Adding route on client using OpenVPN
Solution 1:
Looking at your routing table. There is no explicit route telling traffic to 172...* as you call it. To be sent to the VPN tun interface.
You have several options:
-
If you have access to the openVPN server add this directive to the openvpn config:
push "redirect-gateway def1 bypass-dhcp"
This setting will route/force all traffic to pass through the VPN. The other alternative you have. Is to add a static route yourself on the client side
-
Add the route manually on the client side in a terminal
sudo route add -net 172.16.0.0/24 dev tun0
-
openvpn has a directive for adding and removing of routes client side in your openvpn config file with with the
route
option.Adding:
route 172.16.0.0 255.255.255.0
to your openvpn config file on the vpn client. will add the route automatically when you connect
-
Bonus: openvpn also has a
up
/down
directive that allows you to launch a script on connect to VPN. This can allows you to do any custom action like setting DNS, routes etc. But it requires you to store the commands to execute in another file.So if you had the following to your openvpn client config file
script-security 2 system up run-stuff-after-vpn-connect.sh
Create a file named
run-stuff-after-vpn-connect.sh
(make sure it has execute permissions. And add:#!/bin/sh route add -net 172.16.0.0/24 dev tun0
This will add the route as soon as the tunnel is up
Since you didn't give us the full declaration of your subnet in your question assuming its 172.16.0.0/24