linux两台设备网桥配置,Linux网桥配置

CentOS:

1、配置临时网桥,重启后风格配置丢失

[[email protected] ~]# yum -y install bridge-utils

[[email protected] ~]# brctl addbr br0   #创建网桥逻辑接口

[[email protected] ~]# brctl addif br0 eth0   #将eth0网卡添加到网桥中

[[email protected] ~]# brctl addif br0 eth1   #将eth1网卡添加到网桥中

[[email protected] ~]# ifconfig eth0 0.0.0.0   #将eth0网卡设为为混杂模式

[[email protected] ~]# ifconfig eth1 0.0.0.0   #将eth1网卡设为为混杂模式

[[email protected] ~]# ifconfig br0   #查看桥网卡配置

[[email protected] ~]# ifconfig br0 10.10.10.82/24   #给桥网卡设置IP地址

2、创建永久网桥

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0   #创建网桥配置文件

DEVICE=br0

TYPE=Bridge

BOOTPROTO=static

IPADDR=172.16.100.1

NETMASK=255.255.255.0

ONBOOT=yes

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 #将网卡加入到网桥中

DEVICE=eth0

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=static

IPADDR=0.0.0.0

BRIDGE=br0

[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1   #将网卡加入到网桥中

DEVICE=eth1

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=static

IPADDR=0.0.0.0

BRIDGE=br0

Debian:

1、配置临时网桥

[email protected]:~# apt-get install bridge-utils   #安装依赖包

[email protected]:~# brctl addbr br0     #创建网桥

[email protected]:~# ifconfig br0 up     #启用网桥

[email protected]:~# ip addr show      #查看网桥

[email protected]:~# brctl addif br0 eth0 eth1     #将网卡加入到网桥

[email protected]:~# brctl delif br0 eth1    #从网桥中删除eth1网卡

[email protected]:~# ifconfig br0 down    #关闭网桥

[email protected]:~# brctl delbr br0        #删除网桥

2、创建永久网桥

[email protected]:~# 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值