Choose route path by user id
Hi,
There are two users (user1,user2) on my system, and too interfaces (eth0,wlan0). I want to forward traffic generated by user1 to eth0 and user2 to wlan0. wlan0 is 10.50.50.14/24 with gateway at 10.50.50.1 and eth0 192.168.1.11/24 with gateway at 192.168.1.1. So I need user1 to use gateway 192.168.1.1 and user2 10.50.50.1. First thing I've done is marking outgoing packets from user2 with iptables MARK target like this: Code:
# iptables -t mangle -A OUTPUT -m owner --uid-owner user2 -j MARK --set-mark 1 Code:
# ip rule add fwmark 1 lookup gwroute Code:
10.5.50.0/24 dev wlan0 scope link src 10.5.50.14 Code:
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.11 metric 202 Code:
iptables -t nat -A POSTROUTING -o wlan0 -j SNAT --to 10.50.50.14 Thanks! |
All times are GMT -5. The time now is 11:18 AM. |