I know that in the Internet layer, the source ip and mac address and destination ip and mac address are added to the header. Is this the ip and mac address of the next router we take to get to the end router or just the ip and mac address of the computer we are sending the data too.


1 Answer 1


A packet only contains the final destination IP address otherwise it would be lost. On a Windows computer, type route print in CMD to see the routing table of your computer (which can act just like a router if you enable routing in its settings). Mine looks like such:


IPv4 Route Table
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
     55         On-link    331         On-link    331         On-link    331         On-link    311         On-link    311         On-link    311         On-link    281         On-link    281         On-link    281         On-link    331         On-link    281         On-link    311         On-link    331         On-link    281         On-link    311

Terminology is different for every device but normally you have the path to take for every interface. The interface is the actual IP address given to your network card by the DHCP server of your router (or the static IP you gave your machine). What the table above says is that if the packet exiting the computer is going to any IP (, send it to the gateway which is or the router. It says so with that line:     55

Also, if the destination is to, the destination is "On-Link" meaning it has a direct physical link because it is on the local network. You can thus reach it using its MAC address. It says so with this line:         On-link    311

My configuration is very simple (computers behind one router facing internet). You can have much more complex configurations with LAN networks using switches and several local routers in the same building. Even then, a simplified overview is quite simple. Every router has a routing table, an ARP table and a NAT table. The routing table is like above. It tells the computer if the connection to an IP address is On-Link. If it isn't, then send it to the gateway (more often the router facing internet in simple configurations). To do that, the computer uses its ARP table. Type arp -a to see the ARP table of your computer. Mike looks like below:

Interface: --- 0x11
  Internet Address      Physical Address      Type           58-d5-6e-91-f0-08     dynamic            01-00-5e-00-00-16     static           01-00-5e-00-00-fb     static           01-00-5e-00-00-fc     static       ff-ff-ff-ff-ff-ff     static

The computer uses the ARP protocol to get the MAC address of the computers (or routers) which are On-Link. The computer then sends packets to these machines directly (either in the Ethernet wire or using electromagnetic waves in WIFI configurations).

A router also has a NAT table which makes the link between the external IP of the network and the internal IP (local IP). The NAT specification saves some IP addresses for local use (see RFC 1918). These IP addresses range are to be used locally. When a packet reaches a router facing internet, the NAT table is used to change the local IP address of the machine into the public IP address of your router provided by your ISP. Your router will most often get this IP using the DHCP server of your ISP. The NAT table also saves local ports and changes the local source port to a random port number.

To answer your question, the IP address in the packet is only the final destination IP address. The router takes this IP address and compares it to the routing table entries. If the IP is On-Link, it sends the packet directly using Ethernet or WIFI. Otherwise, it sends the packet to the default gateway. The default gateway for a router facing internet is a special interface often called the WAN interface. The router, uses a NAT table to change the local IP addresses to the public IP of the WAN interface. The WAN interface is connected to your modem which is connected to a wire (either fiber or coaxial) which quits your home to go directly to the ISP which dispatches requests to other bigger ISPs and eventually to the website you try to join. The website you try to join needs to have a fixed port forwarding entry to listen to requests. The port forwarding entries create entries in the NAT table which are saying: if the incoming packet has a certain destination port, send it to the machine with this certain internal IP.

  • $\begingroup$ Thank you sir! 😄 $\endgroup$
    – M G
    Jun 10, 2021 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.