Based on the Linux Master 1 exam syllabusReport an error
ip, ifconfig) and persistent (ifcfg-*, nmcli con). If the task says "must survive a reboot," it always means persistent configuration.ip command syntax: ip addr add address/prefix dev interface, ip route add default via gateway. default is the default route.nmcli con modify, you must reactivate it with nmcli con up for it to take effect. Saving and applying are two separate steps.ifcfg-* that are easy to leave blank are BOOTPROTO (static/dhcp) and ONBOOT=yes. If ONBOOT is no, the interface does not come up after a reboot.ip a → ping gateway → ping 8.8.8.8 → dig. The point where it breaks is the cause.ping 8.8.8.8 works but domain names do not, it is a DNS problem. If the gateway responds but the outside world does not, the default route is missing.| Layer | When it applies | Typical tools | After reboot |
|---|---|---|---|
| Temporary (runtime) | Immediately, in memory only | ip, ifconfig | Lost |
| Persistent | Saved to a file | ifcfg-*, nmcli con | Kept |
ip addr add disappears at reboot./etc/sysconfig/network-scripts/ifcfg-*) or an nmcli connection profile.One-line summary: ip/ifconfig are temporary, ifcfg-*/nmcli con are persistent. "Persist after reboot" = persistent configuration.
ifconfig/route are deprecated, and the modern standard is the ip command (iproute2 package).# Working with addresses
ip addr show # Show addresses of all interfaces (= ip a)
ip addr show eth0 # Only a specific interface
ip addr add 192.168.10.5/24 dev eth0 # Assign an address
ip addr del 192.168.10.5/24 dev eth0 # Remove an address
# Link = the interface itself
ip link show # List interfaces and their state
ip link set eth0 up # Bring the interface up
ip link set eth0 down # Bring it down
# Routing
ip route show # Routing table (= ip r)
ip route add default via 192.168.10.1 # Set the default gateway
ip route add 10.0.0.0/24 via 192.168.10.254 # Static route to a specific network
ip route del 10.0.0.0/24 # Delete a routeip command specifies the netmask together with the address as a CIDR prefix, like /24.ifconfig syntax such as 192.168.10.5 netmask 255.255.255.0.Memorize: ip addr add address/prefix dev interface, ip route add default via gateway. default means 0.0.0.0/0 (the default route).
ifconfig # Show active interfaces
ifconfig eth0 192.168.10.5 netmask 255.255.255.0 # Address + netmask
ifconfig eth0 up # Bring up
route -n # Routing table (no name resolution)
route add default gw 192.168.10.1 # Default gateway
route add -net 10.0.0.0 netmask 255.255.255.0 gw 192.168.10.254 # Static routeifconfig writes the netmask in dotted decimal, like netmask 255.255.255.0.route is written in the form add default gw or add -net ... netmask ... gw.nmcli.ip command is that configuration made with nmcli is persistent.# Check status
nmcli # Overall summary
nmcli device status # Per-device status (= nmcli d)
nmcli connection show # List connection profiles (= nmcli c)
# Create a static IP profile
nmcli connection add type ethernet con-name myeth ifname eth0 \
ipv4.method manual \
ipv4.addresses 192.168.10.5/24 \
ipv4.gateway 192.168.10.1 \
ipv4.dns 8.8.8.8
# Modify an existing profile
nmcli connection modify myeth ipv4.addresses 192.168.10.6/24
nmcli connection modify myeth +ipv4.dns 1.1.1.1 # Add a DNS server (+)
# Apply (you must reactivate for it to take effect)
nmcli connection up myeth
nmcli connection down myethipv4.method (manual = static / auto = DHCP), ipv4.addresses, ipv4.gateway, ipv4.dns.nmcli connection up (or reload) for it to take effect.⚠️ Trap: Changing a profile with
nmcli con modifydoes not apply it immediately. You must reactivate it withnmcli con up <profile>. It is the same "saving and applying are separate" pattern as firewalld's--reload.
nmcli ultimately generates, or that you write by hand, is /etc/sysconfig/network-scripts/ifcfg-<interface>.# /etc/sysconfig/network-scripts/ifcfg-eth0 (static IP example)
TYPE=Ethernet
BOOTPROTO=static # static (or none) = static, dhcp = automatic
NAME=eth0
DEVICE=eth0
ONBOOT=yes # Activate automatically at boot (the key one!)
IPADDR=192.168.10.5
NETMASK=255.255.255.0 # or PREFIX=24
GATEWAY=192.168.10.1
DNS1=8.8.8.8
DNS2=1.1.1.1| Directive | Meaning | Easy to get wrong |
|---|---|---|
BOOTPROTO | Address assignment method | static/none = static, dhcp = automatic |
ONBOOT | Activate at boot | Must be yes to survive a reboot |
IPADDR | IP address | Not needed with DHCP |
NETMASK/PREFIX | Netmask | Use only one of the two |
GATEWAY | Default gateway | |
DNS1/DNS2 | Nameservers |
BOOTPROTO=dhcp and leave IPADDR/NETMASK/GATEWAY empty.nmcli con reload → nmcli con up eth0, or systemctl restart NetworkManager.Fill-in-the-blank example: BOOTPROTO=____ (static/dhcp), ONBOOT=____ (yes). With ONBOOT=no the interface does not come up after a reboot, a classic exam trap.
/etc/resolv.conf.DNS1/DNS2 in ifcfg populate this file.# /etc/resolv.conf
nameserver 8.8.8.8
nameserver 1.1.1.1
search example.com # Automatic domain completion# 1) L3 reachability: ping
ping -c 4 192.168.10.1 # Send 4 packets then stop (-c count)
ping -c 4 8.8.8.8 # Check external reachability
ping -c 4 www.google.com # Check name resolution and reachability together
# 2) Ports and sockets: ss (replaces netstat)
ss -tuln # TCP/UDP listening ports (numeric)
ss -tnp # Established TCP + process
# t=TCP, u=UDP, l=listen, n=numeric (no name resolution), p=process
# 3) Name resolution: dig / nslookup
dig www.example.com # Detailed DNS lookup
dig www.example.com +short # Result only
dig @8.8.8.8 example.com MX # Query a specific server for MX records
nslookup www.example.com # Interactive/simple lookup
# 4) Path tracing
traceroute 8.8.8.8 # Hop-by-hop path tracess options -t (TCP) -u (UDP) -l (listen) -n (numeric) -p (process).ss -tuln is the standard command for seeing "what ports are open right now."Diagnostic ladder: ① Is there an IP? (ip a) → ② L2/L3 via ping gateway → ③ External reachability via ping 8.8.8.8 → ④ DNS via ping domain/dig. Where it breaks is the cause.
⚠️ Confusing: If
ping 8.8.8.8works butping google.comdoes not, it is a DNS (resolv.conf) problem. IP reachability is fine and only name resolution fails.
| Symptom | Suspect | Check command | Fix |
|---|---|---|---|
| No IP | Config/ONBOOT | ip a | ifcfg ONBOOT=yes, nmcli con up |
| Gateway ping fails | Same-network problem | ip r | ip route add default via |
| External IP ping fails | Routing/firewall | ip r, traceroute | Check default route and firewall |
| IP works but domain fails | DNS | dig, cat /etc/resolv.conf | Fix nameserver |
| Cannot connect to a port | Service/firewall | ss -tuln | Start the service, open the port |
Example problem: "ping gateway succeeds + ping 8.8.8.8 fails" → default route is missing. ip route add default via <gw>.
hostnamectl # Show current hostname and OS info
hostnamectl set-hostname web01.example.com # Change the persistent hostname
hostname # Print only the current hostnamehosts: line in /etc/nsswitch.conf.# /etc/nsswitch.conf
hosts: files dns # files (/etc/hosts) first, then dnsfiles comes first, mappings written in /etc/hosts take priority over DNS./etc/hosts.# /etc/hosts
127.0.0.1 localhost
192.168.10.50 web01.example.com web01Resolution priority: By default /etc/hosts (files) > DNS (/etc/resolv.conf). If /etc/hosts has a wrong mapping, you end up at the wrong IP even when DNS is healthy, so check it too when diagnosing.
Renewing a DHCP client: To get the lease again, run dhclient -r (release) and then dhclient (request again), or nmcli con down/up. In a NetworkManager environment, nmcli is more consistent.
# Get the current addresses, routes, and sockets at a glance
ip a
ip r
ss -tuln
# Add a temporary address, check it, then delete it
ip addr add 10.10.10.10/24 dev eth0
ip addr show eth0
ip addr del 10.10.10.10/24 dev eth0
# Diagnose reachability and name resolution
ping -c 3 127.0.0.1 # Loopback (your own TCP/IP stack)
dig +short openai.comTyping it yourself until your hands remember is the only secret to passing.
ip) / configuration saved in a file that persists (ifcfg-*, nmcli con).ifconfig and route. Its main command is ip./24. The ip command uses this form.ip route add default via <IP>.manual is static, auto is DHCP.ifcfg-* that sets the address assignment method. static (or none) and dhcp.yes, the interface does not come up after a reboot.-t TCP -u UDP -l listening -n numeric -p process.+short shows only the result./etc/hosts (files) first or DNS first.set-hostname is applied persistently.Click a choice to reveal the answer and explanation.
Question 1
Which ip command temporarily assigns the address 192.168.1.100/24 to the eth0 interface?
Question 2
Which command sets the default gateway to 192.168.1.1?
Question 3
In the ifcfg-eth0 file, which directive must be set to yes so that the interface is activated automatically even after a reboot?
Question 4
When configuring an ifcfg file to obtain an address automatically via DHCP, what value do you assign to BOOTPROTO?
Question 5
ping 8.8.8.8 gets a normal reply, but ping www.example.com fails. What is the most likely cause?
Question 6
Which ss command shows the TCP and UDP ports currently listening, in numeric form, all at once?
Question 7
After changing an IP with nmcli connection modify, which additional command must you run to apply the change to the current session?