This is some route command output sample:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.240.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.240.0 0.0.0.0 255.255.240.0 U 0 0 0 eth2
When my computer wants to send an IP packet with a destination address of 1.2.3.4
, the packet is sent through eth0 to the gateway 192.168.240.1
. The IP packet contains 2 fields: the source IP and the destination IP. If the source IP is the IP of my computer and the destination IP is 1.2.3.4
, how does the router (gateway) know this IP packet is intended to be forwarded by him? Where in the IP packet is the gateway's IP stored?