2021年7月14日
Linux 双网卡桥接模式配置
目的:用作交换机
- 安装桥工具bridge-utils
sudo apt-get install bridge-utils - 打开IP转发,这是共享上网的必要条件
echo “1” > /proc/sys/net/ipv4/ip_forward - 添加一个桥接连接
brctl addbr br0
将eth0 eth1加到网桥中去ifconfig eth0 0.0.0.0 up ifconfig eth1 0.0.0.0 up brctl addif br0 eth0 brctl addif br0 eth1
- 修改文件/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto lo br0 iface lo inet loopback iface eth0 inet manual iface eth1 inet manual iface br0 inet static bridge_ports eth0 eth1 address 192.168.1.127 broadcast 192.168.1.255 #network 192.168.1.0 netmask 255.255.255.0 gateway 192.168.1.1
- 使能桥接连接
sudo ifconfig bridge0 up
- 重启
sudo reboot