article is in testing mode – do not copyleft yet


References:

  1. http://www.linuxhorizon.ro/iproute2.html
  2. http://www.lartc.org/

2 network cards: 
 
  * eth0 ( static on 192.168.0.0/24 lan )
  * wlan0 ( dhcp on 10.10.10.0/24 lan )
 
I want tcp port 22 & tcp port 80 to be routed via wlan0
 
 
# ip rule
# ip route show table all
 
echo 1 WLAN >> /etc/iproute2/rt_tables
 
iptables -A PREROUTING -t mangle -i wlan0 -p tcp --dport 22 -j MARK --set-mark 1
iptables -A PREROUTING -t mangle -i wlan0 -p tcp --dport 80 -j MARK --set-mark 2
 
ip route add default via 10.10.10.1 dev wlan0 table WLAN
 
ip rule add from 10.10.10.0/24 table WLAN
 
ip rule add from all fwmark 1 table WLAN
ip rule add from all fwmark 2 table WLAN

Show links


$ ip l

$ ip a

$ ip link
$ ip link list
$ ip link show
$ ip addr
$ ip addr show

Show routes


$ ip r

$ ip route
$ ip route list
$ ip route show

Flush routes


ip route flush cache


delete net 


ip link delete INTERFACE.VID