LESSON 15 · BEGINNER5 min read

IP Addressing, Routing, and NAT

Read IP addresses and routes with confidence, understand private versus public space, and see how NAT changes what logs can prove.

OWASP Top 10 · MITRE ATT&CK · NIST CSF 2.0Free to readModule 4 of 14
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Convert between IPv4 addresses, subnet masks, and CIDR notation.
  • Distinguish private, public, loopback, and link-local addresses.
  • Explain the role of a default gateway, routing table, and NAT.
  • Recognise the security implications of IPv6 and shared addresses.

01An IP Address Is a Location and a Range

An IPv4 address is 32 bits, usually written as four decimal numbers separated by dots. The address identifies an interface, while the subnet mask tells you which bits identify the network and which identify the host. CIDR notation combines the two: 192.168.1.42/24 means the first 24 bits are the network and the remaining 8 bits identify hosts on that network.

Subnetting matters because it defines the local broadcast domain and the boundary of direct communication. A host can reach another host directly only if it believes the destination is on the same subnet. Otherwise it sends traffic to its default gateway. That gateway is a router, and its routing table decides where the packet goes next.

You do not need to perform complex subnetting in your head to start. You do need to recognise when two addresses are on the same network, how many usable hosts a subnet contains, and why a misconfigured mask can make a service unreachable or unexpectedly exposed. The Python ipaddress module and online calculators are legitimate tools; understanding the result is the point.

subnet_math.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.

02Private, Public, Loopback, and Link-Local Space

RFC 1918 reserves three IPv4 ranges for private networks: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. These addresses are not routed on the public internet. Homes, offices, and cloud virtual networks reuse them constantly. That is why two different organisations can both use 10.0.0.0/8 without conflict.

Loopback addresses, most commonly 127.0.0.1, refer to the local machine. Link-local addresses in 169.254.0.0/16 are self-assigned when a host cannot obtain an address from DHCP. Public addresses are globally routable, although NAT often hides many private hosts behind one public address. None of these labels tells you whether a host is trustworthy.

IPv6 uses 128-bit addresses and a very different operational model. There is no NAT requirement, addresses are commonly assigned with privacy extensions, and link-local addresses use the fe80::/10 range. IPv6 is not automatically more secure. It changes which addresses appear in logs, how firewalls must be configured, and how devices discover each other. Dual-stack networks need rules for both protocols.

03Routing Tables and Default Gateways

A routing table is a list of destinations and the next hop used to reach them. The default route, often written as 0.0.0.0/0 for IPv4, catches traffic that does not match a more specific route. On a laptop, the default route usually points to the home router. On a server, it points to the cloud subnet router or the data-centre gateway.

Attackers care about routing because it determines reachability. A host with a route to an internal management network can become a pivot point. A container with the host network namespace can see traffic it should not. A VPN split tunnel can send sensitive traffic outside the inspected path. Defenders care because routing explains why a firewall rule did or did not apply.

When investigating, record the interface, address, route, and DNS configuration. Use ip address, ip route, and ip neigh on Linux. Compare what the host believes with what the network device shows. Misconfigurations often produce contradictory evidence: the host thinks it is on one subnet, while the switch or cloud route table thinks it is on another.

inspect-network-config.shShell
ip -brief addressip routeip neighresolvectl status 2>/dev/null || cat /etc/resolv.conf# Test local gateway reachability, then a public address.ping -c 3 10.10.10.1ping -c 3 1.1.1.1# Trace the path one hop at a time.traceroute -n example.com 2>/dev/null || tracepath -n example.com
Outputstdout
lo               UNKNOWN        127.0.0.1/8
eth0             UP             10.10.10.20/24
default via 10.10.10.1 dev eth0 proto dhcp metric 100
10.10.10.1 dev eth0 lladdr 52:54:00:12:34:56 REACHABLE
3 packets transmitted, 3 received, 0% packet loss

04NAT and the Limits of Address-Based Evidence

Network Address Translation rewrites addresses as packets cross a boundary. A home router might translate 192.168.1.42 to a public address and track which internal host initiated each connection. Cloud NAT gateways do the same at scale. NAT conserves public addresses and hides internal topology, but it also means a public IP in a log may represent hundreds or thousands of users.

For defenders, NAT complicates attribution. An external server sees the NAT gateway, not the individual laptop. To identify the internal source, you need the gateway's translation logs, DHCP records, authentication logs, and accurate timestamps. Without those, 'the attack came from 203.0.113.50' may only identify an internet provider's customer or a shared office egress.

For testers and incident responders, never assume an IP address is a person. It can be a proxy, a VPN exit, a compromised device, or a shared NAT. Corroborate with session identifiers, user agents, authentication events, and endpoint telemetry. Addresses are clues, not identities.

LET IT CLICK

The ideas worth keeping.

  • CIDR notation describes the network boundary; the mask determines direct reachability.
  • Private addresses are reused everywhere, so they are not globally unique identifiers.
  • Routing tables and default gateways explain why traffic reaches or misses a destination.
  • NAT and IPv6 both change what address-based evidence can prove; corroborate with other logs.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

Exercise 1: Identify address types

Classify each address and explain whether it is routable on the public internet: 10.20.30.40, 172.20.5.9, 192.168.1.1, 8.8.8.8, 127.0.0.1, 169.254.10.7. Then state which two addresses are on the same /16 network.

Explore a worked solution
one_possible_solution.mdCybersecurity
10.20.30.40 and 172.20.5.9 are private RFC 1918 addresses (10.0.0.0/8 and 172.16.0.0/12) and are not directly routable on the public internet. 192.168.1.1 is private (192.168.0.0/16). 8.8.8.8 is a public address. 127.0.0.1 is loopback. 169.254.10.7 is link-local. 10.20.30.40 and 172.20.5.9 are not on the same /16; their first two octets differ (10.20 versus 172.20). No pair in the list shares a /16 except addresses within the same listed network if one were present.

Classification is the first step. The second is checking the network boundary: private addresses can be reused in different networks and are not evidence of a specific organisation.

02

Exercise 2: Explain a missing route

A server at 10.0.5.20/24 cannot reach 10.0.6.10/24, but it can reach the internet. Its default gateway is 10.0.5.1. Give two plausible causes and one command to investigate each.

Explore a worked solution
one_possible_solution.mdCybersecurity
Cause 1: the router at 10.0.5.1 has no route to 10.0.6.0/24, or a firewall between the subnets blocks the traffic. Investigate with 'ip route' on the server and the router's routing table, then test with 'ping' and 'traceroute' to 10.0.6.10. Cause 2: the server's netmask or route is wrong, so it sends traffic for 10.0.6.10 to the default gateway incorrectly or drops it. Investigate with 'ip route get 10.0.6.10' and compare the result with the intended topology. Also check host and network firewall rules with 'sudo iptables -S' or the platform's security policy tooling.

A reachable internet does not prove internal routing works. The default route can succeed while a more specific internal path is missing or blocked.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 4 answered
01Which address is in the private 172.16.0.0/12 range?
02What does a default route do?
03Why can an IP address in a log fail to identify a single person?
04What is the loopback address range in IPv4?

Keep exploring.

The official references behind this lesson, when you want a second angle or the full details.

One lesson closer.

Reading is a start. Trying it yourself makes the connection.

Completion is saved in this browser. It records reading and hands-on practice progress.