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    #查看网桥状态
[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:~# ip addr show      #查看网桥
root@debian:~# brctl addif br0 eth0 eth1     #将网卡加入到网桥
root@debian:~# brctl delif br0 eth1    #从网桥中删除eth1网卡
root@debian:~# ifconfig br0 down    #关闭网桥
root@debian:~# brctl delbr 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

 

转载于:https://www.cnblogs.com/xwupiaomiao/p/8744860.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值