Linux bridge

CentOS bridge 配置:

1、创建br0配置文件
  touch /etc/sysconfig/network-scripts/ifcfg-br0

2、修改bro配置文件

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

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=0.0.0.0
ONBOOT=yes

3、添加网卡到网桥

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

DEVICE=eth0   # 把eth0添加到网桥中
TYPE=Ethernet
BOOTPROTO=static
IPADDR=0.0.0.0
ONBOOT=yes
BRIDGE=br0

 

Ubuntu bridge配置

root@ubuntu~#vim /etc/network/interfaces

auto lo eth0 eth1 br0

iface lo inet loopback

iface br0 inet static

    address 10.10.10.1

    netmask 255.255.0.0

    gateway 10.10.10.254

    pre-up ip link set eth0 promisc on  #设置混杂模式

    pre-up ip link set eth1 promisc on  

    pre-up echo "1">/proc/sys/net/ipv4/ip_forward  #启用路由转发

    bridge_stp off  #关闭生成树

    bridge_ports eth0 eth1

 

brctl 命令集

root@Openstack001:~# brctl
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
原文地址:https://www.cnblogs.com/vincenshen/p/6295711.html