r/LinuxTeck • • 21h ago

Linux Networking for Beginners — IP, Gateway, DNS, nmcli, and the DORA Handshake from Into the Terminal Ep. 206

8 Upvotes

Every machine on a network needs three things: an address so others can find it, a way out to the rest of the world, and a phonebook to turn names into numbers. This week's Into the Terminal (episode 206) is the absolute-beginner networking episode — Scott and Nate define IP, netmask, gateway, and DNS by pointing at them on a live RHEL box (not a slide deck), flip an interface from DHCP to a static IP with nmcli, bounce it so the change actually sticks, then whiteboard the whole DHCP "DORA" handshake so the magic stops being magic.

Full video here → https://www.youtube.com/watch?v=yFjDfhb7kwI More hands-on RHEL practice → https://redhat.com/interactive-labs


The Essentials: The Four Things Every Interface Needs

Before tools, they drew the mental model on the whiteboard:

SettingWhat it actually does
IP addressYour host's identity on the network (the house number)
Netmask / CIDRHow big "your" network is — /24 is the classic 255.255.255.0
GatewayThe router on your segment that forwards traffic to everywhere else (often .1 or .254)
DNSTurns names humans remember into numbers machines speak

On the same /24 LAN, two hosts talk directly. Off-segment? Traffic goes to the gateway. DNS does not have to live on your LAN — it just has to be reachable. Search domains exist so rhel3 quietly becomes rhel3.example.com.

Scott's phishing war story: corporate DNS deliberately mis-resolved a known-bad phishing domain so users got a support ticket instead of a stolen password. Same idea as Pi-hole / AdGuard — intentional "wrong" answers as a control.

ip a              # or: ip addr show / ip address show
ip route          # see your default gateway / routes

ip a shows interface name, IPv4 + CIDR, broadcast, IPv6, and state (UP = active). Nobody types the long form. Same energy as nmcli con vs nmcli connection.


Viewing Config with nmcli (Not Just ip a)

ip a tells you what is live. NetworkManager knows why — connections, UUIDs, DHCP options, method, DNS, the whole pile.

