Main Goal: I am trying to have a container that can communicate with other devices on my network. Example: ping my laptop to check if it is still powered on. To that end I thought the easiest approach would be to have a container that acquires a static ip from my router using macvlan. But there are major problems…
I need my container to have a static ip on the network so that the different devices can also sometimes communicate with the container. I tried attaching the nic device using the settings below. If anyone can also help me to disable ipv6 from the incus configuration as well that would be great but I already know how to do that from within the container so it is not an absolute must.
Now, it works just fine and communicates with the network, but I cannot figure out how to assign a static ip address from here. Typically, in an ordinary host system I would assign static ips by modifying the /etc/network/interfaces file. But that file and directory does not exist in this container, apparently. I’m not familiar with any other ways to do this.
I also tried ipvlan and routed options to assign from within incus but I could not get them to work. They would never assign an ipv4 address but would still assign ipv6 addresses YET fail to connect to the internet regardless. I used the settings below for those…
There are several ways for the container to get an IP address from the LAN, and you list a few of them. When the container gets an IP address from the LAN with DHCP, it will keep getting the same IP address as long as you configure your router to give the same IP address for that MAC address. This is a common configuration in routers.
The downside with macvlan is that your container will not be able to access the host over the network. Ideally, you can use a bridge instead.
Hello. Thank you for the response. If I were to use a bridge, how could I configure it so that the container can ping a device on my home LAN, like a laptop device for example? With a macvlan nictype, I can just ping the ip address of the device but I didn’t think that was possible with a bridge network.
(if you are happy with macvlan, then keep macvlan. As I said, the only major downside is that your container with macvlan cannot access the host through the network. If you are happy with that, keep macvlan).
On your host machine, you must have the virtual network interface “lxbr0” visible from the command “ip addr show” AND the physical network interface “eno1” for example.
The transfer must be active; on your physical network card and on the virtual network card (bridge) so that the container network 172.16.0.0/24 and that of your local network 192.168.1.0/24 can communicate.