Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude IP from OpenVPN route

Tags:

openvpn

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?

like image 296
sfphoton Avatar asked Oct 15 '25 15:10

sfphoton


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"
like image 89
ilikeMUDs Avatar answered Oct 17 '25 22:10

ilikeMUDs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!