Exclude IP from OpenVPN route

Viewed 1487

I have an OpenVPN server, and would like to make clients route an address range, like 1.2.3.0/24 through VPN. However, I do NOT want to make clients use VPN for a specific IP address on that same range. So the routing table on the clients should look like this:

1.2.3.4/32 - through client's default gateway
1.2.3.0/24 - through VPN

I added the following to my server.conf:

push "route 1.2.3.0 255.255.255.0"

However, this will route 1.2.3.4 through VPN as well. Is there any way to solve this with OpenVPN server config?

1 Answers

You can add a more specific route for the IP address that you don't want to go through the VPN and use the net_gateway and vpn_gateway options to specify the gateway for the route.

push "route 1.2.3.4 255.255.255.255 net_gateway"
push "route 1.2.3.0 255.255.255.0 vpn_gateway"
Related