title: Intra and Inter Subnet Routing
body: <p>Consider the following figure:</p>
  
  <p><a href="https://i.stack.imgur.com/b8Xs9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b8Xs9.png" alt="enter image description here"></a></p>
  
  <p>Now, suppose that the host with IP address 111.111.111.111 has to send a packet to 222.222.222.222. Here is what I think will happen:</p>
  
  <ol>
  <li><p>The sending host will determine that the destination machine is on some other subnet, and hence there won't be an entry for it in it's ARP table. This is done by ANDing the destination IP address with the mask of the sending host's subnet, and then checking for the subnet address.</p></li>
  <li><p>If it is determined that the destination host is determined to be off the host's subnet, then it will send the frame with the destination address MAC address of the left interface of the middle gateway. My first question: How does the host know the MAC address of this interface?</p></li>
  <li><p>The gateway will receive the frame, and send it to it's interface on the right. In the frame, the destination and source IP addresses will remain the same, but the source MAC address will be of the left interface, and the destination MAC address will  be of the right interface.</p></li>
  <li><p>The interface to the right will receive the frame, and then will replace the source MAC address with the interface address, and the destination MAC address as the MAC address of??? The router or will be consult its ARP table to find the destination MAC address.</p></li>
  </ol>
  
  <p>What is the use of the routers in between? Are frames also sent to them using their interfaces' MAC address? For example, the host with IP 111.111.111.111 would first send the frame to the router using its MAC, and then the frame is routed forward. </p>
  
  <p>I am so confused right now. Can someone clear these things up?</p>
  
  <p>Thanks!</p>