2

I cannot access to servers like 192.168.12.123 from vpn if "use this connection only for resources on its network" is checked in vpn settings/ipv4 settings/routes, but I can if this flag is unchecked.

routes address/netmask:

192.168.0.0 255.0.0.0
10.0.0.0    255.0.0.0

flag is unchecked:

route -n                                                                    
Kernel IP routing table                                                        
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0
10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 ppp0
10.35.5.1       0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
168.68.168.6    192.168.0.1     255.255.255.255 UGH   0      0        0 wlan0
168.68.168.6    192.168.0.1     255.255.255.255 UGH   0      0        0 wlan0
192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0

flag is checked

route -n                                                                    
Kernel IP routing table                                                     
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface 
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 wlan0 
10.0.0.0        0.0.0.0         255.0.0.0       U     0      0        0 ppp0 
10.35.5.1       0.0.0.0         255.255.255.255 UH    0      0        0 ppp0 
168.68.168.6    192.168.0.1     255.255.255.255 UGH   0      0        0 wlan0 
168.68.168.6    192.168.0.1     255.255.255.255 UGH   0      0        0 wlan0 
192.168.0.0     0.0.0.0         255.255.255.0   U     9      0        0 wlan0 

main difference is gateway.

0.0.0.0 if flag is unchecked and 192.168.0.1 otherwise.

How to change gateway for checked flag?

Thanks for advance.

2 Answers 2

4

You can add default gateway with command

by the ip address

sudo ip route add default via xxx.xxx.xxx.xxx

xxx.xxx.xxx.xxx - represent ip of vpn server

or by interface

sudo ip route add default dev ppp0  

This can be done manually from terminal when you are connected to vpn.

Second solution is to make script to chance default gw when vpn is connected

Then create script witch will be executed when interface ppp0 go up.

Create script for ppp0 interface

sudo nano /etc/ppp/if-up.d/script

put in script this

    # Check for specific interface if desired
    [ "$IFACE" != "ppp0" ] || exit 0
    # trigger vpn connection
    ip route add default dev ppp0

Save and exit.

Make script called script with execute permissions 755

sudo chmod 755 /etc/network/if-up.d/script

Explanation

When vpn connection will established and ppp0 interface is up script will run and set default device to ppp0

Also you can manually add route to resource on vpn site

sudo ip route add xxx.xxx.xxx.xxx/yy dev ppp0

xxx.xxx.xxx.xxx - represent host/network

yy - represent network mask

example:

add route to host 10.35.5.181 trough ppp0

 sudo ip route add 10.35.5.181/32 dev ppp0

add route to network range 10.35.5.0 with mask 255.255.255.0 trough ppp0

 sudo ip route add 10.35.5.0/24 dev ppp0

This also can be done in Network Manager. On same places where is use this connection only for resources on its network you can add route.

2

Add a route to match the routing table on the remote server:

REMOTE Routing Table

which will give you a local routing table of:

LOCAL Routing Table

I also have some notes for connecting to a L2TP VPN

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .