What are MAC Addresses, IP Addresses, and Subnet Masks?
Let’s say you want to go to cbtnuggets.com. It’s easy. You type in the URL and away you go. But most people don’t realize there’s a lot happening behind the scenes to get you there. Here are all the parts you need to know.
A MAC addressis 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 in the world has a unique MAC address. (In case you were wondering, the 48-bit identifier has 281.5 trillion combinations, so you shouldn’t be worried about duplicates.) Truth be told, we don’t usually care about it — it works behind the scenes.
The IP address is a virtual address and it changes depending on the network your device connects to, or even every time 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.
Subnet masks. Every IPv4 address has a network portion and a host portion. These parts are defined by the subnet mask that is assigned to the address. A common subnet mask of 255.255.255.0 tells us the first three octets of the address denotes the network portion and the last octet denotes the host portion of the address. With an address of 126.96.36.199 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
So let’s put all these pieces together. Let’s 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 probably have a subnetthat 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 then 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 assigned 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 important to understand these simple mechanics.
Here’s CBT Nuggets trainer Jeremy Cioara telling the whole story:
Not a CBT Nuggets subscriber? Start your free week now.