nmcli

nmcli 同来管理网络配置和设备。另外 etc/sysconfig/network-scripts 中保存着网络和设备相关的配置文件。

nmcli con

显示所有连接
# nmcli connection show
NAME    UUID                                  TYPE            DEVICE
eth0    0e612544-0d1e-4487-83d8-d4f054e929d8  802-3-ethernet  eth0
virbr0  405c39c0-8b20-475e-a241-137f74982308  bridge          virbr0
显示所有活跃连接
# nmcli connection show --active
NAME    UUID                                  TYPE            DEVICE
eth0    0e612544-0d1e-4487-83d8-d4f054e929d8  802-3-ethernet  eth0
virbr0  405c39c0-8b20-475e-a241-137f74982308  bridge          virbr0
显示某一个连接的详细信息
# nmcli connection show eth0
....

nmcli dev

显示设备状态
# nmcli device status
DEVICE      TYPE      STATE      CONNECTION
virbr0      bridge    connected  virbr0
eth0        ethernet  connected  eth0
lo          loopback  unmanaged  --
virbr0-nic  tun       unmanaged  --
显示某一个设备的详细信息
# nmcli device show eth0
GENERAL.DEVICE:                         eth0
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         52:54:00:E0:D0:06
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eth0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/0
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.66.193.160/23
IP4.GATEWAY:                            10.66.193.254
IP4.ROUTE[1]:                           dst = 10.72.17.5/32, nh = 10.66.193.254, mt = 100
IP4.DNS[1]:                             10.72.17.5
IP4.DNS[2]:                             10.68.5.26
IP4.DOMAIN[1]:                          pek.redhat.com
IP6.ADDRESS[1]:                         2620:52:0:42c0:5054:ff:fee0:d006/64
IP6.ADDRESS[2]:                         fe80::5054:ff:fee0:d006/64
IP6.GATEWAY:                            fe80::e6d3:f1ff:fe9a:2cc3
IP6.ROUTE[1]:                           dst = 2620:52:0:42c0::/64, nh = ::, mt = 100

nmcli con add

添加一个动态连接
# nmcli connection add con-name "conn-dynamic" type ethernet ifname eth0
Connection 'conn-dynamic' (eaf49242-0708-43f7-aa98-10e62c29dfb4) successfully added.
添加一个静态连接
# nmcli connection add con-name "conn-static" ifname eth0 autoconnect no type ethernet ip4 10.66.192.100/24 gw4 10.66.193.254
Connection 'conn-static' (874025b6-7a32-4ab7-873e-255aad44f2b6) successfully added.
启动静态连接
# nmcli connection up "conn-static"
启动动态连接
# nmcli connection up "conn-dynamic"

nmcli con modify

关闭自动连接
# nmcli connection modify "conn-static" connection.autoconnect no
修改 ipv4.dns
# nmcli connection modify "conn-static" ipv4.dns 10.68.5.26
添加备份 DNS
# nmcli connection modify "conn-static" +ipv4.dns 8.8.8.
修改 ip 地址
# nmcli connection modify "conn-static" ipv4.addresses 10.66.192.100/24
添加备份 ip 地址
# nmcli connection modify "conn-static" +ipv4.addresses 10.10.10.10/16

results matching ""

    No results matching ""