How to use my local lan instead of incus network? Ipv4 and ipv6?

There are several options to make your containers to appear as if they are separate computers on your LAN. These options have been implemented long time ago in the Linux kernel and in some way, the current options bring back a bit of legacy from the old times. Most of them are about virtual networking and it’s the bread and butter of using Linux. Apart from that, there’s even an option to attach an additional physical network device to a container!

Among those virtual networking options, the easiest to setup is macvlan (does not require additional configuration on your host). However, the legacy it has, is that you will not be able to get the Incus host to communicate with the macvlan containers over the network. This looks like a big disadvantage, and may be so for your case. For others it’s a big advantage when they want to really separate the containers from the host, so in terms of security, a bad container cannot access the host.

Prerequisite: you need to find the name of your network interface on the host. In my case, it’s enp5s0 and I show how to find it below. Then, we create a new virtual network, macvlan that has the parent of enp5s0.

$ ip route show default
default via 192.168.1.1 dev enp5s0 proto dhcp metric 425 
$ incus network create macvlan --type=macvlan parent=enp5s0
Network macvlan created
$ incus network show macvlan
config:
  parent: enp5s0
description: ""
name: macvlan
type: macvlan
used_by: []
managed: true
status: Created
locations:
- none
project: default

Finally, let’s create us some containers on macvlan.

$ incus launch images:ubuntu/24.04/cloud mycontainer1 --network=macvlan
Launching mycontainer1
$ incus launch images:ubuntu/24.04/cloud mycontainer2 --network=macvlan
Launching mycontainer2
$ incus list mycontainer -c ns4t
+--------------+---------+----------------------+-----------+
|     NAME     |  STATE  |         IPV4         |   TYPE    |
+--------------+---------+----------------------+-----------+
| mycontainer1 | RUNNING | 192.168.1.241 (eth0) | CONTAINER |
+--------------+---------+----------------------+-----------+
| mycontainer2 | RUNNING | 192.168.1.236 (eth0) | CONTAINER |
+--------------+---------+----------------------+-----------+
$ 

If you then connect on your router and view the list of devices of your LAN, you will see these two as well.

5 Likes