0

Since I live in one of the countries with most freedom ever been presented to citizens, I'm using a VPN all the time to connect to free world. Well, this way my connection gets slower but as I grow older and older behind my desktop, I can surf the net.

But I ssh into our company server almost all the time and it does not need to go through VPN so I'm trying to handle this with a static route. I want all the traffic to go through the VPN except for a single IP address.

I try it like this:

$ sudo ip route add x.x.x.x dev wlan0

But after that, I no longer can ping the server:

$ ping x.x.x.x                          
PING x.x.x.x 56(84) bytes of data.
From SAM-ThinkPad-E450 (192.168.1.103) icmp_seq=1 Destination Host Unreachable
From SAM-ThinkPad-E450 (192.168.1.103) icmp_seq=2 Destination Host Unreachable
From SAM-ThinkPad-E450 (192.168.1.103) icmp_seq=3 Destination Host Unreachable
9
  • 2
    You also need to instruct the OS how to reach the IP range. i.e. which gateway to use. Something like the below should work : sudo ip route add <IPRange> via <Gateway> dev wlan0 Sep 30, 2020 at 9:51
  • @MidwayNomad How can I set it to be the gateway for wlan0 without specifying static IP?
    – Mehraban
    Sep 30, 2020 at 10:35
  • The command instructs your OS to use the gateway to reach the specific IP range. Sep 30, 2020 at 11:25
  • @MidwayNomad I know, but if as I'm using dhcp an static IP address may not work all the time.
    – Mehraban
    Sep 30, 2020 at 12:56
  • but wouldnt the default gateway have a static ip? and can you not use this to get to the office server? Sep 30, 2020 at 13:07

0

You must log in to answer this question.

Browse other questions tagged .