Configure IPv4
and IPv6 Addresses

Configure IPv4 and IPv6 addresses

CIS126RH | RHEL System Administration 1
Mesa Community College

Network configuration is among the most tested skills on the RHCSA exam. RHEL 9 manages network connections with NetworkManager and its command-line tool nmcli. Every persistent network setting — IP address, subnet mask, gateway, DNS — is stored in a connection profile that survives reboots. This module covers assigning static IPv4 and IPv6 addresses, configuring DNS and gateways, and verifying connectivity — all using nmcli as the primary tool.

Learning Objectives

  1. Explain the NetworkManager and nmcli model — Describe how NetworkManager manages connection profiles and why nmcli is the correct tool for persistent configuration
  2. Configure a static IPv4 address — Use nmcli to assign a static IPv4 address, subnet mask, default gateway, and DNS servers to a network interface
  3. Configure a static IPv6 address — Use nmcli to assign a static IPv6 address with prefix length, IPv6 gateway, and IPv6 DNS servers
  4. Verify and troubleshoot network configuration — Use ip addr, ip route, nmcli, and ping to confirm settings and diagnose problems

NetworkManager and nmcli

On RHEL 9, NetworkManager is the service that manages all network connections. nmcli is its command-line interface.

  • NetworkManager stores network settings in connection profiles (files in /etc/NetworkManager/system-connections/)
  • A connection profile defines all settings for one network connection: address, gateway, DNS, method (DHCP or static)
  • A profile is applied to a specific device (e.g. ens3)
  • Changes made with nmcli are persistent — they survive reboots
  • Changes made with ip addr add are temporary — lost at reboot
ip commands are temporary; nmcli commands are persistent

The ip addr add and ip route add commands modify the live kernel network state only. After a reboot the configuration reverts to what is stored in the NetworkManager profile. For persistent configuration, always use nmcli.

Viewing Current Network State

# Show all interfaces with their IP addresses
$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 ...
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic ens3
    inet6 fe80::1/64 scope link

# Show routing table
$ ip route show
default via 192.168.1.1 dev ens3 proto dhcp metric 100
192.168.1.0/24 dev ens3 proto kernel scope link src 192.168.1.100

# Show NetworkManager connection profiles
$ nmcli connection show
NAME    UUID                                  TYPE      DEVICE
ens3    abc123de-4567-89ab-cdef-012345678901  ethernet  ens3

# Show all details of a specific connection
$ nmcli connection show ens3

# Show network device status
$ nmcli device status

Configuring a Static IPv4 Address

The complete static IPv4 configuration requires setting four properties: address/prefix, gateway, DNS, and switching the method from DHCP to manual.

# Set the connection method to manual (static)
$ sudo nmcli connection modify ens3 \
    ipv4.method manual

# Set the IPv4 address and subnet mask (CIDR notation)
$ sudo nmcli connection modify ens3 \
    ipv4.addresses 192.168.1.200/24

# Set the default gateway
$ sudo nmcli connection modify ens3 \
    ipv4.gateway 192.168.1.1

# Set DNS servers (comma-separated for multiple)
$ sudo nmcli connection modify ens3 \
    ipv4.dns "8.8.8.8,8.8.4.4"

# All four in a single command (most efficient)
$ sudo nmcli connection modify ens3 \
    ipv4.method manual \
    ipv4.addresses 192.168.1.200/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns "8.8.8.8,8.8.4.4"

Activating the Connection

After modifying a connection profile, the changes must be applied to the live network interface by reactivating the connection.

# Reactivate the connection to apply changes
$ sudo nmcli connection up ens3
Connection successfully activated (D-Bus active path: ...)

# Alternative: reload all connections without disconnecting
$ sudo nmcli connection reload

# Verify the new address is active
$ ip addr show ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    inet 192.168.1.200/24 brd 192.168.1.255 scope global noprefixroute ens3

# Verify the gateway is in the routing table
$ ip route show
default via 192.168.1.1 dev ens3 proto static metric 100
192.168.1.0/24 dev ens3 proto kernel scope link src 192.168.1.200

# Verify DNS is configured
$ cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nmcli con mod → nmcli con up → ip addr show

This three-step pattern is the complete exam workflow. Modify the profile, activate it, then verify with ip addr show and ip route show.

Configuring a Static IPv6 Address

IPv6 configuration uses the same nmcli connection modify pattern with ipv6.* properties instead of ipv4.*.

