Wednesday, June 11, 2014

Mangle route mark on linux

I- Mark traffic type, you have to mangle,
root@localhost# iptables -A PREROUTING -i vboxnet1 -t mangle -p tcp --dport 80 -j MARK --set-mark 2
root@localhost# iptables -A PREROUTING -i vboxnet1 -t mangle -p tcp --dport 8080 -j MARK --set-mark 2
root@localhost# iptables -A PREROUTING -i wlan0 -t mangle -p tcp --dport 8080 -j MARK --set-mark 2
root@localhost# iptables -A PREROUTING -i wlan0 -t mangle -p tcp --dport 80 -j MARK --set-mark 2


II- Create route table and set the traffic that we already mark and send it to specific gateway
root@localhost# echo 201 mail.out >> /etc/iproute2/rt_tables
root@localhost# ip rule add fwmark 2 table mail.out
root@localhost# ip route add default via 192.168.56.222 table mail.out
root@localhost# ip route flush cache



III- All route forwarding and disable filter
root@localhost# for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 0 > $f ; done
root@localhost# echo 0 > /proc/sys/net/ipv4/route/flush

No comments:

Post a Comment