0

Been Googling without success sadly.

As I understand it at the moment, data passes down the OSI Model from Transport into Network into Datalink, IP Header is added with the Source/Destination IP Address, then Ethernet header is added with Source/Destination MAC address. This is based on either local ARP lookup or ARP discovery response. However, if the IP Address is not in the local network range the frame is sent to the Default gateway, assuming one is set.

So postulating a simple example - I am 192.168.0.1/24 and I want to message 192.168.2.2/24. As my application passes data to the TCP and on to IP then to Ethernet protocols, at some point something realizes that the destination IP is outside the local network, so this needs to go via the Default Gateway, which clearly has a different IP and MAC from the final destination device. I believe the IP address of the final device is added to the IP Headers, so how does the MAC of the default gateway get added to the Ethernet Frame headers please? Is it part of the functions of the Ethernet protocol layers (if so which one) or is it at the Physical Layer e.g. the NIC?

Can I ask at what point does the Default Gateway addressing get added to the Frame? I assume not at IP as the destination address must remain in the IP header to allow Routing? So is it at the Datalink layer or even a function of the Network Adapter/NIC at the Physical layer?

ouflak
  • 2,458
  • 10
  • 44
  • 49
  • 1
    The OSI model is just a model, and is not implemented in real-world OSes. The gateway layer-2 destination address is the local host destination. Remember that a gateway is just a host on the LAN, albeit one that knows how to reach other networks. There is nothing special about using its layer-2 address vs. the layer-2 address of any other local host. – Ron Maupin Jan 05 '22 at 13:32
  • I'll edit my question to make it clearer – ICSOTSecurityEngineer Jan 05 '22 at 14:05
  • 1
    "_o how does the MAC of the default gateway get added to the Ethernet Frame headers please?_" Exactly the same way the MAC address of any other host on the LAN. A gateway is just another host on the LAN. The ARP process is used to get the MAC address of the gateway (not necessarily the default gateway) toward the destination. – Ron Maupin Jan 05 '22 at 14:19
  • At some point in the process of data being handed between protocols, one must recognize dest IP is outside the network and decide to fill headers with info for Default gateway instead of the destination device. TI presume NOT from adding the IP of the default gateway as that would lose the IP of the destination device. Also, we can't ARP across the Router(s) to get the far end MAC of course. So where is the recognition that as the IP of the destination is outside the network there is a need to use a MAC that does not belong to the destination IP and use MAC of the Default Gateway? – ICSOTSecurityEngineer Jan 05 '22 at 17:14
  • I get there is an ARP Table entry for the Default Gateway that will hold the MAC, and this is the source (I think) for building the headers, but something must be recognizing that there is a need to use that, and not ARP for the destination IP, as it is outside the network. I am asking about which protocol in the stack does that decision function. – ICSOTSecurityEngineer Jan 05 '22 at 17:14
  • You are misunderstanding the ARP process, trying to put the determination of on-/off-LAN somewhere else. When ARP runs, it masks the destination to see if it is on the same network, and it applies to proper MAC address (local host or gateway). – Ron Maupin Jan 05 '22 at 17:20
  • 1
    I think you are confused by trying to apply the OSI model to something that does not follow it and has never recognized it. – Ron Maupin Jan 05 '22 at 17:26
  • Any chance you can format that as the Answer so I can upvote, please? – ICSOTSecurityEngineer Jan 06 '22 at 11:13

0 Answers0