# Set static IPv6 — all properties in one command
$ sudo nmcli connection modify ens3 \
    ipv6.method manual \
    ipv6.addresses "2001:db8:1::200/64" \
    ipv6.gateway "2001:db8:1::1" \
    ipv6.dns "2001:4860:4860::8888"

# Activate and verify
$ sudo nmcli connection up ens3
$ ip addr show ens3
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
    inet 192.168.1.200/24 ... ens3
    inet6 2001:db8:1::200/64 scope global noprefixroute

# Dual-stack: IPv4 and IPv6 can both be configured on the same interface
# Both method settings are independent
$ sudo nmcli connection modify ens3 \
    ipv4.method manual \
    ipv4.addresses 192.168.1.200/24 \
    ipv4.gateway 192.168.1.1 \
    ipv6.method manual \
    ipv6.addresses "2001:db8:1::200/64" \
    ipv6.gateway "2001:db8:1::1"

IPv4 vs IPv6 Address Formats

Feature IPv4 IPv6
Address length32 bits — 4 decimal octets128 bits — 8 groups of 4 hex digits
Example address192.168.1.2002001:db8:1::200
Subnet notation192.168.1.0/24 (CIDR)2001:db8:1::/64 (prefix length)
Loopback127.0.0.1::1
Link-local169.254.x.x (APIPA)fe80::/10 (always present)
Abbreviation rulesNo abbreviationLeading zeros dropped; consecutive zero groups → ::
Typical host prefix/24 (254 hosts), /32 (single host)/64 (network), /128 (single host)
nmcli propertyipv4.addressesipv6.addresses
IPv6 address abbreviation rules

Leading zeros in each group can be dropped: 2001:0db8:0001:0000:0000:0000:0000:0200 becomes 2001:db8:1::200. The :: replaces one contiguous sequence of all-zero groups — it can only appear once in an address.

Creating a New Connection Profile

When no profile exists for an interface, create one with nmcli connection add.

# Create a new static IPv4 connection profile
$ sudo nmcli connection add \
    type ethernet \
    con-name "static-ens3" \
    ifname ens3 \
    ipv4.method manual \
    ipv4.addresses 192.168.1.200/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns "8.8.8.8" \
    ipv6.method disabled
Connection 'static-ens3' (uuid) successfully added.

# Activate the new profile
$ sudo nmcli connection up static-ens3

# Deactivate an old DHCP connection if present
$ sudo nmcli connection down ens3

# Delete a connection profile
$ sudo nmcli connection delete old-connection
Modify existing vs create new

On the exam, the interface typically already has a DHCP connection profile. It is usually simpler to nmcli connection modify the existing profile to static rather than creating a new one.

nmcli Interactive Mode

nmcli connection edit opens an interactive shell for modifying a connection with tab completion — useful when learning property names.

# Open the interactive editor for a connection
$ sudo nmcli connection edit ens3
===| nmcli interactive connection editor |===
Editing existing '802-3-ethernet' connection: 'ens3'

Type 'help' or '?' for available commands.
Type 'print' to show all the connection properties.
Type 'describe [<setting>.<prop>]' for detailed property description.

There are 3 optional settings for 802-3-ethernet.
nmcli> set ipv4.addresses 192.168.1.200/24
nmcli> set ipv4.method manual
nmcli> set ipv4.gateway 192.168.1.1
nmcli> save
nmcli> quit

# Activate after saving
$ sudo nmcli connection up ens3

Configuring the Hostname

The system hostname is set with hostnamectl — a related network configuration task often tested alongside IP configuration.

# View the current hostname
$ hostnamectl
 Static hostname: servera.example.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: abc123...
           Boot ID: def456...
  Operating System: Red Hat Enterprise Linux 9.3
       CPE OS Name: cpe:/o:redhat:enterprise_linux:9
            Kernel: Linux 5.14.0-362.24.1.el9_3.x86_64
      Architecture: x86-64

# Set a new static hostname
$ sudo hostnamectl set-hostname servera.example.com

# Verify
$ hostname
servera.example.com

# Hostname is stored in /etc/hostname
$ cat /etc/hostname
servera.example.com
Three hostname types

Static — set by administrator, stored in /etc/hostname, survives reboots. Transient — assigned by DHCP or NetworkManager at runtime, not persistent. Pretty — free-form label for display only. The exam always asks for the static hostname.

