Routing MAC Address Interface – Where Does a Host Save Its IP Address?

datainterfacemac addressrouting

While building a particular packet to be sent across or outside the network, the host, at a certain point, needs to specify the MAC address of the interface through which the packet is going to be sent. To know this address, the host checks its routing table for a network that includes the IP address of the destination node and retrieves the IP address of the interface through which packets to that network are supposed to be sent. My question is concerning the step that happens after this. How does the host translate the IP address of one of its interfaces to the corresponding MAC address? Does it check its MAC address table or are these correspondances stored in some global data structure that the host can access independently of its MAC address table?

Best Answer

Every operating system is potentially completely different and may do more than one thing in regard to this question. The operating system may store its various interface MAC addresses at some location in a configuration file on disk, or simply store it in RAM on start up, or in a database of some kind. It is up to the operating system to do so.

Or it may not store it at all and may simply rely on the network interface driver software to inject such information in packets/frames as needed when they are encapsulated and put 'on the wire'. Technically the operating system (and certainly the application on a device) does not need to 'know' the MAC address of a given network interface in order to send or receive data over it. The interface and its driver software do need to have that in their configuration. This kind of abstraction is key to the layered network model where each layer only needs to deal with its own function and can rely on its neighboring layers to perform their functions.

Of course, some applications may want to access information about IP addresses, MAC addresses, ARP or ND tables, etc. so that kind of information can be accessed for tools like configuration interfaces, traffic capture tools, command line tools and display, etc. But those are diagnostic applications that specifically need to access that data as part of their function. An email program, for example, can send an email without knowing the MAC address of the network interface it uses to make an SMTP connection.

You shouldn't think of the computer as a wholistic organism that has to understand its own working components to function optimally. It is a collection of connected subsystems that work together to accomplish complex tasks that are broken down into tiny mathematical functions and only look like a familiar job to us from the top down view we have as human beings.

Related Topic