IP Addresses, Subnets, and Gateways
Introduction
Imagine trying to send a letter without an address. That's how computers would behave without IP addressing and routing. Whether you're troubleshooting a home network or designing a multi-site enterprise layout, understanding IP addresses, subnets, and gateways is foundational.
This guide will walk through what these terms mean, how they work together, and where people often go wrong. We'll also get hands-on with practical examples and tools that help you make sense of your network.
Understanding IP Addresses
An IP address is a unique identifier assigned to every device on a network. It's how machines find each other and talk. There are two formats:
- IPv4, the familiar dotted-decimal notation like
192.168.0.1
- IPv6, a newer system that looks like
2001:0db8:85a3:0000:0000:8a2e:0370:7334
IPv4 uses 32 bits, allowing about 4.3 billion unique addresses. IPv6 uses 128 bits, which supports a truly massive number of devices. But conceptually, both serve the same purpose.
Each IPv4 address consists of four octets (8-bit numbers), separated by dots. For example:
192.168.1.10 => 11000000.10101000.00000001.00001010 (in binary)
The human-readable form is for us. Under the hood, it's all binary. This structure makes subnetting and routing possible.
Public vs. Private Addresses
Not all IPs are created equal. Private addresses—like anything starting with 192.168
, 10.
, or 172.16-31
—are reserved for internal use. They're not routable on the public internet.
Public addresses are globally unique and must be assigned by a provider. A home router typically has one public-facing IP and then hands out private addresses to your devices.
The Role of Subnets
Subnets divide networks into smaller, manageable pieces. That's useful for performance, security, and organization. A subnet is defined by an IP address and a subnet mask or CIDR notation.
Subnet Mask Example
A subnet mask like 255.255.255.0
says: the first 24 bits are the network portion, and the rest is host space. That's /24
in CIDR.
192.168.1.0/24 → 256 total addresses (254 usable)
You might split that into:
192.168.1.0/26 → 64 total addresses
192.168.1.64/26 → another 64
... and so on
This is powerful for segmenting departments, isolating systems, or enforcing policies.
Classful subnetting (Class A, B, C) is largely obsolete. It's useful as historical context, but today CIDR is the standard.
Gateways and Their Function
A gateway connects one network to another. In most cases, it's a router that forwards packets destined for outside the local subnet.
Picture this: your machine is 192.168.1.10/24
, and the default gateway is 192.168.1.1
. If you ping 192.168.1.50
, your machine knows that's local. But if you ping 8.8.8.8
, it forwards the request to the gateway.
Table: Gateway vs. Router vs. Switch
Component | Purpose | Layer | Key Function |
---|---|---|---|
Gateway | Routes traffic between different networks | Layer 3 | Forward traffic beyond subnet |
Router | Specialized gateway, often with NAT/firewall | Layer 3 | Directs traffic, applies rules |
Switch | Connects devices within same network | Layer 2 | Forwards frames based on MAC |
Example:
ip route show
# default via 192.168.1.1 dev eth0
This tells you where outbound traffic goes. If your gateway is unreachable, your external traffic dies there.
IP Addressing Strategies
Networks rarely assign every address manually. That's where DHCP (Dynamic Host Configuration Protocol) comes in. Most clients ask for an address automatically when they boot.
But some systems need static IPs—printers, servers, management interfaces. You want to know they're always in the same spot.
A good strategy is to reserve a chunk of space. For example:
- DHCP range:
192.168.1.100
to192.168.1.200
- Static devices:
192.168.1.2
to192.168.1.99
DHCP can also issue static addresses using MAC reservations. For example, a Ubiquiti EdgeRouter can assign 192.168.1.10
to a given MAC every time, avoiding overlap while keeping management centralized.
Subnet planning also matters. Breaking a /24
into four /26
s might seem smart—until one segment outgrows its space.
Mistakes here don't always show up immediately. Intermittent service drops or conflicts often trace back to poor planning.
Troubleshooting IP Address Issues
Most IP issues show up as weird behavior—devices not talking, services failing silently.
Basics First
ip a
# or ipconfig (Windows)
Look for:
- No IP
- Wrong subnet
- 169.254.x.x fallback
Then:
ip route show
Confirm the gateway:
default via 192.168.1.1 dev eth0
Gateway Troubles
ping 192.168.1.1
arp -a
If multiple MACs answer for the same IP, you've got a conflict.
arping -I eth0 192.168.1.50
This can sniff out IP collisions from another machine.
DHCP Trouble
journalctl -u NetworkManager
# or check /var/log/syslog for dhcpd
Look for lease requests, failures, or MAC mismatches.
Validate Subnets
ipcalc 192.168.10.50/16
Make sure the host believes it's in the right subnet.
Troubleshooting Checklist
Problem | Symptom | Tool |
---|---|---|
No IP | APIPA (169.254.x.x) | ip a , DHCP logs |
Wrong route | No external access | ip route |
IP conflict | Intermittent failure | arp , arping |
DHCP collision | Same IP to multiple devices | DHCP config |
Subnet mismatch | Can't reach known hosts | ipcalc |
Missing gateway | Internet unreachable | ping , route |