简单的在 Linux 下配置网桥

8/4/2022 Linux

# 安装依赖

安装 brctl 或 iproute

ubuntu

apt intstall -y brctl iproute2
1

alpine

apk add brctl iproute2
1

# 配置网桥

以创建虚拟网桥 br-bridge 并桥接 eth1 eth2 两张网卡为例

ip route

ip link add name br-bridge type bridge
ip link set dev br-bridge up
ip link set dev eth1 master br-bridge
ip link set dev eth2 master br-bridge
1
2
3
4

brctl

brctl addbr br-bridge
brctl addif br-bridge eth1 eth2
1
2

# 启动网卡

避免因为网桥或网卡未启动的,导致流量无法正常通过

ip link set eth1 up
ip link set eth2 up
ip link set br-bridge up
1
2
3
Last Updated: 4/4/2023, 2:33:27 AM