# View ip (similar to ifconfig, ip addr)
nmcli
# Create connection, configure static ip (equivalent to configure ifcfg, where BOOTPROTO=none, and ifup starts)
nmcli c add type ethernet con-name ethX ifname ethX ipv4.addr 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.method manual
# Create connection, configure dynamic ip (equivalent to configure ifcfg, where BOOTPROTO=dhcp, and ifup starts)
nmcli c add type ethernet con-name ethX ifname ethX ipv4.method auto
# Modify ip (non-interactive)
nmcli c modify ethX ipv4.addr '192.168.1.200/24'
nmcli c up ethX
# Modify ip (interactive)
nmcli c edit ethX
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> change
Edit 'addresses' value:192.168.1.200/24
Do you also want to set'ipv4.method' to 'manual'?[yes]: yes
nmcli ipv4> save
nmcli ipv4> activate
nmcli ipv4> quit
# Enable connection (equivalent to ifup)
nmcli c up ethX
# Stop connection (equivalent to ifdown)
nmcli c down
# Delete connection (similar to ifdown and delete ifcfg)
nmcli c delete ethX
# View the connection list
nmcli c show
# View connection details
nmcli c show ethX
# Reload all ifcfg or route to connection (not effective immediately)
nmcli c reload
# Reload the specified ifcfg or route to connection (will not take effect immediately)
nmcli c load /etc/sysconfig/network-scripts/ifcfg-ethX
nmcli c load /etc/sysconfig/network-scripts/route-ethX
# Immediately effective connection, there are 3 methods
nmcli c up ethX
nmcli d reapply ethX
nmcli d connect ethX
# View device list
nmcli d
# View all device details
nmcli d show
# View detailed information of the specified device
nmcli d show ethX
# Activate the network card
nmcli d connect ethX
# Turn off wireless network (NM enables wireless network by default)
nmcli r all off
# View NM management status
nmcli n
# Turn on NM management
nmcli n on
# Close NM management (execute with caution)
nmcli n off
# Listen for events
nmcli m
# View the status of NM itself
nmcli
# Check if NM is available online
nm-online
The ifcfg mentioned above refers to /etc/sysconfig/network-scripts/ifcfg-ethX and /etc/sysconfig/network-scripts/route-ethX
Recommended Posts