Skip to content

IP Addressing & DNS

A network is a group of computers and computing devices connected together through communication channels (cables, Wi-Fi, fiber). Networks allow devices to communicate, share resources, and exchange information. Most organizations have both an internal network and an Internet connection - the Internet itself is the largest network in the world, often called “the network of networks”.

Every device attached to a network must have at least one unique IP (Internet Protocol) address - this is what enables routing packets to the right destination. IP addresses are assigned through RIRs (Regional Internet Registries) and come in two versions:

IPv4IPv6
Size32 bits128 bits
Example192.168.1.102001:db8::1
Total addresses~4.3 billion~3.4×10³⁸
NAT needed?Yes (address exhaustion)No
StatusStill dominantGrowing adoption

Why didn’t we run out of IPv4? - NAT (Network Address Translation) extended IPv4’s life by letting many private addresses share one public IP. Your home router does this: your devices get private 192.168.x.x addresses that are invisible outside your network. The router holds the single public IP from your ISP.

  • Unicast - delivered to a specific host (e.g., 140.211.169.4)
  • Network - host portion set to all zeros; identifies the network itself (e.g., 192.168.1.0)
  • Broadcast - host portion set to all ones; all members of the network listen (e.g., 192.168.1.255)
  • Multicast - appropriately configured nodes subscribe to a group address (e.g., 224.0.0.2)

IPv4 octet structure

A 32-bit IPv4 address is divided into four 8-bit sections called octets (each ranging 0–255). The address has two parts: a Network ID (Net ID) and a Host ID.

Network ID vs Host ID

Historically, addresses were divided into classes based on the first few bits of the first octet:

Network ClassFirst Octet RangeNetmaskNotes
A1–127255.0.0.0126 networks, ~16.7 million hosts each
B128–191255.255.0.016,384 networks, 65,534 hosts each
C192–223255.255.255.0~2.1 million networks, 254 hosts each
D224–239-Multicast
E240–254-Reserved

Class A (eno1 example: 1.0.0.0–127.255.255.255):

Class A

  • First octet = Net ID; remaining three = Host ID
  • First bit always 0 → 7 bits for network = 126 usable Class A networks

Class B (128.0.0.0–191.255.255.255):

Class B

  • First two octets = Net ID; last two = Host ID
  • First two bits always 10 → 14 bits for network = 16,384 networks

Class C (192.0.0.0–223.255.255.255):

Class C

  • First three octets = Net ID; last octet = Host ID
  • Most common for small networks (254 hosts max)

The netmask defines which bits belong to the network and which to the host. You can AND an IP with the netmask to extract the network address:

172.16.2.17 IP address
& 255.255.0.0 netmask (Class B)
─────────────
172.16.0.0 network address
ClassDecimalBinary
A255.0.0.011111111 00000000 00000000 00000000
B255.255.0.011111111 11111111 00000000 00000000
C255.255.255.011111111 11111111 11111111 00000000

Modern networking uses CIDR (Classless Inter-Domain Routing) - the /prefix notation - which is more flexible than classful addressing:

192.168.1.10/24
└── Network: 192.168.1.0 (first 24 bits)
└── Host: .10 (last 8 bits → 254 usable hosts)
CIDRSubnet MaskUsable Hosts
/8255.0.0.0~16.7 million
/16255.255.0.0~65,534
/24255.255.255.0254
/28255.255.255.24014
/30255.255.255.2522 (point-to-point links)

