1、检查 server101 的网卡,记住第二个网卡的名称
[root@server101 ~]# nmcli device
DEVICE TYPE STATE CONNECTION
br0 bridge connected Bridge eno16777736
eno16777736 ethernet connected System eno16777736
eno33554960 ethernet disconnected --
eno50332184 ethernet disconnected --
lo loopback unmanaged --
2. 创建一个新的 connection,名称为 net2,使用第二个网卡,IP 地址 192.168.1.101 /24,确保 system 可以通过第二个网卡 ping 通 192.168.1.254
[root@server101 ~]# nmcli connection add con-name net2 ifname eno33554960 autoconnect yes type ethernet
Connection 'net2' (2a1215b2-24c4--a76f-c8a84610ed4a) successfully added.
[root@server101 ~]# nmcli connection modify net2 ipv4.addresses '192.168.1.101/24' ipv4.method manual
[root@server101 ~]# nmcli connection up net2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/)
[root@server101 ~]# ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast master br0 state UP qlen
link/ether :0c:::3f: brd ff:ff:ff:ff:ff:ff
: eno33554960: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c:::3f:5d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.101/ brd 192.168.1.255 scope global eno33554960
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe16:3f5d/ scope link
valid_lft forever preferred_lft forever
: eno50332184: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c:::3f: brd ff:ff:ff:ff:ff:ff
: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc noqueue state UP
link/ether :0c:::3f: brd ff:ff:ff:ff:ff:ff
inet 192.168.0.101/ brd 192.168.0.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe16:3f53/ scope link
valid_lft forever preferred_lft forever
[root@server101 ~]# ping 192.168.1.254
PING 192.168.1.254 (192.168.1.254) () bytes of data.
bytes from 192.168.1.254: icmp_seq= ttl= time=0.690 ms
bytes from 192.168.1.254: icmp_seq= ttl= time=0.851 ms
bytes from 192.168.1.254: icmp_seq= ttl= time=1.13 ms
^C
--- 192.168.1.254 ping statistics ---
packets transmitted, received, % packet loss, time 2003ms
rtt min/avg/max/mdev = 0.690/0.890/1.131/0.185 ms
[root@server101 ~]#
3