follow this tutorial
https://openvpn.net/community-resources/how-to/#scope
dont forget to do step below
how to add route (not persistent) on ubuntu
example
sudo ip route add 10.10.10.0/24 via 192.168.1.254 # Specific route
sudo ip route add default via 192.168.1.254 # Default route (gw)
how to add persistent route on ubuntu
- modify the /etc/network/interfaces file.
$ sudo nano /etc/network/interfaces
- The route will get set up when one of the interfaces comes up. Find the section that corresponds to the interface that this route will be set up on. Eg. eth0 or em1.
At the bottom of this section, add the following line:up route add -net 192.168.40.0/24 gw 192.168.30.1 dev em1