I am trying to setup a small loopback program in python to send UDP packets from one interface to the other. Without modifying iptables, the kernel will just short circuit any communication and send it directly to a specific interface without ever going over the wire. Using the following I was able to get pings to travel over the wire (from this post) but I'm not sure how to get UDP to do the same thing.
ifconfig eth2 10.50.0.1/24
ifconfig eth3 10.50.1.1/24
# nat source IP 10.50.0.1 -> 10.60.0.1 when going to 10.60.1.1
iptables -t nat -A POSTROUTING -s 10.50.0.1 -d 10.60.1.1 -j SNAT --to-source 10.60.0.1
# nat inbound 10.60.0.1 -> 10.50.0.1
iptables -t nat -A PREROUTING -d 10.60.0.1 -j DNAT --to-destination 10.50.0.1
# nat source IP 10.50.1.1 -> 10.60.1.1 when going to 10.60.0.1
iptables -t nat -A POSTROUTING -s 10.50.1.1 -d 10.60.0.1 -j SNAT --to-source 10.60.1.1
# nat inbound 10.60.1.1 -> 10.50.1.1
iptables -t nat -A PREROUTING -d 10.60.1.1 -j DNAT --to-destination 10.50.1.1
ip route add 10.60.1.1 dev eth2
arp -i eth2 -s 10.60.1.1 00:1B:21:C1:F6:0F # eth3's mac address
ip route add 10.60.0.1 dev eth3
arp -i eth3 -s 10.60.0.1 00:1B:21:C1:F6:0E # eth2's mac address
ping 10.60.1.1
I would like tp be able to broadcast a UDP message out on 10.50.0.1
, and read it on 10.50.1.1
How can I go about doing this?