HPE CRAY 자료 공유

[LINUX] nmcli 명령 모음 본문

Applications/LINUX

[LINUX] nmcli 명령 모음

CRAY KOREA Blog 2023. 11. 14. 15:24

[Compare nm-settings with ifcfg-* directives (IPv4)]

nmcli con mod ifcfg-* file Effect
ipv4.method manual BOOTPROTO=none IPv4 address configured statically
ipv4.method auto OOTPROTO=dhcp Will look for configuration settings from a DHCPv4 server
ipv4.address "192.168.0.10/24" IPADDR=192.168.0.10
PREFIX=24
Set static IPv4 address, network prefix
ipv4.gateway 192.168.0.1 GATEWAY=192.168.0.1 Set IPv4 Gateway
ipv4.dns 8.8.8.8 DNS1=8.8.8.8 Modify /etc/resolv.conf to use this nameserver
ipv4.dns-search example.com DOMAIN=example.com Modify /etc/resolv.conf to use this domain in the search directive
ipv4.ignore-auto-dns true PEERDNS=no Ignore DNS Server information from the DHCP Server
connection.autoconnect yes ONBOOT=yes Automatically activate this connection on boot
connection.id eth0 NAME=eth0 NAME=eth0 The name of this connection
connection.interface-name eth0 DEVICE=eth0 The connection is bound to the network interface with this name
802-3-ethernet.mac-address 08:00:27:4b:7a:80 HWADDR=08:00:27:4b:7a:80 The connection is bound to the network interface with this MAC Address
ipv4.never-default no DEFROUTE=yes Never use provided interface's gateway as default gateway

 

[예제#1]

 # nmcli con mod enp0s8 ipv4.address "192.168.56.10/24"
 # nmcli con mod enp0s8 ipv4.method manual
 # nmcli con mod enp0s8 connection.autoconnect yes
 # nmcli con up enp0s8

 

[예제#2]

 # nmcli con add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=1000"
 # nmcli con add type ethernet slave-type bond con-name bond0-port0 ifname ens17f0 master bond0
 # nmcli con add type ethernet slave-type bond con-name bond0-port1 ifname ens19f0 master bond0
 # nmcli con mod bond0 ipv4.addresses '10.163.20.231/24'
 # nmcli con mod bond0 ipv4.gateway '10.163.20.1'
 # nmcli con mod bond0 ipv4.method manual
 # nmcli con up bond0

 

[예제#3: IB bonding]

 # nmcli con add type bond con-name bond1 ifname bond1 bond.options "mode=active-backup,miimon=100,updelay=100,downdelay=100" mtu 2044
 # nmcli con add type infiniband slave-type bond con-name ib0 ifname ib0 master bond1
 # nmcli con add type infiniband slave-type bond con-name ib1 ifname ib1 master bond1
 # nmcli con mod bond1 ipv4.addresses '192.168.20.201/24'
 # nmcli con mod bond1 ipv4.method manual
 # nmcli con mod bond1 connection.autoconnect yes
 # nmcli con up bond1

 

[Brief list of nmcli commands syntax]

Command Purpose
# nmcli dev status Show the Network Manager status of all network interfaces
# nmcli con show List all connections
# nmcli con show name List the current settings for the connection name
# nmcli con add con-name name .. Add a new connection named name
# nmcli con mod name .. Modify the connection name
# nmcli con reload Tell networkManager to reread the configuration files 
(useful after they have been edited by hand)
# nmcli con up name Activate the connection name
# nmcli dev dis dev Deactivate and disconnect the current connection on the network interface dev
# nmcli con del name Delete the connection name and its configuration file

 

- 참고 : https://www.golinuxcloud.com/nmcli-command-examples-cheatsheet-centos-rhel