Definition: Media Access Control Address is a hexadecimal number that's assigned to each device connected to a network to help machines identify one another and communicate with one another. Typically found engraved onto a devices Network Interface Card (NIC). Also identified as the Physical or Hardware Address.
MAC Address Example (In Windows):
00-02-5A-63-3E-16
00-02-5A (i.e. first 3 bytes) corresponds to the identity of the manufacturer of the NIC.
63-3E-16 (i.e. last 3 bytes) corresponds to the unique number from the manufacturer that identifies each device on a network.
MAC Address in Apple & Linux: 00:02:5A:63:3E:16
MAC Address in Cisco: 0002.5A63.3E16
How does it work in the same network?
Each network interface in a device is assigned a unique MAC address, with some devices having multiple MAC addresses.
Example: Should a local machine have an ethernet adapter port, built-in Wi-Fi capabilities (i.e. Wireless LAN adapter), and an Ethernet Bluetooth adapter) then it would have three MAC addresses in the machines system config.
A device in a network will be assigned a unique IP address by the ISP that changes on a regular basis. With the IP address being used to identify the location of the device and the MAC address communicating who the device is. Similar to a residential address and User Pedro inside the residential home.
Connectivity in the same network
When devices want to communicate with each other on the same network, they will inspect each others IP address to start. If the IP addresses are in the same group, then they know that they're all in the same network.
Machine A, when trying to communicate with Machine B, will send out an Address Resolution Protocol or ARP broadcast to all devices on the local network asking Machine B to identify themselves via their local IP address. At confirmation of Machine B's IP address, they will then share their MAC address with Machine A.
Once that connection has taken place, communication can now take place between both machines. The IP & MAC address of both machines will then be stored in their respective cache memory. This is done to make the connectivity more efficient in the future.
How does it work in the different network?
Similar steps are taken as outlined with machines in the same network. The difference is that when Machine A sends a data packet via ARP to their network to access a site of interest (e.g. www.example.com) they will notice that the site is not located in their network.
As a result, Machine A will send an ARP broadcast requesting the MAC address of the default gateway/router in an effort to send their data packet to example.com's IP & MAC address. Once the MAC address of the default gateway has been received, the data packet will be sent over to the default gateway.
Next, the default gateway will inspect example.com's IP address to determine the best route to take to reach the requested IP address. It will then send out an ARP broadcast to the next router to forward along the data packet. In doing so, it'll once again request the MAC address of the next router.
This world-wide game of router telephone will continue until the respective router reaches the IP address of example.com. At that point the router will send an ARP to example.com's IP address, requesting their MAC address. Once the MAC address is provided, then the data packet will be sent along to the final destination.
Summary
When a machine wants to communicate to a machine in a different network it uses an IP address to locate the final destination that the data packet needs to reach.
Meanwhile, the MAC address ensures that at each step the data packet is getting closer and closer to the final destination.
MAC Addresses
Definition: Media Access Control Address is a hexadecimal number that's assigned to each device connected to a network to help machines identify one another and communicate with one another. Typically found engraved onto a devices Network Interface Card (NIC). Also identified as the Physical or Hardware Address.
How does it work in the same network?
Connectivity in the same network
How does it work in the different network?
Summary
References: