[LINUX] [RHEL / CentOS 8] Network settings memo

How to use nmcli

The text-based user interface nmtui for network settings is intuitive, so here's a note of the command line interface nmcli.

computer_wireless.png

Connection list

Displays a list of recognized network interfaces. nmcli c

Example


# nmcli c[onnection]
NAME    UUID                                  TYPE      DEVICE 
ens160  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  ethernet  ens160

Verification

Overview

Check the current status. nmcli

Example


# nmcli

Details

Check the detailed settings of the specified network (connection ID). nmcli c s [connection ID]

Example


# nmcli c[onnection] s[how] ens160

Setting

Changes the settings of the specified network (connection ID). nmcli c [onnection] m [odifty] [connection ID] [+ |-] \ . \ \

Example


Fixed IP(For DHCP, set manual to auto) 
# nmcli c m ens160 ipv4.method manual

DNS
# nmcli c m ens160 ipv4.dns 8.8.8.8,8.8.4.4

IP address
# nmcli c m ens160 ipv4.addresses 192.168.45.10/24

default gateway
# nmcli c m ens160 ipv4.gateway 192.168.45.254

IPv6 disabled
# nmcli c m ens160 ipv6.method ignore

Automatic connection
# nmcli c m ens160 connection.autoconnect yes

Static route
# nmcli c m ens160 ipv4.routes "192.168.100.0/24 192.168.45.253"

Reflect connection system settings(No need for down)
# nmcli c up ens160

hostname
# nmcli g[eneral] hostname centkun8.fukuchan-senpai.local

Tips

How to set multiple IP addresses, DNS, static routes, etc. Also, how to delete.

Example


Set multiple items separated by commas
# nmcli c m ens160 ipv4.dns "8.8.8.8,8.8.4.4"

「+Add to the existing settings with "" in the head
# nmcli c m ens160 +ipv4.dns "1.1.1.1"

「-Prefix "" to delete only the matching parameters
# nmcli c m ens160 -ipv4.dns "8.8.4.4"

「""Erase the parameter with
# nmcli c m ens160 ipv4.dns ""

Recommended Posts

[RHEL / CentOS 8] Network settings memo
CentOS 7 basic settings after network settings
[CentOS] Network check / change command [RHEL]
Network settings and confirmation in CentOS7
CentOS 7 NW settings
CentOS 7 network initialization
Teaming (LACP) settings in CentOS 8
[WSL2] CentOS 8 VScode setting memo
AWS Lightsail Primer 4 Basic Settings (CentOS 7)