centos下设置网桥

1、设置网卡

vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0

TYPE=Bridge

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=10.0.0.10

NETMASK=255.255.255.0

GATEWAY=10.0.0.254

DNS1=8.8.8.8

IPV6INIT=no

USERCTL=no

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

HWADDR=BC:30:5B:CB:30:3F

TYPE=Ethernet

UUID=e513c376-2c85-45a7-92ba-d14ca2225e69

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=no

#IPADDR=10.0.0.10

#NETMASK=255.255.255.0

#GATEWAY=10.0.0.254

#DNS1=192.168.1.250

#DNS2=192.168.1.251

#IPV6INIT=no

USERCTL=no

BRIDGE=br0

此步也可以这样设置网桥br0:

# brctl addbr br0

# ip addr add 10.0.0.10/24 dev br0

# ip link set dev br0 up

2、关闭 NetworkManager

chkconfig NetworkManager off

service NetworkManager stop

3、重启网络

service network restart

4、查看网桥

[root@localhost ~]# brctl show

bridge name   bridge id          STP enabled     interfaces

br0         8000.0050562539b9     no            ens33

命令:brctlbrctl --helpUsage: brctl [commands]commands:    addbr                 add bridge    delbr                 delete bridge    addif             add interface to bridge    delif             delete interface from bridge    setageing             set ageing time    setbridgeprio            set bridge priority    setfd                 set bridge forward delay    sethello              set hello time    setmaxage             set max message age    sethashel             set hash elasticity    sethashmax            set hash max    setmclmc              set multicast last member count    setmcrouter            set multicast router    setmcsnoop            set multicast snooping    setmcsqc              set multicast startup query count    setmclmi              set multicast last member interval    setmcmi               set multicast membership interval    setmcqpi              set multicast querier interval    setmcqi               set multicast query interval    setmcqri              set multicast query response interval    setmcqri              set multicast startup query interval    setpathcost        set path cost    setportprio        set port priority    setportmcrouter        set port multicast router    show          [ ]        show a list of bridges    showmacs              show a list of mac addrs    showstp               show bridge stp info    stp           {on|off}    turn stp on/off常用:1.创建网桥设备:brctl addbr ,eg:brctl addbr  br02.向网桥设备添加物理网卡:brctl addif ,eg:brctl  addif  br0 eth03.从网桥中删除网卡:brctl delif ,eg:brctl  delif  br0 eth04.删除网桥:brctl delbr ,eg:brctl delbr br05.查看网桥配置情况:brctl show

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