Posts

Showing posts from March 29, 2019

forward packets from one interface to another interface using iptables

Image
5 1 I have an embeded system with 2 interfaces e0 and m0, whose ips are 10.0.0.20 and 192.168.0.20, respectively. Incoming packets into e0 have an ip of 10.0.0.10 and should be forwarded to m0 interface to external server whose ip is 10.0.0.30. Also, the returning traffic into m0 should be returned to e0. I tried to forward packets with these commands: route add -net 10.0.0.0/16 dev m0 iptables -t nat -A PREROUTING -d 10.0.0.30 -j DNAT --to-destination 192.168.0.20 iptables -t nat -A POSTROUTING -s 10.0.0.0/16 -j SNAT --to-source 10.0.0.20 I did tcpdump at m0 but don't see anything going out. Can you tell me what I am missing? Thank you in advance. 1: lo: <LOOPBACK> mtu 65536 qdisc noop link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: e0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu