Networking Basics: How IP and MAC Addresses Work
Quick Definition: IP addresses and MAC addresses both identify devices on a network, but they work a bit differently. A MAC address is hard coded into a device, while the IP address is the virtual address.
Let's say you want to go to cbtnuggets.com. It's easy. You type in the URL, and away you go. It's a simple process most of us perform multiple times a day. But most people don't realize a lot happens behind the scenes to get you there. For instance, a MAC address, IP address, and subnet mask are responsible for making sure you land in the right spot. How does it work? What do these different addresses mean?
Let's explore how it all works.
What is a MAC Address?
A MAC address is a device's "physical" address. It's hard-coded to the network card from the manufacturer. Represented by a 12-digit hexadecimal number, every device worldwide has a unique MAC address. (The 48-bit identifier has 281.5 trillion combinations, so you shouldn't worry about duplicates.) While most people don’t remember or care about MAC addresses, they work behind the scenes to identify your device on a network.
What is an IP Address?
The IP address is a virtual address that changes depending on the network your device connects to, or even when you reboot your computer. Years ago, you kept the same IP address on your computer, but now IP addresses are usually dynamically assigned. Some websites always have the same IP address, called a Static IP Address.
Think of it like a street address you might give out to receive mail where you live — except the IP address can change over time.
What is a Subnet Mask?
Subnet masks work like a filter to help determine which part of an IP address identifies the network and which identifies the device on that network. Every IPv4 address has a network portion and a host portion. These parts are defined by the subnet mask assigned to the address.
A common subnet mask of 255.255.255.0 tells us the first three octets of the address denote the network portion, and the last octet denotes the address's host portion. With an address of 220.127.116.11 with a 255.25.255.0 mask, 192.168.3.0 is the network, and the last octet, .4, is a host on that network.
How MAC Addresses, IP Addresses, and Subnet Masks Work Together
Say you have a house with a router. The router connects all your devices to the internet. You've got an Xbox, iPhone, and a couple of computers.
If yours is like most homes in the world, you have a subnet that starts with 192.168.1. It's the default subnet on most residential routers. So, every device has an IP address that starts with those three octets and ends with a unique number.
Here's an example of the devices on a subnet:
Computer 1 – 192.168.1.5
Computer 2 – 192.168.1.6
Xbox – 192.168.1.7
iPhone – 192.168.1.8
Note that each device on the network starts with 192.168.1, and then the router assigns a unique number at the end for each device.
When you tell your computer to talk to another device, your computer goes, "Hi, router. I'm 192.168.1.5, and I'm trying to contact 192.168.1.6. It's on this network."
Your router will have an internal table called an ARP cache. This table holds a mapping of IP addresses to physical MAC addresses. If the IP address you are trying to talk to is listed in the table, the router immediately forwards your traffic to the destination.
If your router doesn't know the MAC address, it asks all the devices on the network. That's called a broadcast ARP message.
The router says, "Hello, network. Who is 192.168.1.6?"
The second computer goes, "Oh, that's me, and here is my MAC address."
When this exchange is complete, the router stores the new IP to MAC address relation in its ARP cache for use at a later time.
That's how your Local Area Network (LAN) uses IP and MAC addresses, and it's essential to understand these simple mechanics — even if you're setting up a home network. It is worth noting that setting up networks for a business or large organization can get a lot more complicated.
Here's CBT Nuggets trainer Jeremy Cioara explaining how this works in more detail:
Final Thoughts on IP and MAC Addresses
Understanding how MAC addresses, IP addresses, and subnets work together is fundamental in understanding how networking works. While most residential customers might only need to know the basics, you'll want to dive deeper if you're looking for a career in IT.
Start by checking out our free Intro to Networking training. It explores different types of networks, like LANs and VPNs, as well as how to get started in a career in networking.
delivered to your inbox.