Find a course

Module 2: Addressing: MAC, IPv4, Subnets and IPv6Lesson 4 of 1311 min

MAC Addresses, IPv4 and Private Networks

Compare MAC and IP addresses, read IPv4 in dotted decimal and binary, see how ARP links them, and learn private ranges and NAT.

Step 1 of 12Learn

Two addresses for every device

Your laptop has at least two addresses, and they solve different problems.

A MAC address (Media Access Control) is a 48-bit hardware address assigned to the network interface, written as six pairs of hexadecimal digits: 3C:22:FB:9A:10:7E. The first half usually identifies the manufacturer. MAC addresses are used only on the local link, to get a frame from one device to the next one on the same Ethernet segment or Wi-Fi network. They never cross a router. Modern phones and laptops often use a randomized MAC address for each Wi-Fi network to make tracking harder.

An IP address is a logical address that identifies a device's location in a network. It is assigned by configuration, often automatically, and changes when you move to another network: your laptop gets one address at home and another at a coffee shop. IP addresses are what routers use to move packets between networks, end to end.

An analogy: the MAC address is like a person's name, useful for finding them inside one room. The IP address is like a mailing address, which tells the postal system which city, street and building to deliver to. Postal workers route mail by address; once it reaches the building, a name finds the right person.

Step 2 of 12Compare

MAC address vs. IP address

AspectMAC addressIPv4 address
Length48 bits32 bits
Written asSix hex pairs: 3C:22:FB:9A:10:7EFour decimal numbers: 192.168.1.20
Assigned byManufacturer (or randomized by the OS)Network configuration, usually DHCP
LayerLayer 2, data linkLayer 3, network
ScopeOnly the local link; never crosses a routerEnd to end across networks

Step 3 of 12Learn

Reading an IPv4 address

An IPv4 address is 32 bits long. Humans write it as four numbers separated by dots, each representing 8 bits (an octet), so each number ranges from 0 to 255: 192.168.1.20.

Each octet is a binary number. The eight bit positions have values 128, 64, 32, 16, 8, 4, 2 and 1. Add the values of the bits that are 1:

11000000 = 128 + 64           = 192
10101000 = 128 + 32 + 8       = 168
00000001 = 1                  = 1
00010100 = 16 + 4             = 20

So 192.168.1.20 is 11000000.10101000.00000001.00010100 in binary. You'll need this skill in the next lesson, because subnet masks are much easier to understand in binary.

32 bits allow 232, about 4.3 billion addresses. That sounded like plenty in the early 1980s, but with billions of phones, laptops, servers and smart devices, the free pool ran out. The regional registries that hand out addresses exhausted their general pools during the 2010s. Two solutions followed: private addresses with NAT, which stretched IPv4, and IPv6, which replaces it with a far larger space.

A few special addresses appear constantly: 127.0.0.1 is loopback, meaning "this computer itself", and an address starting with 169.254 means a device asked for an address automatically and got no answer.

Step 4 of 12Practice · Work it out

What is the decimal value of the binary octet 11100000?

Step 5 of 12Try the calculator

Binary octet decoder

Set each bit to 0 or 1. Each position is worth twice the one to its right.

Decimal value
192

Step 6 of 12Learn

Private addresses, NAT and ARP

Three ranges are reserved as private addresses (RFC 1918). Anyone can use them inside their own network, and they are never routed on the public internet:

  • 10.0.0.0 to 10.255.255.255 (10.0.0.0/8)
  • 172.16.0.0 to 172.31.255.255 (172.16.0.0/12)
  • 192.168.0.0 to 192.168.255.255 (192.168.0.0/16)

Millions of homes use 192.168.1.x at the same time without conflict, because those addresses never leave the home. When your phone talks to a website, your router performs NAT (network address translation). It replaces the private source address with its own single public address, remembers the conversation in a table, and translates replies back to the right device. One public address can serve dozens of devices this way. A side effect is that devices behind NAT can't easily be reached from the internet unless you set up port forwarding, which also acts as a basic shield.

On the local network, one more step is needed. To send a packet to 192.168.1.1, your laptop needs that device's MAC address. It uses ARP (Address Resolution Protocol): it broadcasts "Who has 192.168.1.1?", the owner replies with its MAC address, and the laptop caches the answer for a while. You can see the cache with arp -a on Windows or ip neigh on Linux.

Step 7 of 12Practice · Sort into groups

Sort each IPv4 address as private or public.

Tap an item, then tap its group (or drag it there).

Step 8 of 12Diagram

NAT: many private devices, one public address

NAT: many private devices, one public addressProcess diagram: Laptop 192.168.1.20 → Router rewrites the source → Server replies to 203.0.113.7 → Router maps it back.Laptop192.168.1.20Routerrewrites thesourceServerreplies to203.0.113.7Router mapsit back

Tap a shape with to see more.

Laptop 192.168.1.20

Sends a request from a private address.

Router rewrites the source

Swaps in its public address, say 203.0.113.7, and notes the mapping in a table.

Server replies to 203.0.113.7

It never sees the private address.

Router maps it back

Looks up the table and forwards the reply to 192.168.1.20.

Step 9 of 12Practice · Put in order

Your laptop (192.168.1.20) sends its first packet to the printer at 192.168.1.50 on the same network. Put the steps in order.

Drag the items, or use the arrow buttons, to put them in order.

  1. The printer replies with its MAC address
  2. It broadcasts an ARP request asking who has 192.168.1.50
  3. The laptop checks its ARP cache and finds no entry for 192.168.1.50
  4. The laptop stores the MAC address in its ARP cache
  5. The laptop sends the frame addressed to the printer's MAC address

Step 10 of 12Note

Step 11 of 12Practice · Fill in the blanks

Fill in the blanks

An IPv4 address is bits long and a MAC address is bits long.

Step 12 of 12Practice · Choose one

A device shows the IP address 169.254.37.112. What does this most likely mean?