配置多套网卡配置,方便在测试的时候切换地址
[23:10:43 root@localhost ~]#nmcli connection
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0
eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
virbr0 7fa014a2-3931-407c-a02c-56312ae92316 bridge virbr0
[23:10:55 root@localhost ~]#nmcli connection add con-name eth1-test ifname eth1 type ethernet ipv4.method manual ipv4.addresses 31.0.158.236/24
Connection 'eth1-test' (90be13dd-8db9-473a-afee-4c302541915d) successfully added.
[23:12:48 root@localhost ~]#nmcli connection
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0
eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
virbr0 7fa014a2-3931-407c-a02c-56312ae92316 bridge virbr0
eth1-test 90be13dd-8db9-473a-afee-4c302541915d ethernet --
[23:12:53 root@localhost ~]#cdnet
[23:13:56 root@localhost network-scripts]#ls
ifcfg-eth0 ifdown-bnep ifdown-isdn ifdown-Team ifup-bnep ifup-isdn ifup-routes ifup-wireless
ifcfg-eth1 ifdown-eth ifdown-post ifdown-TeamPort ifup-eth ifup-plip ifup-sit init.ipv6-global
ifcfg-eth1-test ifdown-ib ifdown-ppp ifdown-tunnel ifup-ib ifup-plusb ifup-Team network-functions
ifcfg-lo ifdown-ippp ifdown-routes ifup ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6
ifdown ifdown-ipv6 ifdown-sit ifup-aliases ifup-ipv6 ifup-ppp ifup-tunnel
[23:13:59 root@localhost network-scripts]#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:53:74:3a brd ff:ff:ff:ff:ff:ff
inet 192.168.70.7/24 brd 192.168.70.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe53:743a/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:53:74:44 brd ff:ff:ff:ff:ff:ff
inet 31.0.158.235/24 brd 31.0.158.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe53:7444/64 scope link
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:7f:41:29 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:7f:41:29 brd ff:ff:ff:ff:ff:ff
[23:14:55 root@localhost network-scripts]#nmcli connection up eth1-test
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[23:15:58 root@localhost network-scripts]#nmcli connection
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0
eth1-test 90be13dd-8db9-473a-afee-4c302541915d ethernet eth1
virbr0 7fa014a2-3931-407c-a02c-56312ae92316 bridge virbr0
eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet --
[23:16:07 root@localhost network-scripts]#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:53:74:3a brd ff:ff:ff:ff:ff:ff
inet 192.168.70.7/24 brd 192.168.70.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe53:743a/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:53:74:44 brd ff:ff:ff:ff:ff:ff
inet 31.0.158.236/24 brd 31.0.158.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::f4fe:6040:a639:2932/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:7f:41:29 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:7f:41:29 brd ff:ff:ff:ff:ff:ff
再添加可以手动修改ifcfg-eth1-test文件,修改IP地址和UID及name
然后nmcli connection reload加载配置,nmcli connection up eth1-test2启用
删除
[23:17:05 root@localhost network-scripts]#nmcli connection delete eth1-tes