查看网络脚本目录,只看到以太网卡eno1的配置:
[root@server ~]# ls -al /etc/sysconfig/network-scripts/
total 8
drwxr-xr-x. 2 root root 24 Oct 6 22:27 .
drwxr-xr-x. 7 root root 4096 Oct 6 23:15 ..
-rw-r--r--. 1 root root 308 Oct 6 22:27 ifcfg-eno1
查看以太网卡配置文件ifcfg-eno1的内容:
[root@server ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno1
UUID=ce6dd316-b6a9-4e58-9032-e0c1b3fcf1b0
DEVICE=eno1
ONBOOT=yes
查看当前连接:
[root@server ~]# nmcli connection
NAME UUID TYPE DEVICE
eno1 ce6dd316-b6a9-4e58-9032-e0c1b3fcf1b0 ethernet eno1
virbr0 979aeccf-7002-4b27-853b-ca0faddf7f0d bridge virbr0
新建网桥,名字为br0:
[root@server ~]# nmcli connection add type bridge con-name br0 ifname br0 autoconnect yes
Connection 'br0' (6d7894dc-ccb0-45a6-9347-940128de7efa) successfully added.
这时/etc/sysconfig/network-scripts目录已经新增一个文件ifcfg-br0,可查看到内容为:
[root@server ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
STP=yes
BRIDGING_OPTS=priority=32768
TYPE=Bridge
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=br0
UUID=6d7894dc-ccb0-45a6-9347-940128de7efa
DEVICE=br0
ONBOOT=yes
查看连接:
[root@server ~]# nmcli connection
NAME UUID TYPE DEVICE
eno1 ce6dd316-b6a9-4e58-9032-e0c1b3fcf1b0 ethernet eno1
virbr0 979aeccf-7002-4b27-853b-ca0faddf7f0d bridge virbr0
br0 6d7894dc-ccb0-45a6-9347-940128de7efa bridge br0
网桥br0桥接至eno1:
[root@server ~]# nmcli connection add type bridge-slave ifname eno1 master br0
Connection 'bridge-slave-eno1' (b1788643-bdbb-4f24-adde-265462f172fc) successfully added.
这时/etc/sysconfig/network-scripts目录已经自动新增一个文件ifcfg-bridge-slave-eno1:
[root@server ~]# cat /etc/sysconfig/network-scripts/ifcfg-bridge-slave-eno1
TYPE=Ethernet
NAME=bridge-slave-eno1
UUID=b1788643-bdbb-4f24-adde-265462f172fc
DEVICE=eno1
ONBOOT=yes
BRIDGE=br0
查看连接:
[root@server ~]# nmcli connection
NAME UUID TYPE DEVICE
eno1 ce6dd316-b6a9-4e58-9032-e0c1b3fcf1b0 ethernet eno1
virbr0 7bbff2fd-12e1-4e9c-8cd6-9f0bd14ad35e bridge virbr0
br0 6d7894dc-ccb0-45a6-9347-940128de7efa bridge br0
bridge-slave-eno1 b1788643-bdbb-4f24-adde-265462f172fc ethernet --
查看网络:
[root@server ~]# ifconfig
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::548:8ed0:e2e:51cd prefixlen 64 scopeid 0x20<link>
ether 00:d8:61:12:34:61 txqueuelen 1000 (Ethernet)
RX packets 4247 bytes 1606152 (1.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1895 bytes 350509 (342.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xdf000000-df020000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 220 bytes 20176 (19.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 220 bytes 20176 (19.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:cc:69:3d txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
关闭eno1:
[root@server ~]# nmcli connection down eno1
Connection 'eno1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
打开网桥br0:
[root@server ~]# nmcli connection up br0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
注意:如果这个过程是远程SSH或VNC操作的,需要耐心等信息返回~
查看连接(可以看到网桥已经生效):
[root@server ~]# nmcli connection
NAME UUID TYPE DEVICE
br0 6d7894dc-ccb0-45a6-9347-940128de7efa bridge br0
bridge-slave-eno1 b1788643-bdbb-4f24-adde-265462f172fc ethernet eno1
virbr0 7e63fed2-6839-43e0-9580-636729506f8f bridge virbr0
eno1 ce6dd316-b6a9-4e58-9032-e0c1b3fcf1b0 ethernet --
查看网络:
[root@server ~]# ifconfig
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::d0f2:879:9ecf:f907 prefixlen 64 scopeid 0x20<link>
ether 00:d8:61:12:34:61 txqueuelen 1000 (Ethernet)
RX packets 200 bytes 74916 (73.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 72 bytes 10614 (10.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:d8:61:12:34:61 txqueuelen 1000 (Ethernet)
RX packets 4526 bytes 1697104 (1.6 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2026 bytes 367827 (359.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 16 memory 0xdf000000-df020000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 256 bytes 23716 (23.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 256 bytes 23716 (23.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:cc:69:3d txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
网桥可以使用了。如不再使用网桥,可关闭,再重新打开eno1即可
————————————————
版权声明:本文为CSDN博主「智识训练营」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mdykj33/article/details/102638382