CommandWhat it does
nmcli con showList connections, UUID, type, device
nmcli con show "Wired connection 1"Dump everything for that connection (opens a pager)
nmcli -f ipv4 con show "Wired connection 1"Filter to just IPv4 settings
nmcli -f DHCP4 con show "Wired connection 1"Just the DHCP4 block
nmcli device showDevice-centric view of all NICs
nmcli -f IP4.ADDRESS device show enp7s0One field: IPv4 addresses (it's an array — multiple IPs per NIC is fine)

Pro tips from the show:

  • Connection names can have spaces — quote them. They're case-sensitive. Tab completion for names is hit-or-miss depending on bash-completion setup (Scott had it; Nate's RHEL 10 lab box didn't for connection names).
  • -f / --fields beats scrolling a pager when you know what you want. Dot-separated keys nest (ipv4.method, DHCP4.OPTION, …).
  • One interface can hold multiple IPs (VIPs, containers, etc.) — that's why address fields look like arrays.
  • Don't edit network config over the only link you're SSHed in on without a plan. Nate's early-career friend learned that the hard way: five minutes later, "I have to walk to the data center now."

RHEL used to live on classic ifcfg key/value files; NetworkManager + nmcli is the way forward. Ubuntu still leans on text/INI-style configs. Scott will gladly start the holy war: simple files feel simpler until you realize NetworkManager exposes (and scripts) a lot more knobs than those old files ever did. nmcli is also scriptable — better than heredoc'ing a config file and hoping the syntax is right.

Cockpit's network plugin does the same jobs with a GUI warning if you're about to tear down the interface you're connected on.


Advanced: Flip DHCP → Static (Then Bounce It)

Out of the box, new interfaces are usually ipv4.method=auto (DHCP). For a home lab, a fixed server address, or anything that shouldn't wander, set it manual.

Demo from the episode — one shot, all the knobs:

nmcli con mod "Wired connection 1" \
  ipv4.method manual \
  ipv4.address 192.168.122.42/24 \
  ipv4.dns "192.168.122.1,8.8.8.8" \
  ipv4.gateway 192.168.122.1
KeyMeaning
ipv4.method manualYou own addressing (vs auto = DHCP)
ipv4.address …/24Address + netmask in CIDR (preferred over a separate netmask field)
ipv4.dns "a,b"DNS list — use at least two; one dead server means painful timeouts before failover
ipv4.gatewayDefault router on the local segment

Then:

ip a                                          # still shows the OLD address!
nmcli con down "Wired connection 1"
ip a                                          # interface present, no address
nmcli con show                                # connection goes gray / unbound from device
nmcli con up "Wired connection 1"
ip a                                          # 192.168.122.42 is live

Why the bounce? Changing settings does not apply immediately. That's a feature: a typo shouldn't instantly lock you out. Down/up (or reboot, if you're changing networks wholesale) is the last safeguard. Prefer bounce over reboot for normal IP changes. Hostname via reverse DNS is a related gotcha — new IP ≠ automatic hostname refresh.

nmcli con down / up success messages look alarmingly error-like (long path, parentheses, slashes). Read them: "connection successfully deactivated/activated."

Unplugging a cable and plugging it back in? On a desktop applet, maybe it refreshes. On a typical server, NetworkManager often keeps the config in memory through a blip — don't count on physical reconnect as a lease refresh.


Advanced: DHCP — DORA and Friends

When ipv4.method is auto, bring-up runs the classic handshake. Chat remembered the acronym DORA:

StepPacketWhat's happening
DDiscoverClient broadcasts from 0.0.0.0 to 255.255.255.255: "anyone a DHCP server?" (includes MAC)
OOfferServer replies: "I'm here, and I have an IP you could use" (not leased yet)
RRequestClient broadcasts which offer it's taking — so other clients/servers hear it too
AAckServer confirms the lease. Competing claimants get a NACK and restart at Discover

Multiple DHCP servers on a segment without coordinated leases = chaos. First offer the client acts on usually wins.

Also in the protocol (not part of DORA):

ActionWhen
Renew~halfway through the lease (and again later if needed) — stay online, keep the same IP
ReleaseGraceful shutdown / interface down / explicit release — "I don't want this address anymore"

Lease length is policy: short on guest Wi-Fi (hours), long on stable server nets (Scott's lab lease calculated out to August 2029 — chat did the math). If the pool is exhausted, the server walks the range looking for free addresses again; clients that never get a lease may land on a link-local / APIPA-style address from the OS stack.

Static vs DHCP on the same LAN: either leave a reserved range for hand-set statics, or let DHCP own "static" assignments via reservations. Mixing unmanaged statics into the DHCP pool is how you get silent IP conflicts. Servers often still use DHCP — they just always get the same reserved address.

Where does the DHCP server live? Often not on your client VLAN. Switches forward those broadcasts with DHCP relay to an infrastructure segment. Scott's phone outage story: DHCP config was fine; someone had disabled DHCP forwarding on the office switches. Phones shouted Discover into the void. Informed ticket beats "the phones don't work."

Inspect what you were actually handed:

nmcli -f DHCP4 device show <device>

Leases can carry options your client ignores once the OS is already running — and options installers/phones/switches care about a lot:

OptionCommon use
66TFTP / HTTP server for network boot
67Boot file
42NTP
120SIP servers (phones)

PXE install = DHCP Discover + those boot options. Running Linux just pulls IP/netmask/gateway/DNS (and friends) and ignores the rest.


Side Quest: VLANs (Chat Asked)

VLANs are tagged, isolated L2 segments on the same physical gear. Nate showed VLAN-typed NetworkManager connections (IDs 2, 10, 20, …) bridged into friendly names — services, IoT, lab — so smart bulbs aren't sitting next to the banking laptop. Tagging can come from DHCP or be set statically. Beyond day-one sysadmin scope, but worth knowing the word when your network person says it.


Quick Reference Card

# See what's live
ip a
ip route

# Inspect NetworkManager
nmcli con show
nmcli con show "Wired connection 1"
nmcli -f ipv4,DHCP4 con show "Wired connection 1"
nmcli device show
nmcli -f IP4.ADDRESS device show enp7s0

# Static IP (then bounce)
nmcli con mod "Wired connection 1" \
  ipv4.method manual \
  ipv4.address 192.168.122.42/24 \
  ipv4.dns "192.168.122.1,8.8.8.8" \
  ipv4.gateway 192.168.122.1
nmcli con down "Wired connection 1"
nmcli con up "Wired connection 1"

# Back toward DHCP (method auto), then bounce the same way
nmcli con mod "Wired connection 1" ipv4.method auto
nmcli con down "Wired connection 1" && nmcli con up "Wired connection 1"

# What DHCP actually gave you
nmcli -f DHCP4 device show enp7s0

Remember: modify ≠ apply. Down/up (or reboot) makes it real. Don't bounce the only path you're connected on without console/out-of-band access.

Binary netmask math got punted to "one day" — Nate's take: people ask a calculator (or Claude) for "16 addresses, what mask?" Scott still wants you to know why the numbers mean what they mean so it isn't magic.


Links

  • Video: https://www.youtube.com/watch?v=yFjDfhb7kwI
  • RHEL Developer Registration: https://developers.redhat.com/register
  • Interactive Labs: https://redhat.com/interactive-labs
  • Discord: https://red.ht/rhel-discord
  • Nate Lager: https://social.undrground.org/@gangrif
  • Scott McBrien: https://www.linkedin.com/in/scott-mcbrien-349b356

Into the Terminal is a live show from the Red Hat Enterprise Linux team covering practical Linux administration skills — commands, concepts, and war stories — for people who live in a shell. Like, subscribe, and yell war stories about static IPs that locked you out in the comments.