Chapter Objective
Describe basic IPv4 networking concepts, view current network configuration, and configure network connections using NetworkManager's command-line and text-UI tools.
Key Commands
ip addrnmclinmtuihostnamectlping
Describe basic IPv4 networking concepts, view current network configuration, and configure network connections using NetworkManager's command-line and text-UI tools.
ip addrnmclinmtuihostnamectlpingEvery device on an IPv4 network needs an IP address — a 32-bit number, written as four decimal numbers separated by dots (e.g. 192.168.1.50) — along with a subnet mask defining which portion of the address identifies the network versus the specific host.
| Term | Meaning |
|---|---|
| IP address | A unique numeric identifier for a device on a network |
| Subnet mask | Defines which bits of an address represent the network vs. the host |
| CIDR notation | Shorthand for a subnet mask, e.g. /24 for 255.255.255.0 |
| Default gateway | The router traffic is sent to when the destination isn't on the local network |
| DNS server | Translates hostnames like example.com into IP addresses |
NetworkManager is the service that manages network connections on RHEL — detecting interfaces, applying configuration, and keeping connections up. It's controlled through several front ends that all manipulate the same underlying configuration.
| Tool | Interface |
|---|---|
nmcli | Command-line, scriptable |
nmtui | Text-based menu UI, good for interactive use over SSH |
| GNOME Settings | Graphical, for desktop systems |
nmtui is immediately visible to nmcli and vice versa — they're just different ways of talking to the same NetworkManager service.
# Show all network interfaces and their IP addresses ip addr show # Shortened form of the same command ip a # Show just one interface ip addr show eth0 # Show the routing table, including the default gateway ip route show # List NetworkManager connection profiles nmcli connection show # Show general device status (connected/disconnected, connection name) nmcli device status
eth0) is the physical or virtual network interface. A connection is the saved configuration profile NetworkManager applies to a device. One device can have multiple connection profiles, even though only one is typically active at a time.
# Configure a static IPv4 address, prefix, and gateway on a connection nmcli connection modify eth0 ipv4.addresses 192.168.1.50/24 nmcli connection modify eth0 ipv4.gateway 192.168.1.1 nmcli connection modify eth0 ipv4.dns 192.168.1.1 nmcli connection modify eth0 ipv4.method manual # Switch back to DHCP instead of a static address nmcli connection modify eth0 ipv4.method auto # Apply the changes by bringing the connection down and back up nmcli connection down eth0 nmcli connection up eth0
nmcli connection modify only updates the saved profile — it does not immediately reconfigure the live connection. You need to bring the connection down and back up (or reboot) before the change actually takes effect.
# Launch the text-based network configuration menu
nmtui
nmtui presents a menu-driven interface for editing connections, activating/deactivating them, and changing the hostname — useful when you'd rather navigate with arrow keys than remember exact nmcli syntax, especially during an interactive SSH session.
nmtui is friendlier for one-off interactive changes; nmcli is what you'll use in scripts and automation. Being comfortable with both covers you in either situation.
# Show the current hostname and related system details hostnamectl # Set a new static hostname sudo hostnamectl set-hostname server1.example.com # Resolve a hostname to an IP address getent hosts example.com # View statically defined host entries cat /etc/hosts
/etc/hosts is checked before DNS by default, which makes it a quick way to override name resolution for testing — for example, pointing a hostname at a specific IP without touching DNS configuration.
# Test basic reachability to a host ping server1.example.com # Send only 4 packets, then stop ping -c 4 server1.example.com # Test whether a specific TCP port is reachable curl -v telnet://server1.example.com:22
nmcli commands needed to switch a connection named eth0 from DHCP back to automatic (DHCP) addressing.nmcli connection modify, why might your change not seem to take effect immediately?