Prerequisites
This guide requires:
- RHEL8+ or compatible Linux distribution
- NetworkManager installed and running
- Elevated privileges (sudo access)
1. Identify Network Interfaces
Check which network interfaces are available:
nmcli device status
Example output:
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected Wired connection 1
2. Create a New Static Connection
Create a new connection profile named static-prod with a static IP:
sudo nmcli connection add \
type ethernet \
ifname ens160 \
con-name static-prod \
ipv4.method manual \
ipv4.addresses 192.168.1.50/24 \
ipv4.gateway 192.168.1.1 \
ipv4.dns 192.168.1.10
Explanation:
- type ethernet: connection type
- ifname ens160: bind profile to interface
- con-name static-prod: descriptive profile name
- ipv4.method manual: use static IP
- ipv4.addresses, gateway, dns: network settings
3. Activate the New Connection
sudo nmcli connection up static-prod
This applies the profile to the interface and assigns the static IP.
4. Verify the Connection
ip addr show ens160
nmcli connection show --active
You should see static-prod active with the correct IP.
5. Manage Existing Profiles (Optional)
Disable autoconnect for old profiles to avoid conflicts:
sudo nmcli connection modify "Wired connection 1" connection.autoconnect no
sudo nmcli connection up "Wired connection 1" # To switch back if needed
This allows safe switching between multiple profiles on the same interface.