CentOS8创建网桥
bridge-utils软件包在RHEL7.7被弃用了,所以后面版本不能使用brctl命令。
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/7.7_release_notes/deprecated_functionality
使用nmcli可以完成相同的功能:
1.创建网桥
1 nmcli conn add type bridge con-name br0 ifname br0
2.配置IP地址
1 nmcli connection modify br0 ipv4.addresses '192.168.11.8/24' ipv4.gateway '192.168.11.254' ipv4.dns '114.114.114.114' ipv4.method manual
3.为网桥关联物理接口
1 nmcli conn add type ethernet slave-type bridge con-name br0-ens192 ifname ens192 master br0 2 nmcli conn up br0
4.关闭以太网卡的connection
1 nmcli conn down ens192
5.查看物理网卡的桥接
1 [root@localhost ~]# bridge link show 2 2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100 3 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 master virbr0 state disabled priority 32 cost 100 4 7: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master virbr0 state forwarding priority 32 cost 100
如需要恢复配置,执行如下命令。
1 nmcli conn up ens192 2 nmcli conn down br0 3 nmcli conn del br0 4 nmcli conn del br0-ens192