I need to route packets from an owner(lets say with uid-owner 'mailuser') to ppp1 network interface, and all other packets to ppp0 network interface. (Assuming the two network interfaces namely ppp0 and ppp1 are up)
So, I used the below-mentioned commands to test the proper routing of packets(which were generated by web browser with uid-owner 'mailuser'), to ppp1 network interface.
Following are the commands used (along with a short description) :
1. Copied all routes from table main to table 100 and table 200.
sudo ip route show table main <route1> <route2> <routeN> sudo ip route add <route1> table 100 sudo ip route add <route2> table 100 sudo ip route add <routeN> table 100 sudo ip route add <route1> table 200 sudo ip route add <route2> table 200 sudo ip route add <routeN> table 200
2. Changed the default routes for the tables 100 & 200.
sudo iptables route change default via <gateway_ip_of_ppp0> dev ppp0 table 100 sudo iptables route change default via <gateway_ip_of_ppp1> dev ppp1 table 200
3. Removed the routes in main table.
sudo ip route flush table main
4. Marked the packets if the uid is 'mailuser'.
sudo iptables -t mangle -A OUTPUT -m owner --uid-owner mailuser -j MARK --set-mark 0x1
5. Added rule to look up table 100 (default route through ppp0) for packets which are not marked.
sudo ip rule add not fwmark 0x1 lookup 100
6. Added rule to look up table 200 (default route through ppp1) for packets which are marked with 0x1.
sudo ip rule add fwmark 0x1 lookup 200
7. Flushed the routes in cache
sudo ip route flush cache
I expected all the traffic from user
mailuser to be sent via
ppp1, which was so, as seen over
tcpdump -I ppp1.
But, no response packets were received as inferred by the logs, hence, the browser(whose process has pid-owner
mailuser) was not able to load any web-site.
So, What could be the problem here? As the browser is unable to load any web page when default route of table 200 is ppp1, whereas when I changed the default route to ppp0, it was working fine.
I have already checked ping command on both interfaces i.e. Ppp0 and ppp1, which works fine for both.
Please help in identifying & solving the problem of Why sending packets via the other 'ppp1' network interface fails?