I am trying to check the gateway that I wrote (see What is the easiest way to test the gateway? For context). Due to a problem that I would prefer not to get, the gateway and the "sender" must be on the same machine. I have a receiver (say, 9.9.9.9) that the gateway can reach.
So, I launched an application ./sendStuff 9.9.9.9that will send some packets to this IP address.
The problem is this: how to get packets destined for 9.9.9.9 to go to the gateway on the local host? I tried:
sudo route add -host 9.9.9.9 gw 127.0.0.1 lo
sudo route add -host 9.9.9.9 gw <machine external IP address> eth0
but not one of them passes packets through the gateway. I have verified that the correct IP addresses are present in sudo route. What can I do?
Upon request, here is the route table, after running the second command (IP addresses are changed to fit the question. Xyzt is the IP address of the machine on which I run this):
Destination Gateway Genmask Flags Metric Ref Use Iface
9.9.9.9 x.y.z.t 255.255.255.255 UGH 0 0 0 eth0
x.y.z.0 0.0.0.0 255.255.254.0 U 0 0 0 eth0
0.0.0.0 <gateway addr> 0.0.0.0 UG 100 0 0 eth0
source
share