RHCSA Commands: Networking
Network Verification & Inspection
| Command | Description | Example |
|---|---|---|
ip addr show |
Display all network interfaces with IP addresses, MAC addresses, and subnet masks | ip addr show or ip a s or ip a |
ip link show |
Display link state of all network interfaces (UP/DOWN status, MAC addresses) | ip link show |
ip -s link show |
Display link state with traffic statistics (packets sent/received, errors) | ip -s link show |
ip link set dev <device> up |
Bring a network interface up (activate link layer) | ip link set dev ens33 up |
ip addr add <IP>/<prefix> dev <device> |
Temporarily add an IP address to an interface (non-persistent) | ip addr add 10.0.0.10/24 dev ens33 |
ip route show |
Display routing table, including default gateway and connected networks | ip route show |
ss -lt |
Display all listening TCP ports on the local system | ss -lt |
ss -tul |
Display all listening TCP and UDP ports on the local system | ss -tul |
netstat |
Display network connections, routing tables, and port usage (legacy, replaced by ss) |
netstat |
Hostname Management
| Command | Description | Example |
|---|---|---|
hostname |
Display the current system hostname | hostname |
hostnamectl |
Display detailed hostname and system information | hostnamectl |
hostnamectl status |
Show current hostname, kernel, virtualization, and OS details | hostnamectl status |
hostnamectl set-hostname <FQDN> |
Set the system hostname persistently (updates /etc/hostname and restarts systemd-hostnamed) | hostnamectl set-hostname server10.example.com |
nmcli general hostname |
Display the current hostname via NetworkManager | nmcli general hostname |
nmcli general hostname <FQDN> |
Set the system hostname via NetworkManager | nmcli general hostname server20.example.com |
uname |
Display system information including hostname | uname |
systemctl restart systemd-hostnamed |
Restart the hostname daemon to apply hostname changes made via /etc/hostname | systemctl restart systemd-hostnamed |
NetworkManager Service Management
| Command | Description | Example |
|---|---|---|
systemctl status NetworkManager |
Check the current status of the NetworkManager service | systemctl status NetworkManager |
systemctl enable --now NetworkManager |
Enable and start the NetworkManager service immediately | systemctl enable --now NetworkManager |
nmcli general permissions |
Check current user permissions to modify network configuration | nmcli general permissions |
nmcli - Connection Management
| Command | Description | Example |
|---|---|---|
nmcli con show |
List all network connections (active and inactive) with NAME, UUID, DEVICE, and TYPE | nmcli con show or nmcli c s or nmcli cs |
nmcli con show <connection-name> |
Display all properties of a specific connection | nmcli con show ens33 |
nmcli con add con-name <name> type ethernet ifname <dev> ipv4.method auto |
Create a new DHCP connection profile | nmcli con add con-name dhcp type ethernet ifname ens33 ipv4.method auto |
nmcli con add con-name <name> ifname <dev> type ethernet ip4 <IP>/<prefix> gw4 <gateway> ipv4.method manual |
Create a new static IP connection profile | nmcli con add con-name static ifname ens33 type ethernet ip4 10.0.0.10/24 gw4 10.0.0.1 ipv4.method manual |
nmcli con add con-name <name> ifname <dev> ipv4 <IP>/<prefix> gw4 <gateway> ipv4.method manual |
Create a static connection (alternative syntax) | nmcli con add con-name static ifname ens33 ipv4 10.0.0.10/24 gw4 10.0.0.1 ipv4.method manual |
nmcli con up <connection-name> |
Activate a connection profile (attach to device and apply settings) | nmcli con up static |
nmcli con down <connection-name> |
Deactivate a connection profile (detach from device) | nmcli con down static |
nmcli con mod <connection-name> <property> <value> |
Modify a property of an existing connection | nmcli con mod static ipv4.dns 10.0.0.10 |
nmcli con mod <connection-name> +<property> <value> |
Append an additional value to a multi-value property | nmcli con mod static +ipv4.dns 8.8.8.8 |
nmcli con mod <connection-name> ipv4.addresses <IP>/<prefix> |
Change the IP address of an existing connection | nmcli con mod static ipv4.addresses 10.0.0.100/24 |
nmcli con mod <connection-name> +ipv4.addresses <IP>/<prefix> |
Add a second IP address to an existing connection | nmcli con mod static +ipv4.addresses 10.20.30.40/16 |
nmcli con mod <connection-name> connection.autoconnect no |
Disable auto-connect on boot for a connection | nmcli con mod static connection.autoconnect no |
nmcli con mod <connection-name> ipv4.ignore-auto-dns yes |
Prevent DHCP from overwriting DNS settings | nmcli con mod <con-name> ipv4.ignore-auto-dns yes |
nmcli con delete <connection-name> |
Delete a connection profile | nmcli con delete static |
nmcli con edit <connection-name> |
Open an interactive editor for a connection profile | nmcli con edit ens33 |
nmcli con reload |
Instruct NetworkManager to re-read all connection profiles from disk | nmcli con reload |
nmcli con load <file> |
Instruct NetworkManager to load a specific connection profile file | nmcli con load /etc/NetworkManager/system-connections/myconn.nmconnection |
nmcli - Device Management
| Command | Description | Example |
|---|---|---|
nmcli dev status |
Show all network devices, their types, states, and attached connections | nmcli dev status or nmcli d s |
nmcli dev show <device> |
Display detailed settings for a specific network device | nmcli dev show ens33 |
nmtui - Text User Interface
| Command | Description | Example |
|---|---|---|
nmtui |
Launch the text-based UI for editing connections, activating connections, and setting the system hostname | nmtui |
nm-connection-editor |
Launch the graphical GUI for editing network connections (GNOME desktop) | nm-connection-editor |
Legacy Connection Management
| Command | Description | Example |
|---|---|---|
ifup <connection-name> |
Activate a network connection (legacy tool) | ifup enp0s8 |
ifdown <connection-name> |
Deactivate a network connection (legacy tool) | ifdown enp0s8 |
Hostname Resolution & DNS
| Command | Description | Example |
|---|---|---|
getent hosts <hostname> |
Resolve a hostname to an IP address (checks /etc/hosts first, then DNS) | getent hosts server1 |
ping -c <count> <target> |
Send ICMP echo requests to test network connectivity | ping -c 4 192.168.1.10 |
ping -c <count> <hostname> |
Test connectivity using a hostname (verifies name resolution + connectivity) | ping -c 2 server20 |
ping6 |
Send ICMPv6 echo requests to test IPv6 connectivity | ping6 <ipv6-address> |
traceroute |
Trace the route packets take to a destination (uses ICMP) | traceroute <target> |
tracepath |
Trace the network path to a destination without requiring root | tracepath <target> |
tracepath6 |
Trace the IPv6 network path to a destination | tracepath6 <target> |
Firewall Service Management
| Command | Description | Example |
|---|---|---|
systemctl status firewalld |
Check the running status of the firewalld service | systemctl status firewalld |
systemctl enable --now firewalld |
Enable and start the firewalld service immediately | systemctl enable --now firewalld |
systemctl restart firewalld |
Restart the firewalld service (discards runtime-only changes) | systemctl restart firewalld |
firewall-cmd --state |
Display the running status of firewalld (returns “running” or “not running”) | firewall-cmd --state |
Firewall - Zone Management
| Command | Description | Example |
|---|---|---|
firewall-cmd --get-zones |
List all available firewalld zones | firewall-cmd --get-zones |
firewall-cmd --get-default-zone |
Show the name of the current default/active zone | firewall-cmd --get-default-zone |
firewall-cmd --set-default-zone=<zone> |
Change the default zone for both runtime and permanent configuration | firewall-cmd --set-default-zone=internal |
firewall-cmd --get-active-zones |
Display all active zones and their assigned interfaces | firewall-cmd --get-active-zones |
firewall-cmd --list-all |
List all settings (services, ports, interfaces, sources) for the default zone | firewall-cmd --list-all |
firewall-cmd --list-all --zone=<zone> |
List all settings for a specific zone | firewall-cmd --list-all --zone=public |
firewall-cmd --list-all-zones |
List the settings for all available zones | firewall-cmd --list-all-zones |
firewall-cmd --zone=<zone> |
Specify which zone to work on (without this, the default zone is used) | firewall-cmd --zone=public --list-services |
firewall-cmd --add-interface=<interface> |
Bind a network interface to the default zone (or specified zone) | firewall-cmd --add-interface=eno1 --zone=public |
firewall-cmd --remove-interface=<interface> |
Remove a network interface from a specific zone | firewall-cmd --remove-interface=eno1 --zone=public |
firewall-cmd --change-interface=<interface> |
Change the zone binding of a network interface to a different zone | firewall-cmd --change-interface=ens33 --zone=internal |
firewall-cmd --list-interfaces |
List network interfaces assigned to the current zone | firewall-cmd --list-interfaces |
Firewall - Service Management
| Command | Description | Example |
|---|---|---|
firewall-cmd --get-services |
Print all predefined firewalld services available on the system | firewall-cmd --get-services |
firewall-cmd --list-services |
List services currently enabled in the default zone | firewall-cmd --list-services |
firewall-cmd --add-service=<service> |
Add a service to the default zone (runtime only) | firewall-cmd --add-service=http |
firewall-cmd --add-service=<service> --permanent |
Add a service to the default zone persistently | firewall-cmd --add-service=http --permanent |
firewall-cmd --add-service=<service> --permanent --zone=<zone> |
Add a service to a specific zone persistently | firewall-cmd --add-service=nfs --permanent --zone=external |
firewall-cmd --remove-service=<service> |
Remove a service from the default zone (runtime only) | firewall-cmd --remove-service=ssh |
firewall-cmd --remove-service=<service> --permanent --zone=<zone> |
Remove a service from a specific zone persistently | firewall-cmd --remove-service=http --permanent --zone=public |
firewall-cmd --query-service=<service> |
Query whether a service is enabled in the current zone | firewall-cmd --query-service=ssh |
Firewall - Port Management
| Command | Description | Example |
|---|---|---|
firewall-cmd --list-ports |
List network ports currently open in the default zone | firewall-cmd --list-ports |
firewall-cmd --add-port=<port>/<protocol> |
Add a port to the default zone (runtime only) | firewall-cmd --add-port=443/tcp |
firewall-cmd --add-port=<port>/<protocol> --permanent |
Add a port to the default zone persistently | firewall-cmd --add-port=2020/tcp --permanent |
firewall-cmd --add-port=<port>/<protocol> --permanent --zone=<zone> |
Add a port to a specific zone persistently | firewall-cmd --add-port=8080/tcp --permanent --zone=internal |
firewall-cmd --add-port=<port-range>/<protocol> --permanent --zone=<zone> |
Add a range of ports to a specific zone persistently | firewall-cmd --add-port=5901-5910/tcp --permanent --zone=internal |
firewall-cmd --remove-port=<port>/<protocol> |
Remove a port from the default zone (runtime only) | firewall-cmd --remove-port=5000/tcp |
firewall-cmd --remove-port=<port>/<protocol> --permanent --zone=<zone> |
Remove a port from a specific zone persistently | firewall-cmd --remove-port=5901-5910/tcp --permanent --zone=internal |
firewall-cmd --query-port=<port>/<protocol> |
Query whether a port is open in the current zone | firewall-cmd --query-port=8080/tcp |
Firewall - IP Source Management
| Command | Description | Example |
|---|---|---|
firewall-cmd --list-sources |
List IP sources (CIDR ranges) assigned to the current zone | firewall-cmd --list-sources |
firewall-cmd --add-source=<IP/CIDR> |
Add an IP source to the default zone | firewall-cmd --add-source=192.168.0.0/24 |
firewall-cmd --add-source=<IP/CIDR> --zone=<zone> |
Add an IP source to a specific zone | firewall-cmd --add-source=192.168.0.0/24 --zone=public |
firewall-cmd --remove-source=<IP/CIDR> |
Remove an IP source from the configuration | firewall-cmd --remove-source=192.168.0.0/24 |
firewall-cmd --change-source=<IP/CIDR> |
Change an IP source assignment | firewall-cmd --change-source=10.0.0.0/24 |
Firewall - Configuration Persistence & Reload
| Command | Description | Example |
|---|---|---|
firewall-cmd --permanent |
Flag to store a change persistently to disk (change becomes active only after reload or restart) | firewall-cmd --permanent --add-service=http |
firewall-cmd --reload |
Reload firewall rules from permanent disk configuration into runtime (all runtime-only changes are lost) | firewall-cmd --reload |
firewall-cmd --runtime-to-permanent |
Save all current runtime rules to the permanent disk configuration | firewall-cmd --runtime-to-permanent |
Firewall - GUI Tool
| Command | Description | Example |
|---|---|---|
firewall-config |
Launch the GUI tool for managing firewalld configurations graphically | firewall-config |
SSH (Remote Access Testing)
| Command | Description | Example |
|---|---|---|
ssh <user>@<host> |
Connect to a remote system via SSH (used to test firewall rules) | ssh user1@server10 |
Manual Pages & Reference
| Command | Description | Example |
|---|---|---|
man nmcli-examples |
Display the nmcli examples manual page with extensive usage examples | man nmcli-examples |
man 5 nm-settings |
Display documentation for NetworkManager connection settings and directives | man 5 nm-settings |
man firewalld.zone |
Display documentation for firewalld zone configuration files (XML format) | man firewalld.zone |
man firewalld.service |
Display documentation for firewalld service configuration files (XML format) | man firewalld.service |
Key Configuration Files (Reference)
| File/Directory | Description |
|---|---|
/etc/hostname |
Stores the system hostname |
/etc/hosts |
Local hostname-to-IP address mapping table |
/etc/resolv.conf |
DNS resolver configuration (managed by NetworkManager, do NOT edit directly) |
/etc/nsswitch.conf |
Name service switch configuration (controls hostname resolution order: files, dns, myhostname) |
/etc/services |
Maps service names to port numbers and protocols |
/etc/protocols |
Maps protocol names to protocol numbers |
/etc/NetworkManager/system-connections/*.nmconnection |
NetworkManager connection profile files (RHEL 9) |
/etc/sysconfig/network-scripts/ifcfg-* |
Legacy network connection profile files (still read by NetworkManager) |
/usr/lib/firewalld/zones/ |
System-defined firewalld zone configuration files (XML) |
/etc/firewalld/zones/ |
User-defined firewalld zone configuration files (XML, overrides system defaults) |
/usr/lib/firewalld/services/ |
System-defined firewalld service configuration files (XML) |
/etc/firewalld/services/ |
User-defined firewalld service configuration files (XML, overrides system defaults) |