OpenVPN Route Private traffic only (OpenVPN Server on linux)

You can route specific subnet via OpenVPN and the rest of the traffic will be routed to the default PC gateway.

Note: this is valid on OpenVPN installations on Linux that have been installed using this installation script: https://github.com/angristan/openvpn-install

 

Open OpenVPN server.conf file:

/etc/openvpn/server.conf

Remove or comment out the following lines:

push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "redirect-gateway def1 bypass-dhcp"

 

Add the following line where 10.0.0.0 is the network that we need to route via OpenVPN.

push "route 10.0.0.0 255.0.0.0"

 

Save the file and restart using the following command:

sudo systemctl restart openvpn-server@server.service