yum provides brctl #查询工具所需安装的软件包
[root@localhost ~]# yum provides brctl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
base/7/x86_64/filelists_db | 7.2 MB 00:00:00
extras/7/x86_64/filelists_db | 277 kB 00:00:00
updates/7/x86_64/filelists_db | 8.2 MB 00:00:00
bridge-utils-1.5-9.el7.x86_64 : Utilities for configuring the linux ethernet bridge
Repo : base
Matched from:
Filename : /usr/sbin/brctl
bridge-utils-1.5-9.el7.x86_64 : Utilities for configuring the linux ethernet bridge
Repo : @anaconda
Matched from:
Filename : /sbin/brctl
bridge-utils-1.5-9.el7.x86_64 : Utilities for configuring the linux ethernet bridge
Repo : @anaconda
Matched from:
Filename : /usr/sbin/brctl
[root@localhost ~]# brctl -h
Usage: brctl [commands]
commands:
addbr add bridge
delbr delete bridge
addif add interface to bridge
delif delete interface from bridge
hairpin {on|off} turn hairpin on/off
setageing
yum install bridge-utils -y #安装网桥工具
brctl show #展示网桥
brctl addbr br100 #添加网桥
网桥及网卡配置文件:
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-em1 TYPE=Ethernet BOOTPROTO=none NAME=em1 DEVICE=em1 ONBOOT=yes BRIDGE="br100" [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-br100 TYPE=Bridge BOOTPROTO=static NAME=br100 DEVICE=br100 GATEWAY=192.168.3.1 DNS1=119.29.29.29 ONBOOT=yes IPADDR=192.168.3.225 PREFIX=24 [root@localhost ~]#
brctl addif br100 em1 #添加网卡到网桥
systemctl stop NetworkManager
systemctl disable NetworkManager #禁用此服务
systemctl restart network #重启网络
配置完成效果:
[root@localhost ~]# ifconfig br100: flags=4163mtu 1500 inet 192.168.3.225 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::928d:6eff:fec0:946c prefixlen 64 scopeid 0x20 ether 90:8d:6e:c0:94:6c txqueuelen 1000 (Ethernet) RX packets 42297 bytes 3766761 (3.5 MiB) RX errors 0 dropped 1913 overruns 0 frame 0 TX packets 242 bytes 32037 (31.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 em1: flags=4163 mtu 1500 inet6 fe80::928d:6eff:fec0:946c prefixlen 64 scopeid 0x20 ether 90:8d:6e:c0:94:6c txqueuelen 1000 (Ethernet) RX packets 42494 bytes 4573816 (4.3 MiB) RX errors 0 dropped 95 overruns 0 frame 0 TX packets 249 bytes 34555 (33.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 30 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 2 bytes 200 (200.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2 bytes 200 (200.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0



