VLAN 感知桥顶部的 VLAN:可能吗以及如何实现?

VLAN 感知桥顶部的 VLAN:可能吗以及如何实现?

我目前正在将 OpenSUSE 主机配置为 KVM 虚拟机管理程序。

我有一个物理接口作为桥接器的从属接口。我将使这个桥接器接口能够识别 VLAN,并在虚拟机内部处理 VLAN 配置。

但是,我还想确保桥接接口本身是单独 VLAN 的成员,并获取该 VLAN 中的 IP 地址(静态分配)。这对于能够从该单独 VLAN 通过 SSH 进入虚拟机管理程序以管理虚拟机管理程序和虚拟机是必要的。

主机中只有一个物理网络接口。使用 nmcli 是否可行?那么如何实现呢?

我考虑在桥接器顶部定义一个 vlan 接口,并确保 vlan 接口获得 IP,但底层桥接器没有(但可以识别 vlan)。因此基本上:enp0s1 -> br0(可以识别 vlan,无 ip)-> br0.vlan(静态 ip)。

或者:

我在物理接口上定义了一个单独的 vlan 接口,因此:enp0s1 -> br0(vlan 感知,无 ip)+ enp0s1.vlan 具有静态 ip。

解决这个问题的方法是什么?

答案1

因此,我对“桥顶部的 VLAN 接口”的理解是nmcli

(我已经在 Slackware VM 上测试过了,但我认为它可以在生产服务器上运行)

第一个选项:桥顶的 VLAN 接口

# First create a bridge interface.
nmcli connection add type bridge con-name br0 ifname br0 stp yes

# Then modifying the bridge VLAN-aware.
nmcli connection modify br0 bridge.vlan_filtering yes

# Now add the VLAN interface on top of the bridge.
nmcli connection add type vlan con-name br0.vlan dev br0 id {YOUR_VLAN_ID}

# Finally modify the connection to assign a static IP address to the VLAN interface
nmcli connection modify br0.vlan ipv4.address {IPADDRESS}/{SUBNETMASK}

第二种选择:物理接口上的单独 VLAN 接口:

# First we create the VLAN interface on the physical interface.
nmcli connection add type vlan con-name enp0s1.vlan dev enp0s1 id {YOUR_VLAN_ID}

# Then modify the connection to assign a static IP address to the VLAN interface.
nmcli connection modify enp0s1.vlan ipv4.address {IPADDRESS}/{SUBNET_MASK}

我认为没有最好的方法,这取决于你网络设置

相关内容