You don't have the vlan tag/trunk/id inside of the VM.
On the host you have to "terminate" the vlan and map them to a veb or
veb/vport.
As was mentioned in another post, vport isn't mandatory, you can also do
with just veb.
# /etc.vm.conf
switch "uplink_vlan800" {
interface veb800
}
switch "uplink_vlan880" {
interface veb880
}
vm "vm1" {
memory 16G
disk "/var/vmm/vm1.qcow2"
interface tap {
switch "uplink_vlan880"
lladdr fe:51:bb:1e:11:03
}
}
vm "vm2" {
memory 8G
disk "/var/vmm/vm2.qcow2"
interface tap {
switch "uplink_vlan800"
lladdr fe:51:bb:1e:11:05
}
}
In the VM you have standard config for /etc/hostname.vio0 like:
# /etc/hostname.vio0
inet <IPv4> <SUBNET>
inet6 <IPv6> <PREFIX>
Mischa
On 2024-06-14 18:09, jrmu wrote:
I attempted to follow the advice posted, but perhaps misunderstood
somewhere.
I attempted to assign the IP address to vlan0 inside the virtual
machine
(104.167.241.51). Needless to say this did not work, but I am not quite
sure
what the correct configuration is. Any help would be greatly welcome:
$ doas cat /etc/vm.conf
socket owner :vmdusers
switch "switch1" {
locked lladdr
interface veb1
}
bsdiso="/home/iso/install75.iso"
vm "jrmu" {
owner jrmu
memory 2G
cdrom $bsdiso
disk /home/jrmu/jrmu.qcow2 format qcow2
interface tap1 {
locked lladdr e8:8b:27:7b:7a:02
switch "switch0"
}
}
$ doas cat /etc/hostname.veb1
add vlan0
add vlan1
link1
$ doas cat /etc/hostname.vlan0
vnetid 100 parent em1
lladdr fe:e1:ba:d0:84:0e
up
$ doas cat /etc/hostname.vlan1
vnetid 100 parent tap1
lladdr fe:e1:ba:d0:84:0f
up
$ doas cat /etc/hostname.em1
inet 104.167.241.211 0xffffffc0
inet6 2602:fccf:400:41::1 64
!route add -inet6 2602:fccf:400::1 -cloning -link -iface em1
!route add -inet6 default 2602:fccf:400::1
$ ifconfig
em1:
flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu
1500
lladdr 00:25:90:5a:2d:92
index 2 priority 0 llprio 3
groups: egress
media: Ethernet autoselect (1000baseT full-duplex)
status: active
inet 104.167.241.211 netmask 0xffffffc0 broadcast 104.167.241.255
inet6 fe80::225:90ff:fe5a:2d92%em1 prefixlen 64 scopeid 0x2
inet6 2602:fccf:400:41::1 prefixlen 64
veb1: flags=a843<UP,BROADCAST,RUNNING,SIMPLEX,LINK1,MULTICAST>
description: switch2-switch1
index 6 llprio 3
groups: veb
vlan0 flags=3<LEARNING,DISCOVER>
port 7 ifpriority 0 ifcost 0
vlan1 flags=3<LEARNING,DISCOVER>
port 8 ifpriority 0 ifcost 0
vlan0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu
1500
lladdr fe:e1:ba:d0:84:0e
index 7 priority 0 llprio 3
encap: vnetid 100 parent em1 txprio packet rxprio outer
groups: vlan
media: Ethernet autoselect (1000baseT full-duplex)
status: active
vlan1: flags=8102<BROADCAST,PROMISC,MULTICAST> mtu 1500
lladdr fe:e1:ba:d0:84:0f
index 8 priority 0 llprio 3
encap: vnetid 100 parent none txprio packet rxprio outer
groups: vlan
status: no carrier
vport1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr fe:e1:ba:d1:85:30
index 10 priority 0 llprio 3
groups: vport
inet 104.167.241.51 netmask 0xfffffff8 broadcast 104.167.241.55
inet6 fe80::fce1:baff:fed1:8530%vport1 prefixlen 64 scopeid 0xa
inet6 2602:fccf:4:51:: prefixlen 48
tap1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu
1500
lladdr fe:e1:ba:d7:82:a2
description: vm2-if0-jrmu
index 17 priority 0 llprio 3
groups: tap vms
status: active
Inside the virtual machine jrmu:
jrmu# cat /etc/hostname.vio0
up
jrmu# cat /etc/hostname.vlan0
vnetid 100 parent vio0
inet 104.167.241.51 0xffffff00
inet6 2602:fccf:4:51:: 64
!route add 104.167.241.211 -cloning -link -iface vlan0
!route add default 104.167.241.211
!route add -inet6 2602:fccf:4::1 -cloning -link -iface vlan0
!route add -inet6 default 2602:fccf:4::1
up
jrmu# ifconfig
lo0: flags=2008049<UP,LOOPBACK,RUNNING,MULTICAST,LRO> mtu 32768
index 3 priority 0 llprio 3
groups: lo
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet 127.0.0.1 netmask 0xff000000
vio0:
flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu
1500
lladdr e8:8b:27:7b:7a:02
index 1 priority 0 llprio 3
media: Ethernet autoselect
status: active
enc0: flags=0<>
index 2 priority 0 llprio 3
groups: enc
status: active
vether0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr fe:e1:ba:d0:8c:a9
index 4 priority 0 llprio 3
groups: vether
media: Ethernet autoselect
status: active
inet 10.0.0.2 netmask 0xff000000 broadcast 10.255.255.255
inet6 fe80::fce1:baff:fed0:8ca9%vether0 prefixlen 64 scopeid
0x4
inet6 fc00::2 prefixlen 7
vlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
lladdr e8:8b:27:7b:7a:02
index 5 priority 0 llprio 3
encap: vnetid 100 parent vio0 txprio packet rxprio outer
groups: vlan egress
media: Ethernet autoselect
status: active
inet 104.167.241.51 netmask 0xffffff00 broadcast
104.167.241.255
inet6 fe80::ea8b:27ff:fe7b:7a02%vlan0 prefixlen 64 scopeid 0x5
inet6 2602:fccf:4:51:: prefixlen 64
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33136
index 6 priority 0 llprio 3
groups: pflog