What is the MAC address used for? How is it related to the IP address?
When we connect to WiFi or set up a computer network, we will see two things: IP address and MAC address. Many people may have some idea about IP, but when it comes to MAC address, they are confused. What is the use of this string of symbols?
1. Basic explanation
MAC address: A number that comes with the device network card when it leaves the factory. This thing is unique in the world and will not be repeated unless you change it yourself. Your mobile phone, computer, printer, and even smart refrigerator will have its own MAC address.
IP address: Everyone is familiar with IP address. When you connect to the Internet, the system will automatically assign an address, but the IP address will change frequently. For example, if you connect to the company network today and change the WiFi at a cafe tomorrow, the IP address will change. But the MAC address of your device will not change.
2. Frequently Asked Questions
1. How do they work together?
If you want to send data to a certain IP (for example, visit a web page), the system must first know which device this IP corresponds to, that is, what the MAC address is. If there is no corresponding information in the system's arp table, the system uses the ARP protocol to broadcast what the MAC address corresponding to the IP is.
Then store the received MAC in its own arp table.
Then encapsulate the MAC address in the packet and send it out.
Summary: IP is used for positioning, and MAC is used to actually send data. If you only know the IP, the data cannot be sent out, and you also need to know the MAC.
2. Why can't we communicate directly using the MAC address?
Some people may think, since each device has its own MAC address, and this address is unique in the world, why do we still need an IP address to make things lively? Isn't it simpler to communicate directly using MAC?
This question is actually quite common, but the answer is also very clear: MAC addresses are only useful in local area networks.
You can imagine, if all the devices in the world rely on MAC to communicate, how many routers would be needed to remember the MAC of each device at the same time? It would be impossible to support it, and there would be no way to plan the network. It would be too chaotic.
The original intention of the design of IP addresses was to solve this problem. It can be managed in a hierarchical manner, and can be planned and routed. The network is so large, and it is IP that connects all the networks.
3. Let’s sort out the ideas
The MAC address will not change easily, it is the unique symbol that identifies your device. The IP address will change at any time. When transmitting data, first find the target device through IP, then use ARP to ask for its MAC address, and finally send it accurately.