setting routes that survive a reboot

twisted roads

The problem:

I have set up Proton VPN for all traffic, but I want to access some hosts in the private range. As all traffic is going through the VPN tunnel, the hosts are unreachable.

The Solution:

Routes need to be set that tell the system “If you want to go to this host / network, use this gateway“.

Create and enable a service to do this the below does not work for me

As root, go to /etc/network/interfaces.d

Create a file here with a descriptive name, I have used “localroutes” and add the following:

up route add -net <NETWORK> gw <GATEWAY>

To make it such that all traffic destined for the subnets 192.168.99.0 and 10.10.10.0 must go through the gateway 192.168.0.1:

up route add -net 192.168.99.0/24 gw 192.161.0.1
up route add -net 10.10.10.0/24 gw 192.168.0.1

Save the file and restart networking:

sudo systemctl enable networking
sudo systemctl restart networking

OR

sudo service networking restart

Now the traffic shall be routed accordingly, to encompass additional subnets, just add lines to the file following the above example

Leave a Comment

Your email address will not be published. Required fields are marked *