設備環境:
dell R710
網卡名字:em1、 em2、em3、em4
IP網段:10.0.0.x
[root@centos7 ~]# nmcli connection show
NAME UUID TYPE DEVICE
em1 3dc232fa-216b-4915-ab18-f10f7d3d93eb ethernet em1
virbr0 fb5ff432-8ba6-400f-9d7f-063c6bfe250e bridge virbr0
em2 a0d2e299-4b73-4aa3-bd76-71abbe0aec69 ethernet --
em3 593cdfbd-9603-4ae8-a052-48fab2f460e7 ethernet --
em4 7ebb584b-077d-4fda-9f1e-d65915b7dcda ethernet --
[root@centos7 ~]#
ifc_bridge_name="br0"
ip_address="10.0.0.11/24"
ip_gateway="10.0.0.1"
ip_dns1="202.103.24.68"
ip_dns2="202.103.44.150"
nmcli connection add type bridge con-name ${ifc_bridge_name} ifname ${ifc_bridge_name}
nmcli connection modify ${ifc_bridge_name} ipv4.method manual ipv4.addr "${ip_address}"
nmcli connection modify ${ifc_bridge_name} ipv4.gateway "${ip_gateway}"
nmcli connection modify ${ifc_bridge_name} +ipv4.dns "${ip_dns1}"
nmcli connection modify ${ifc_bridge_name} +ipv4.dns "${ip_dns2}"
[root@centos7 ~]# nmcli connection
NAME UUID TYPE DEVICE
br0 d267bc86-8314-4ebb-a4ee-a44c77f72b4f bridge br0
em1 3dc232fa-216b-4915-ab18-f10f7d3d93eb ethernet em1
virbr0 fb5ff432-8ba6-400f-9d7f-063c6bfe250e bridge virbr0
em2 a0d2e299-4b73-4aa3-bd76-71abbe0aec69 ethernet --
em3 593cdfbd-9603-4ae8-a052-48fab2f460e7 ethernet --
em4 7ebb584b-077d-4fda-9f1e-d65915b7dcda ethernet --
[root@centos7 ~]# nmcli connection up d267bc86-8314-4ebb-a4ee-a44c77f72b4f
[root@centos7 ~]# ifc_slave_name="em1"
[root@centos7 ~]# ifc_bridge_name="br0"
[root@centos7 ~]# nmcli connection modify ${ifc_slave_name} connection.slave-type bridge connection.master ${ifc_bridge_name}
[root@centos7 ~]# service NetworkManager restart
Redirecting to /bin/systemctl restart NetworkManager.service
[root@centos7 network-scripts]#cd /etc/sysconfig/network-scripts
[root@centos7 network-scripts]# vim ifcfg-br0
STP=yes
BRIDGING_OPTS=priority=32768
TYPE=Bridge
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=br0
UUID=d267bc86-8314-4ebb-a4ee-a44c77f72b4f
DEVICE=br0
ONBOOT=yes ##注意這裏!!!
IPADDR=10.0.0.11
PREFIX=24
GATEWAY=10.0.0.1
DNS1=202.103.24.68
DNS2=202.103.44.150
[root@centos7 ~]# reboot