Hello, I am having trouble understanding how to create an ipvlan interface and integrate it into an LXC container.
System: Debian 11
Host:
root@DUO:/srv/lxc # ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0a:9d:f6:0f:d7 brd ff:ff:ff:ff:ff:ff
inet 192.168.9.3/24 brd 192.168.9.255 scope global enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::20a:9dff:fef6:fd7/64 scope link
valid_lft forever preferred_lft forever
13: ipvl-jelly@enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether 00:0a:9d:f6:0f:d7 brd ff:ff:ff:ff:ff:ff
inet6 fe80::a:9d00:af6:fd7/64 scope link
valid_lft forever preferred_lft forever
root@DUO:/srv/lxc #
The host system has no bridge, ipv4 forwarding is activated.
The LXC container is also Debian, and a sample config looks like this:
#vmJellyfin
lxc.hook.pre-start = /usr/bin/bash -c "ip link add link enp3s0 name ipvl-jelly type ipvlan mode l2"
lxc.hook.post-stop = /usr/bin/bash -c "ip link delete ipvl-jelly"
lxc.net.0.type = ipvlan
lxc.net.0.ipvlan.mode=l2
#lxc.net.0.ipvlan.flags=bridge
lxc.net.0.link = ipvl-jelly
#lxc.net.0.l2proxy = 1
lxc.net.0.ipv4.address = 192.168.9.82/32
lxc.net.0.ipv4.gateway = 192.168.9.2
lxc.net.0.flags = up
lxc.apparmor.profile = unconfined
lxc.apparmor.allow_nesting = 1
lxc.rootfs.path = dir:/var/lib/lxc/vmJellyfin/rootfs
lxc.uts.name = vmJellyfin
lxc.arch = amd64
lxc.pty.max = 1024
In lxc.hook.pre-start, the ipvlan device is created, then no matter what is assigned to lxc.net.0.type or ipvlan.mode, contianer works.
root@DUO:/srv/lxc # lxc-ls -f
NAME STATE AUTOSTART GROUPS IPV4 IPV6 UNPRIVILEGED
vmJellyfin RUNNING 0 - 192.168.9.82 - false
vmLeantime STOPPED 0 - - - false
Question 1: Is my LXC network configuration correct?
Question 2: Why is there no network communication between the host and the container?
I’ve been playing around with namespaces, but it doesn’t work with the container.
See Example: https://www.kernel.org/doc/Documentation/networking/ipvlan.txt