centos7物理机网桥配置

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       <bridge>      add bridge
    delbr       <bridge>      delete bridge
    addif       <bridge> <device>   add interface to bridge
    delif       <bridge> <device>   delete interface from bridge
    hairpin     <bridge> <port> {on|off}    turn hairpin on/off
    setageing   <bridge> <time>     set ageing time
    setbridgeprio   <bridge> <prio>     set bridge priority
    setfd       <bridge> <time>     set bridge forward delay
    sethello    <bridge> <time>     set hello time
    setmaxage   <bridge> <time>     set max message age
    setpathcost <bridge> <port> <cost>    set path cost
    setportprio <bridge> <port> <prio>    set port priority
    show        [ <bridge> ]      show a list of bridges
    showmacs    <bridge>      show a list of mac addrs
    showstp     <bridge>      show bridge stp info
    stp         <bridge> {on|off} turn stp on/off
[root@localhost ~]#

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=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 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<link>
        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<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::928d:6eff:fec0:946c  prefixlen 64  scopeid 0x20<link>
        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<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 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
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值