RangePurpose
10.0.0.0/8Private (Class A space)
172.16.0.0/12Private (Class B space)
192.168.0.0/16Private (Class C space) - most common for home/office
127.0.0.0/8Loopback - 127.0.0.1 is always “this machine”
0.0.0.0Unspecified - used by DHCP before an address is assigned
255.255.255.255Limited broadcast
169.254.0.0/16Link-local (APIPA) - assigned when DHCP fails

  • Link-local (fe80::/10) - auto-configured on every interface; not routable outside the local link
  • Global unicast (2000::/3) - publicly routable; the IPv6 equivalent of a public IPv4 address
  • Multicast (ff00::/8) - one-to-many; replaces IPv4 broadcast
  • Anycast - assigned to multiple interfaces; packet routed to the nearest one
  • IPv4-Mapped - ::FFFF:a.b.c.d/96 - represents an IPv4 address in IPv6 space
  • Loopback - ::1 (equivalent of 127.0.0.1)
  • IP ranges are requested from ISPs or RIRs based on network size
  • Static assignment: fixed, manually configured; required for servers
  • Dynamic (DHCP): automatically assigned at boot; can change on reconnect

ip is the modern replacement for the deprecated ifconfig, route, and arp.

Terminal window
# Interfaces
ip addr # show all interfaces and IPs
ip addr show eth0 # show specific interface
ip addr add 192.168.1.10/24 dev eth0 # add IP (temporary)
ip addr del 192.168.1.10/24 dev eth0 # remove IP
ip link show # show interface state
ip link set eth0 up # bring interface up
ip link set eth0 down # bring interface down
# Routing
ip route # show routing table
ip route show default # show default gateway
ip route add default via 192.168.1.1 dev eth0 # set default route (temporary)
ip route add 10.0.0.0/8 via 192.168.1.254 # add static route (temporary)
ip route del 10.0.0.0/8 # delete route
# ARP / Neighbours
ip neigh # show ARP table
ip neigh flush dev eth0 # clear ARP entries for interface

Name resolution converts numerical IPs to human-readable hostnames (e.g., 104.95.85.15whitehouse.gov). Resolution happens in order, controlled by /etc/nsswitch.conf:

  1. /etc/hosts - local static entries (checked first)
  2. DNS servers in /etc/resolv.conf
127.0.0.1 localhost
192.168.1.10 db-server db01 # multiple aliases for same IP

DNS diagram

If /etc/hosts can’t resolve a name, the system queries a DNS (Domain Name Server). DNS is a distributed system - any single DNS server only knows its zone of authority, but they cooperate to resolve any name globally.

The machine’s DNS is configured in /etc/resolv.conf:

Terminal window
search example.com aps.org # appended to unqualified names
nameserver 192.168.1.1
nameserver 8.8.8.8
Terminal window
dig example.com # full DNS lookup (most information)
dig example.com A # explicit record type: A, AAAA, MX, TXT, CNAME, NS
dig -x 1.1.1.1 # reverse lookup (IP → hostname)
dig +short example.com # just the answer - great for scripting
dig +trace example.com # trace full resolution chain from root servers
dig @8.8.8.8 example.com # query a specific DNS server
host example.com # simpler output
nslookup example.com # older; avoid with DNSSEC (can return wrong answers)

Example dig output annotated:

dig linuxfoundation.org
;; QUESTION SECTION:
;linuxfoundation.org. IN A ← querying A (IPv4) record
;; ANSWER SECTION:
linuxfoundation.org. 524 IN A 3.13.31.214 ← TTL is 524 seconds
;; SERVER: 10.139.1.1#53 ← which resolver was used
;; Query time: 3 msec

Reverse lookup (IP → hostname) using +short:

Terminal window
dig -x 1.1.1.1 +short
one.one.one.one.

Terminal window
hostname # print current hostname
hostnamectl # full info: static, transient, pretty + OS details
sudo hostnamectl set-hostname myserver # set persistently (stored in /etc/hostname)
sudo hostnamectl set-hostname "My Server" --pretty

Work outward from the local host:

StepCommandWhat it tells you
1. Interface up?ip addr showIP assigned, state UP/DOWN
2. Network driver loaded?lsmod | grep <driver>Kernel module present
3. Reach gateway?ping -c 3 $(ip route | awk '/default/{print $3}')Local LAN reachable
4. Reach public IP?ping -c 3 8.8.8.8Routing works (bypasses DNS)
5. DNS working?dig +short google.comResolver reachable
6. Trace the pathmtr 8.8.8.8Per-hop loss and latency