Linux Networking Made Simple — IP, CIDR, Subnetting, nmcli/nmtui, Routes, DNS & Troubleshooting
Posted: Sat Jun 13, 2026 11:26 am
Linux Networking Made Simple — IP, CIDR, Subnetting, nmcli/nmtui, Routes, DNS & Troubleshooting
A beginner-friendly guide explained in plain language, with real commands you can copy (AlmaLinux 9 / RHEL 9 — NetworkManager)
─────────────────────────────────────────
1 IP Addressing — the basics
Think of an IP address like a home address for a computer. Just as the postman needs your house number and street to deliver mail, the network needs an IP address to deliver data to the right machine.
An IPv4 address looks like this: 192.168.1.10 — four numbers (0–255) separated by dots.
Two parts hidden inside every IP
Tip: Your home router almost always uses something like 192.168.0.1 or 192.168.1.1 — that's a private address.
─────────────────────────────────────────
2 CIDR — what the "/24" means
You'll often see an address written like 192.168.1.10/24. That /24 is called CIDR notation, and it simply tells you how much of the address is the "street name" (network) and how much is the "house number" (host).
Plain-language version: the number after the slash = how many bits belong to the network. The rest are free for devices.
The three you'll see most often
─────────────────────────────────────────
3 Subnetting — splitting one network into smaller ones
Imagine a big office building with one giant open floor. Subnetting is like putting up walls to make separate rooms — each department gets its own space, traffic stays organised, and you control who talks to whom.
Simple example
You have the network 192.168.1.0/24 (254 devices in one room). Split it into two smaller rooms:
Three reserved addresses in any subnet
─────────────────────────────────────────
4 nmcli — configuring the network from the command line
On AlmaLinux 9, the network is managed by NetworkManager, and nmcli is its command-line tool. A "connection" is a saved profile of settings for a network card.
See what you have
Set a STATIC IP address
Switch back to automatic (DHCP)
Tip: "manual" = static IP you set yourself. "auto" = DHCP, where the router hands out an address automatically. Always run "nmcli con up" to make changes take effect.
─────────────────────────────────────────
5 nmtui — the easy menu-based way
If commands feel intimidating, nmtui gives you a simple text menu you navigate with arrow keys — no syntax to memorise.
Then choose "Edit a connection", pick your interface, fill in the IP/gateway/DNS fields, save, and select "Activate a connection" to apply.
Tip: nmtui and nmcli do the exact same thing under the hood. Use nmtui to learn, nmcli to go fast.
─────────────────────────────────────────
6 Static Routes — telling traffic which door to use
A route is a signpost: "to reach network X, send the traffic through gateway Y." Your machine already has a default route (everything unknown goes to the main gateway). A static route adds a custom signpost for a specific network.
Add a permanent static route
View the current routing table
Tip: The line starting with "default" in 'ip route' is your gateway to the internet. Everything not matched by a specific route goes there.
─────────────────────────────────────────
7 DNS Configuration — turning names into numbers
Computers talk in numbers (IPs), but humans use names (google.com). DNS is the phonebook that translates names into IP addresses.
Set DNS servers (the right way on NetworkManager)
Check what's being used
Test that DNS works
WARNING: Don't edit /etc/resolv.conf by hand on AlmaLinux 9 — NetworkManager rewrites it. Always set DNS through nmcli (ipv4.dns) so it sticks.
─────────────────────────────────────────
8 Hostname Management — naming your machine
The hostname is your computer's name on the network (like "web01" or "fileserver"). It makes machines easy to identify.
View and set the hostname
Tip: hostnamectl makes the change permanent across reboots. Log out and back in to see the new name in your shell prompt.
─────────────────────────────────────────
9 Troubleshooting — when the network won't work
Work through these in order, from "is it even connected?" outward to the internet.
Step 1 — Do I have an IP and is the link up?
Step 2 — Can I reach my own gateway?
Step 3 — Can I reach the internet by IP?
Step 4 — Is DNS working?
Step 5 — Where does traffic get stuck / what's listening?
Golden troubleshooting order: Interface up? -> Got an IP? -> Reach the gateway? -> Reach the internet by IP? -> DNS resolves names? Each step rules out a layer.
─────────────────────────────────────────
Quick Reference Cheat Sheet
Stuck on a networking issue? Post your 'ip addr' and 'ip route' output below and the community will help you debug it.
A beginner-friendly guide explained in plain language, with real commands you can copy (AlmaLinux 9 / RHEL 9 — NetworkManager)
─────────────────────────────────────────
─────────────────────────────────────────New to networking? Start here.
This guide explains each idea in everyday words first, then shows the exact command. No jargon dumped on you — read top to bottom and you'll be able to configure a Linux box's network with confidence.
1 IP Addressing — the basics
Think of an IP address like a home address for a computer. Just as the postman needs your house number and street to deliver mail, the network needs an IP address to deliver data to the right machine.
An IPv4 address looks like this: 192.168.1.10 — four numbers (0–255) separated by dots.
Two parts hidden inside every IP
- Network part — like the street name. All devices on the same network share it.
- Host part — like the house number. Unique to each device on that street.
- 10.0.0.0 to 10.255.255.255
- 172.16.0.0 to 172.31.255.255
- 192.168.0.0 to 192.168.255.255
Tip: Your home router almost always uses something like 192.168.0.1 or 192.168.1.1 — that's a private address.
─────────────────────────────────────────
2 CIDR — what the "/24" means
You'll often see an address written like 192.168.1.10/24. That /24 is called CIDR notation, and it simply tells you how much of the address is the "street name" (network) and how much is the "house number" (host).
Plain-language version: the number after the slash = how many bits belong to the network. The rest are free for devices.
The three you'll see most often
- /24 = netmask 255.255.255.0 — up to 254 usable devices (a typical small network)
- /16 = netmask 255.255.0.0 — up to 65,534 devices (a large network)
- /8 = netmask 255.0.0.0 — millions of devices (very large)
─────────────────────────────────────────
3 Subnetting — splitting one network into smaller ones
Imagine a big office building with one giant open floor. Subnetting is like putting up walls to make separate rooms — each department gets its own space, traffic stays organised, and you control who talks to whom.
Simple example
You have the network 192.168.1.0/24 (254 devices in one room). Split it into two smaller rooms:
- 192.168.1.0/25 — first half, addresses .1 to .126 (126 devices)
- 192.168.1.128/25 — second half, addresses .129 to .254 (126 devices)
Three reserved addresses in any subnet
- Network address — the first one (e.g. 192.168.1.0), names the subnet itself
- Broadcast address — the last one (e.g. 192.168.1.255), "everyone on this subnet"
- Gateway — usually the first usable (e.g. 192.168.1.1), the door to other networks
─────────────────────────────────────────
4 nmcli — configuring the network from the command line
On AlmaLinux 9, the network is managed by NetworkManager, and nmcli is its command-line tool. A "connection" is a saved profile of settings for a network card.
See what you have
Code: Select all
nmcli device status # list network cards and their state
nmcli connection show # list saved connection profiles
ip addr # show current IP addressesCode: Select all
# Replace 'ens160' with your interface name from 'nmcli device status'
nmcli con mod ens160 ipv4.addresses 192.168.1.50/24
nmcli con mod ens160 ipv4.gateway 192.168.1.1
nmcli con mod ens160 ipv4.dns "8.8.8.8 1.1.1.1"
nmcli con mod ens160 ipv4.method manual
# Apply the changes
nmcli con up ens160Code: Select all
nmcli con mod ens160 ipv4.method auto
nmcli con up ens160─────────────────────────────────────────
5 nmtui — the easy menu-based way
If commands feel intimidating, nmtui gives you a simple text menu you navigate with arrow keys — no syntax to memorise.
Code: Select all
nmtuiTip: nmtui and nmcli do the exact same thing under the hood. Use nmtui to learn, nmcli to go fast.
─────────────────────────────────────────
6 Static Routes — telling traffic which door to use
A route is a signpost: "to reach network X, send the traffic through gateway Y." Your machine already has a default route (everything unknown goes to the main gateway). A static route adds a custom signpost for a specific network.
Add a permanent static route
Code: Select all
# "To reach the 10.10.10.0/24 network, go via 192.168.1.254"
nmcli con mod ens160 +ipv4.routes "10.10.10.0/24 192.168.1.254"
nmcli con up ens160Code: Select all
ip route # shows all active routes
ip route get 10.10.10.5 # ask: which route would this IP take?─────────────────────────────────────────
7 DNS Configuration — turning names into numbers
Computers talk in numbers (IPs), but humans use names (google.com). DNS is the phonebook that translates names into IP addresses.
Set DNS servers (the right way on NetworkManager)
Code: Select all
nmcli con mod ens160 ipv4.dns "8.8.8.8 1.1.1.1"
nmcli con up ens160Code: Select all
cat /etc/resolv.conf # the active DNS servers
nmcli dev show ens160 | grep DNS # what NetworkManager has setCode: Select all
nslookup netaport.com
dig netaport.com # more detailed lookup─────────────────────────────────────────
8 Hostname Management — naming your machine
The hostname is your computer's name on the network (like "web01" or "fileserver"). It makes machines easy to identify.
View and set the hostname
Code: Select all
hostnamectl # show current hostname and system info
hostnamectl set-hostname web01 # set a new permanent hostname
hostname # quick check of the current name─────────────────────────────────────────
9 Troubleshooting — when the network won't work
Work through these in order, from "is it even connected?" outward to the internet.
Step 1 — Do I have an IP and is the link up?
Code: Select all
ip addr # do I have an IP address?
ip link # is the cable/interface UP?
nmcli device status # NetworkManager's viewCode: Select all
ip route # find the default gateway
ping -c 4 192.168.1.1 # ping the gateway (use your own)Code: Select all
ping -c 4 8.8.8.8 # if this works but names don't = DNS problemCode: Select all
ping -c 4 google.com # fails here but step 3 worked? -> fix DNS
nslookup google.comCode: Select all
traceroute google.com # see each hop along the path
ss -tulpn # which ports/services are listening─────────────────────────────────────────
Quick Reference Cheat Sheet
- Show IPs — ip addr
- Show routes — ip route
- Device status — nmcli device status
- Set static IP — nmcli con mod ens160 ipv4.addresses 192.168.1.50/24 ; ipv4.method manual
- Set gateway — nmcli con mod ens160 ipv4.gateway 192.168.1.1
- Set DNS — nmcli con mod ens160 ipv4.dns "8.8.8.8 1.1.1.1"
- Add route — nmcli con mod ens160 +ipv4.routes "10.10.10.0/24 192.168.1.254"
- Apply changes — nmcli con up ens160
- Menu tool — nmtui
- Set hostname — hostnamectl set-hostname web01
- Test reach — ping -c 4 8.8.8.8
- Test DNS — nslookup google.com
- Trace path — traceroute google.com
- Listening ports — ss -tulpn
Stuck on a networking issue? Post your 'ip addr' and 'ip route' output below and the community will help you debug it.