-
修改網卡連接配置
修改網絡連接eth0的IP地址(/掩碼),網關,DNS(兩個),IP地址方式為手動,是否自動連接。命令行如下:
[root@localhost network-scripts]# nmcli c modify eth0 ipv4.addresses '192.168.0.44/24' ipv4.gateway '192.168.0.1' ipv4.dns '101.198.198.198 192.168.0.1' ipv4.method manual connection.autoconnect yes
-
增加一個網絡連接
設備即網絡接口,連接是對網絡接口的配置。一個網絡接口可有多個連接配置,但同時只有一個連接配置生效。
增加一個網絡連接名稱為wqc的連接在網卡eth0上。命令行方式如下:
[root@localhost network-scripts]# nmcli c add type ethernet con-name wqc ifname eth0
或:
[root@localhost network-scripts]# nmcli c add type ethernet connection.id wqc ifname eth0
-
刪除一個網絡連接
[root@localhost network-scripts]# nmcli c del wqc
-
啟用 (停用)網絡連接
[root@localhost network-scripts]# nmcli c up wqc 啟用wqc 的連接,立即生效
[root@localhost network-scripts]# nmcli c down wqc 停用wqc 的連接,立即生效
-
命令行方式修改連接配置的對應關系
nmcli c modify eth0 ..........
nmcli 方法 ifcfg-*配置文件內容
ipv4.method manual BOOTPROTO=none
ipv4.method auto BOOTPROTO=dhcp
ipv4.addresses '192.0.2.1/24' IPADDR=192.0.2.1
PREFIX=24
ipv4.gateway '192.168.2.25' GATEWAY=192.0.2.25
ipv4.dns '8.8.8.8 4.4.4.4' DNS1=8.8.8.8DNS2=4.4.4.4
connection.autoconnect yes ONBOOT=yesconnection.autoconnect no ONBOOT=no
connection.id eth0 NAME=eth0
connection.interface-name eth0 DEVICE=eth0