What is MAC address?
A Media Access Control address (MAC address) is a hardware identifier that uniquely identifies each device on a network.
When device is manufactured it is assigned a MAC address which can be found on NIC (network interface controller) card.
It can also be known as physical address, hardware address, or ethernet hardware address.
When a device transmits a packet to the other device, it reaches the switch, which scans the packet’s header to figure out what to do next.
MAC address are assigned to NICs or other hardware they do not change by itself. Many network interfaces support MAC address changes.
A MAC address is a 48-bit hexadecimal address. It’s usually six sets of two digits or characters, separated by colons.
An example MAC address would be 00:00:5e:00:53:af. Many network card or hardware manufacture uses a unique sequence at the begining of their MAC address which is called as OUI (organizationally unique identifier).
OUI is usally first three bytes of digits or characters.
What is an IP address?
An IP address, or Internet Protocol Address, is a series of numbers that identifies any device on a network.
Computers use IP address to comunicate with each other both over internet or LAN. IP address helps internet to identify different computers, routers or websites.
An IP address is a string of numbers separated by periods. IP addresses are expressed as a set of four numbers — an example address might be: 127.0.0.1.
Each number in the set can range from 0 to 255 therefore, the full IP addressing range goes from 0.0.0.0 to 255.255.255.255.
Difference between IP address and MAC address?
|IP Address||MAC Address|
|known as Internet Protocol Address||known as Media Access Control Address|
|it is either four or sixteen byte address||it is a siz byte hexadecimal address|
|ISP can provide IP address||NIC manufacture provides the MAC address|
|IP operates at network layer||MAC address operates at data link layer|
|ip address identify connection of a device on internet||mac address helps identifying the actual device|
|ip can change with time and environment||mac cant be changed with time and environment|
|ip address sharing is allowed with multiple clients||mac address can not be shared|
|ip address is software oriented||mac address is hardware oriented|
How ARP works between IP and MAC address?
Let's take following example:
Let say that computer A wants to send a message to computer B. Computer A does not know about MAC address of computer B.
Computer A will broadcast ARP request which is recieved by computer B and computer C on the same network.
ARP request basically tells "Here is my ip and mac address and I am looking for mac address of a device with this ip address".
Every device on a network has its own ARP table. When computer B recieves the request it first check to see if computer A does not exists in its own ARP table.
If not it will create a new entry by adding computer A mac and ip address in ARP table of computer B.
Then, computer B will send an ARP reply with its IP address and MAC address. Computer A will receive the reply and add ip and mac info of computer B to its ARP table.
It is important to know that anyone can lookup ip address in a header while AC address can’t easily be found by others.
Once an IP packet leaves your LAN and goes through a router, it removes MAC address from the header.
Therefore, anyone outside your LAN never sees your MAC in the IP packet (unless an application sends it as data).