Verifying Network Configuration

# Verify assigned IP addresses
$ ip addr show ens3
2: ens3: ... UP ...
    inet 192.168.1.200/24 brd 192.168.1.255 scope global noprefixroute ens3
    inet6 2001:db8:1::200/64 scope global noprefixroute

# Verify routing table (includes default gateway)
$ ip route show
default via 192.168.1.1 dev ens3 proto static metric 100

# Verify IPv6 routing
$ ip -6 route show

# Verify DNS configuration
$ cat /etc/resolv.conf

# Test connectivity to gateway
$ ping -c 4 192.168.1.1

# Test DNS resolution
$ ping -c 2 www.example.com

# Show full connection profile details
$ nmcli connection show ens3 | grep ipv4
Check the profile AND the live state

nmcli connection show ens3 shows what is saved in the profile. ip addr show ens3 shows what is currently active on the interface. After nmcli connection up, both should match.

Connection Profile Files

NetworkManager stores connection profiles as key-value files in /etc/NetworkManager/system-connections/.

# List connection profile files
$ ls /etc/NetworkManager/system-connections/
ens3.nmconnection

# View a connection profile file (read-only for reference)
$ sudo cat /etc/NetworkManager/system-connections/ens3.nmconnection
[connection]
id=ens3
uuid=abc123-de45-fg67-hi89-jk0123456789
type=ethernet
interface-name=ens3

[ethernet]

[ipv4]
address1=192.168.1.200/24,192.168.1.1
dns=8.8.8.8;8.8.4.4;
method=manual

[ipv6]
addr-gen-mode=eui64
method=auto

[proxy]
Use nmcli to edit profiles, not text editors

While the profile files are human-readable, editing them directly requires running sudo nmcli connection reload afterward and may cause parsing errors. Always use nmcli connection modify instead.

Network Configuration Quick Reference

Task Command
Show all interfaces and IPsip addr show
Show routing tableip route show
Show connection profilesnmcli connection show
Show profile detailsnmcli connection show CONNAME
Set static IPv4 addresssudo nmcli con mod CONNAME ipv4.addresses ADDR/PREFIX
Set IPv4 gatewaysudo nmcli con mod CONNAME ipv4.gateway GW
Set IPv4 DNSsudo nmcli con mod CONNAME ipv4.dns "DNS1,DNS2"
Set to static (not DHCP)sudo nmcli con mod CONNAME ipv4.method manual
Set static IPv6 addresssudo nmcli con mod CONNAME ipv6.addresses ADDR/PREFIX
Set IPv6 gatewaysudo nmcli con mod CONNAME ipv6.gateway GW6
Activate a connectionsudo nmcli connection up CONNAME
Deactivate a connectionsudo nmcli connection down CONNAME
Set the hostnamesudo hostnamectl set-hostname HOSTNAME
Test gateway connectivityping -c 4 GATEWAY

Common Mistakes

Mistake What goes wrong Correct approach
Using ip addr add instead of nmcli Address is active now but disappears after reboot — task fails grading Always use nmcli connection modify for persistent configuration
Forgetting ipv4.method manual DHCP overrides the static address — the configured address is never used Always set ipv4.method manual when assigning a static address
Forgetting nmcli connection up after modifying Profile is updated but the interface still uses the old configuration Always run sudo nmcli connection up CONNAME to apply changes
Not including the prefix length (/24) NetworkManager uses /32 by default — no subnet routing, connectivity fails Always specify the full CIDR notation: 192.168.1.200/24
Referencing the wrong connection name "Error: unknown connection 'eth0'" — the profile name may differ from the device name Run nmcli connection show first to get the exact profile NAME
IPv6 method left as auto when a static address is required IPv6 auto-configuration assigns additional addresses alongside the static one Set ipv6.method manual when assigning a static IPv6 address

Complete Static Configuration Workflow

The exam scenario: configure ens3 with a static IPv4 address 192.168.1.200/24, gateway 192.168.1.1, and DNS 8.8.8.8.

# Step 1: Identify the connection name
$ nmcli connection show
NAME    UUID   TYPE      DEVICE
ens3    ...    ethernet  ens3

# Step 2: Set all IPv4 properties at once
$ sudo nmcli connection modify ens3 \
    ipv4.method manual \
    ipv4.addresses 192.168.1.200/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns "8.8.8.8"

# Step 3: Activate the connection
$ sudo nmcli connection up ens3

