Answer the question
In order to leave comments, you need to log in
How to redirect the traffic of the desired user in iptables to another interface?
There are two interfaces eth0 and eth1 It is
necessary to redirect all user traffic under the id 1001 to the second interface eth1
Possible to implement? if so how?
Answer the question
In order to leave comments, you need to log in
iptables -t mangle -N markrt
iptables -t mangle -F markrt
#в локальную сеть не маркируем
iptables -t mangle -A markrt -d 172.16.0.0/24 -j RETURN
iptables -t mangle -A markrt -m connmark ! --mark 0 -j RETURN
iptables -t mangle -A markrt -j MARK --set-mark 10
iptables -t mangle -A OUTPUT -m owner --uid-owner 1001 -j markrt
#если приложение не прибито к интерфейсу eth1, то адрес будет кривым. исправляем
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
#делаем default маршрут, поменять на свое, table 10 - оставить
ip route add default dev eth1 via 172.16.0.1 table 10
#пакеты, промаркированные 0xa должны маршрутизироваться по правилу
ip rule add fwmark 10 lookup 10
Mark user packets in iptables and make a separate routing table for marked packets
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question