Network Manager - nmcliIf your Linux Distribution is using Network Manager, then nmcli is a great interface to configure connections from the command line interface.
To view connections using nmcli, use:
# nmcli connection NAME UUID TYPE DEVICE docker0 1948720d-d589-4a3f-99d6-5fefcb5a3380 bridge docker0 Wired connection 1 13f3f876-c0ab-3b31-a086-360d972043d8 802-3-ethernet enp4s0 tun0 c4e462c4-89d9-4d6d-8042-2c2eda44c6da tun tun0 virbr0 f3aedff9-2b78-4a7f-b24e-b3d878daefbf bridge virbr0 Droidz a940b5dd-ac3a-41b8-9d90-ed408c5f0910 802-11-wireless --
To see details use the show action with the connection name:
# nmcli connection show Droidz
Change the connection name from "Wired connection 1" to "enp4s0" after the device name:
Set IP Address
Set a single IP address for the enp4s0 connection:
Use Multiple Addresses
Configure multiple IP addresses for the enp4s0 connection:# nmcli connection modify enp4s0 ipv4.addresses \ 10.0.0.234/8,192.168.0.234/24
Modifying Other Connection SettingsIf using BASH shell completion, many other network connections can discovered to modify easily. For example, typing:
# nmcli connection modify enp4s0 ipv4.
and then pressing the TAB key would show:
ipv4.addresses ipv4.dhcp-send-hostname ipv4.dns-search ipv4.method ipv4.dad-timeout ipv4.dhcp-timeout ipv4.gateway ipv4.never-default ipv4.dhcp-client-id ipv4.dns ipv4.ignore-auto-dns ipv4.route-metric ipv4.dhcp-fqdn ipv4.dns-options ipv4.ignore-auto-routes ipv4.routes ipv4.dhcp-hostname ipv4.dns-priority ipv4.may-fail
Setting the Default GatewayThe command for setting the default gateway is:
# nmcli connection modify enp4s0 ipv4.gateway 192.168.0.1
Activating Modified ChangesAfter changing the configuration of a connection, bring the connection up to activate them:
# nmcli connection up enp4s0
Interactive EditingTo use an interactive editing mode from the command line, use the edit action for the connection:
# nmcli connection edit enp4s0
Use the help command to get started with editing.
Use the describe command to determine what to provide for a setting.
Hot tip: to avoid settings from being appended when set, first remove them. For example to return to a single IP address from multiple addresses, the other addresses must be removed first.
set ipv4.addresses 192.168.0.234/24
The nmtui and nm-connection-editor commands provide a text menu and graphical interface to Network Manager.