Ubuntu:VLAN + 桥接不起作用

Ubuntu:VLAN + 桥接不起作用

我正在尝试为 LXC(我们的容器需要真实的 IP 地址)创建一个连接到 VLAN(ID 5)的网桥(br0.5)。该盒子不会连接到默认 VLAN,并且交换机上的端口配置为中继。

所以我在 /etc/network/interfaces 中执行了此操作。这是 Ubuntu 16.04 Server LTS。

auto enp1s0f0
iface enp1s0f0 inet manual
up /sbin/ifconfig enp1s0f0 up || /bin/true
down /sbin/ifconfig enp1s0f0 down || /bin/true

auto enp1s0f0.5
iface enp1s0f0.5 inet manual
vlan-raw-device eth0

auto br0
iface br0 inet manual
bridge_ports enp1s0f0 
bridge_stp off 
pre-up /sbin/ifconfig enp1s0f0 up || /bin/true
up /sbin/ifconfig br0 up || /bin/true 

auto br0.5
iface br0.5 net static
address 192.168.5.77
netmask 255.255.255.0
gateway 192.168.5.1
dns-nameservers 192.168.1.2 192.168.1.5 
vlan-raw-device br0

一旦我应用此配置,就会添加默认路由,网关确实是 192.168.5.1。问题是:我无法访问任何东西,甚至无法 ping 同一 VLAN 中的主机。所有接口都已启动。

缺什么?

答案1

你做的方式有点不对。

您应该将实际的 VLAN 接口包含到网桥中,因此您的配置应该看起来像这样:

auto enp1s0f0
iface enp1s0f0 inet manual

auto enp1s0f0.5
iface enp1s0f0.5 inet manual

auto br0
iface br0 inet manual
bridge_ports enp1s0f0.5 
bridge_stp off 

auto br0
iface br0 net static
address 192.168.5.77
netmask 255.255.255.0
gateway 192.168.5.1
dns-nameservers 192.168.1.2 192.168.1.5

您也不需要单独的ifconfig命令,网络子系统会直接处理这些命令。

相关内容