Linux网桥配置

CentOS:
1、配置临时网桥,重启后风格配置丢失
[root@CentOS ~]# yum -y install bridge-utils
[root@CentOS ~]# brctl addbr br0   #创建网桥逻辑接口
[root@CentOS ~]# brctl addif br0 eth0   #将eth0网卡添加到网桥中
[root@CentOS ~]# brctl addif br0 eth1   #将eth1网卡添加到网桥中
[root@CentOS ~]# brctl show br0  #查看br0网桥状态
[root@CentOS ~]# ifconfig eth0 0.0.0.0   #将eth0网卡设为为混杂模式
[root@CentOS ~]# ifconfig eth1 0.0.0.0   #将eth1网卡设为为混杂模式
[root@CentOS ~]# ifconfig br0   #查看桥网卡配置
[root@CentOS ~]# ifconfig br0 10.10.10.82/24   #给桥网卡设置IP地址

2、创建永久网桥
[root@CentOS ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0   #创建网桥配置文件
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=10.47.8.17
NETMASK=255.255.255.0
GATEWAY=10.47.8.1
DNS1=223.5.5.5
DNS2=10.0.0.9
ONBOOT=yes
[root@CentOS ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 #将网卡加入到网桥中
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=0.0.0.0
BRIDGE=br0
[root@CentOS ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1   #将网卡加入到网桥中
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=0.0.0.0
BRIDGE=br0

Debian:
1、配置临时网桥
root@debian:~# apt-get install bridge-utils   #安装依赖包
root@debian:~# brctl addbr br0     #创建网桥
root@debian:~# ifconfig br0 up     #启用网桥
root@debian:~# brctl show br0    #查看网桥
root@debian:~# brctl addif br0 eth0 eth1     #将网卡加入到网桥
root@debian:~# brctl delif br0 eth1    #从网桥中删除eth1网卡
root@debian:~# ifconfig br0 down    #关闭网桥
root@debian:~# brctl delbr br0        #删除网桥
root@debian:~# ip address help
root@debian:~# ip link set br0 up/down
root@debian:~# ip address show dev br0
root@debian:~# ip address add 192.168.120.10/24 dev br0
root@debian:~# ip address del 192.168.120.10/24 dev br0

2、创建永久网桥
root@debian:~# nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
# auto lo br0 两行写成一行
auto lo
auto br0
iface lo inet loopback
iface br0 inet static
iface eth0 inet manual
iface eth1 inet manual
address 10.1.1.122
broadcast 10.1.1.255
netmask 255.255.255.0
gateway 10.1.1.1
bridge_ports eth0 eth1    #把eth0,eth1加入到网桥
bridge_stp off                 # disable Spanning Tree Protocol
bridge_waitport 0          # no delay before a port becomes available
bridge_fd 0                   # no forwarding delay

 参考链接:
        http://www.javashuo.com/article/p-dxtywwah-ue.html           #Linux网络管理

posted @ 2018-04-08 14:35  風£飛  阅读(797)  评论(0编辑  收藏  举报