Route with raspian (debian)

Written by pmd - - no comments

I only want to have some process owned by specific users to use the VPN. This means two route table, or more.

Routes

Create a new table "42" for marked packet:

sudo ip rule add fwmark 42 table 42

List all route table:

ip rule list
0:      from all lookup local
32765:  from all fwmark 0x2a lookup 42
32766:  from all lookup main
32767:  from all lookup default

Delete table 42:

sudo ip rule del fwmark 42 table 42

Show "main" table route:

ip route show table main
default via 192.168.1.1 dev wlan0 src 192.168.1.200 metric 303
10.13.0.81 dev tun0 proto kernel scope link src 10.13.0.82
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.200 metric 303

Add a default route in table 42:

sudo ip route add 0.0.0.0/1 via 10.13.0.29 dev tun0 table 42

Delete the default route in table 42:

sudo ip route del 0.0.0.0/1 via 10.13.0.29 dev tun0 table 42

You can delete all routes of a specific table:

sudo ip route flush table 42

Copy all route from table main to table 42:

ip route show table main | while read LINE; do sudo ip route add $LINE table 42; done

Comments are closed.