Simply put, the IP address is provided by the service provider, and the MAC address is the physical address of your Nic. I. I believe everyone is familiar with the IP address, that is, the 32-bit address assigned to the host using the TCP/IP protocol. An IP address consists of four octal groups separated by dots. For example, 192.168.0.1 is an IP address, which is written in dotted decimal format. An IP address consists of a network address and a host address. The number of BITs assigned to these two parts varies with the address class A, B, and C. The network address is used for routing, while the host address is used to find a separate host in the network or subnet. An IP address makes it possible to transmit data from the source address to the destination address through a route. 2. MAC addresses are not necessarily familiar with MAC addresses because they are not directly in contact with them. In the OSI (Open System Interconnection) layer-7 network protocol (physical layer, data link layer, network layer, transmission layer, Session Layer, presentation layer, application layer) reference model, the second layer is the data link ). It contains two sub-layers. The upper layer is Logical Link Control (LLC: Logical Link Control), and the lower layer is the media access control layer we mentioned earlier, media Access Control Layer. Media refers to the various physical environments through which signals are transmitted. Commonly used network media include cables (such as twisted pair wires, coaxial cables, and optical fibers), as well as microwave, laser, and infrared rays, which are sometimes called physical media. A mac address is also called a physical address, hardware address, or link address. It is written into the hardware when produced by a network device manufacturer. This address has nothing to do with the network, that is, no matter where the hardware with this address (such as NIC, Hub, or router) is connected to the network, it has the same MAC address, generally, the MAC address cannot be changed and cannot be set by the user. 3. The length, representation method, allocation method, and uniqueness of the MAC address are 48 bits (6 bytes), usually expressed as 12 hexadecimal numbers, separate Two hexadecimal numbers with colons. For example, 08: 00: 20: 0a: 8c: 6d is a MAC address, the first six hexadecimal digits 08:00:20 represent the number of the network hardware manufacturer, which is allocated by the IEEE (istitute of Electrical and Electronics Engineers, Association of Electrical and Electronics Engineers, the last three hexadecimal numbers 0a: 8c: 6d represent the serial number of a network product (such as a NIC) manufactured by the manufacturer. Each network manufacturer must ensure that each Ethernet device it creates has the same first three bytes and different last three bytes. This ensures that each Ethernet device in the world has a unique MAC address. 4. IP address and MAC address in the Internet connection. Since each Ethernet device has a unique MAC address at the factory, why do I need to assign an IP address to each host? Or why is each host assigned a unique IP address? Why is a unique MAC address embedded in the production of network devices (such as network adapters, hubs, routers, and so on? The main reasons are as follows: (1) IP Address allocation is based on the topological structure of the network, rather than based on who made the network settings. If an efficient routing scheme is built on the basis of the device manufacturer rather than the topological location of the network, this scheme is not feasible. (2) When there is an additional layer of address addressing, the device is easier to move and maintain. For example, if an Ethernet Card is broken, it can be replaced without getting a new IP address. If an IP host is moved from one network to another, you can give it a new IP address instead of a new Nic. (3) communication between computers in the LAN or Wide Area Network eventually means that data packets are transmitted from one node to another starting from the initial node on a certain form of link, finally transmitted to the target node. ARP (Address Resolution Protocol: Address Resolution Protocol) is responsible for ing IP addresses to MAC addresses. Let's take an example to see how IP addresses and MAC addresses are combined to send packets. Assume that a packet (called PAC) is sent from a host in Beijing (named a, IP address ip_a, MAC address mac_a) to a host in Washington (named B, the IP address is ip_ B, And the MAC address is mac_ B ). The two hosts cannot be directly connected. Therefore, data packets must pass through many intermediate nodes (such as routers and servers) during transmission ), we assume that during transmission, C1, C2, and C3 (their MAC addresses are M1, M2, and m3 respectively) are required. Before sending a PAC, A sends an ARP request to find the MAC address M1 of C1, the first intermediate node that must be passed to ip_ B, then encapsulate these addresses in the data packet: ip_a, ip_ B, mac_a, and M1. After a PAC is transferred to C1, ARP finds the MAC address m2 of the second intermediate node C2 Based on the IP address ip_ B, then, the data packet with M2 is sent to C2. And so on, until the mac_ B address of host B with the IP address ip_ B is found, and finally sent to host B. During transmission, ip_a, ip_ B, and mac_a remain unchanged, while the MAC address of the intermediate node is constantly changing through ARP (M1, M2, M3) until the target address is mac_ B. Based on the above, we can conclude that the similarities between IP addresses and MAC addresses are unique. The main characteristics of different IP addresses are as follows: 1. for a device on the network, such as a computer or a router, its IP address can be changed (but must be unique), while the MAC address cannot be changed. You can specify any IP address for a host as needed. For example, you can assign an IP address of 192.168.0.112 to a computer on the LAN, or change it to 192.168.0.200. Once a network device (such as a NIC or vro) is created, its MAC address is always unique and cannot be changed by the user. 2. different lengths. The IP address is 32 bits and the MAC address is 48 bits. 3. Different allocation bases. IP Address allocation is based on network topology, while MAC Address allocation is based on the manufacturer. 4. The Addressing protocol layer is different. The IP address is applied to the Layer 3, that is, the network layer, and the MAC address is applied to the Layer 2, that is, the data link layer. The data link layer protocol transfers data from one node to another node on the same link (through the MAC address ), the Network Layer Protocol allows data to be transmitted from one network to another (ARP finds the MAC address of the intermediate node based on the destination IP address and transmits it through the intermediate node to reach the destination network ).
Relationship between MAC addresses and IP addresses