# Step 4: Verify — all three checks
$ ip addr show ens3       # confirms IP address
$ ip route show             # confirms gateway
$ cat /etc/resolv.conf   # confirms DNS

# Optional: test connectivity
$ ping -c 2 192.168.1.1   # gateway reachable?

Knowledge Check

Answer these before moving to the next slide.

  1. Why must you use nmcli instead of ip addr add to configure a static IP address on RHEL 9?
  2. Write the single nmcli command to configure the connection ens3 with static IPv4 address 10.0.0.50/24, gateway 10.0.0.1, and DNS 10.0.0.53.
  3. After modifying the connection profile, what command applies the changes to the live interface?
  4. Write the command to verify that the static IP address 10.0.0.50 is currently active on ens3.
  5. Write the nmcli command to configure a static IPv6 address 2001:db8::50/64 with gateway 2001:db8::1 on connection ens3.
  6. What is the difference between what nmcli connection show ens3 displays and what ip addr show ens3 displays?

Knowledge Check — Answers

  1. ip addr add modifies only the kernel's live network state — the address is lost at the next reboot because it is not saved anywhere persistent. nmcli writes to the NetworkManager connection profile file, which is read at every boot, making the configuration persistent across reboots.
  2. sudo nmcli connection modify ens3 ipv4.method manual ipv4.addresses 10.0.0.50/24 ipv4.gateway 10.0.0.1 ipv4.dns "10.0.0.53"
  3. sudo nmcli connection up ens3 — this reactivates the connection using the updated profile, applying the new static IP, gateway, and DNS to the live network interface.
  4. ip addr show ens3 — examine the inet line in the output and confirm 10.0.0.50/24 is listed as the address.
  5. sudo nmcli connection modify ens3 ipv6.method manual ipv6.addresses "2001:db8::50/64" ipv6.gateway "2001:db8::1"
    Then activate: sudo nmcli connection up ens3
  6. nmcli connection show ens3 displays what is saved in the NetworkManager profile file — the intended configuration. ip addr show ens3 displays what is currently active in the kernel — the running configuration. After nmcli connection up, both should match. If they differ, the profile has been modified but not yet activated.

Key Takeaways

  1. Use nmcli for persistent configuration — not ip. ip addr add is temporary and lost at reboot. nmcli connection modify writes to the NetworkManager profile, which is read at every boot. Identify the connection name with nmcli connection show first.
  2. Static IPv4 requires four properties: method, address, gateway, DNS. ipv4.method manual disables DHCP. ipv4.addresses ADDR/PREFIX sets the address. ipv4.gateway GW sets the default route. ipv4.dns "DNS" sets the resolver. All four in one nmcli con mod command.
  3. Activate with nmcli connection up CONNAME after every modify. Profile changes do not take effect until the connection is reactivated. Verify with ip addr show (address), ip route show (gateway), and cat /etc/resolv.conf (DNS).
  4. IPv6 uses the same pattern with ipv6.* properties. ipv6.method manual, ipv6.addresses ADDR/PREFIX, ipv6.gateway GW6. IPv4 and IPv6 can both be configured on the same interface simultaneously (dual-stack). Both require their own method manual.

Graded Lab

  • Run nmcli connection show to identify the connection name for your primary network interface. Run ip addr show and ip route show to record the baseline IP address and gateway.
  • Configure a static IPv4 address using nmcli connection modify with all four required properties (method manual, address, gateway, dns). Use an address appropriate for your lab network (provided by the instructor).
  • Activate the connection with nmcli connection up. Verify with ip addr show (confirm the static address), ip route show (confirm the gateway), and cat /etc/resolv.conf (confirm DNS).
  • Add a static IPv6 address to the same connection using ipv6.method manual, ipv6.addresses, and ipv6.gateway. Activate and verify with ip addr show — confirm both the IPv4 and IPv6 addresses appear.
  • Set the system hostname to labserver.example.com using hostnamectl set-hostname. Verify with hostname and cat /etc/hostname.
  • Reboot the system. After reboot, run ip addr show, ip route show, and hostname to confirm all settings persisted. This confirms that nmcli — not ip — was used correctly.
RHCSA Objective

"Configure IPv4 and IPv6 addresses." Use nmcli con mod CONNAME ipv4.method manual ipv4.addresses A/P ipv4.gateway G ipv4.dns D then nmcli con up CONNAME then verify.