- Points
- 178
In this mode, commands are slightly different from using nmcli in a non-interactive way. Here’s how you can configure your network settings in the nmcli interactive mode and also outside of it.
Using nmcli Interactive Mode
In nmcli interactive mode, commands should be entered without the nmcli prefix, and you typically use specific commands for each setting. Here’s how to set the IP address and other network settings in interactive mode:- Enter Interactive Mode
If you're not already in interactive mode, start it with:
Code:nmcli
- Edit the Connection
To edit the network connection named ens18, enter the following command:
Code:nmcli> con edit ens18
- Modify IP Address
Within the interactive mode, use the following command to modify the IP address:
Code:nmcli> set ipv4.addresses 31.xxx.xx.xxx/24
- Set the Gateway
Set the gateway using:
Code:nmcli> set ipv4.gateway 31.xxx.xx.x
- Set DNS Servers
Configure the DNS servers with:
Code:nmcli> set ipv4.dns "8.8.8.8 8.8.4.4"
- Set IPv4 Method to Manual
Ensure the IPv4 method is set to manual:
Code:nmcli> set ipv4.method manual
- Save and Quit
Save the changes and exit the interactive mode with:
Code:nmcli> save nmcli> quit
- Bring the Connection Up
Apply the changes and bring the connection up:
Code:nmcli con up ens18
Using nmcli Non-Interactive Commands
If you prefer to configure outside of interactive mode, use the non-interactive commands directly:- Modify IP Address
Code:nmcli con mod ens18 ipv4.addresses 31.xxx.xx.xxx/24
- Set the Gateway
Code:nmcli con mod ens18 ipv4.gateway 31.xxx.xx.x
- Set DNS Servers
Code:nmcli con mod ens18 ipv4.dns "8.8.8.8 8.8.4.4"
- Set IPv4 Method to Manual
Code:nmcli con mod ens18 ipv4.method manual
- Bring the Connection Up
Code:nmcli con up ens18
Summary
- Interactive Mode: Use nmcli> con edit ens18 to start editing, then use set commands for configuration. Save and quit with save and quit.
- Non-Interactive Mode: Directly use nmcli commands like nmcli con mod and nmcli con up.