In some cases you need more than one network interface attached to an instance and if you have a standard OS container the procedure is pretty much straight forward. However, deploying OCI images and assigning a second network interface comes with a challenge. It doesn’t work the same automatic way like eth0, except I’m missing something.
You can perform all the required incus low level steps like you do with normal OS containers like:
incus config device add <name> eth1 nic nictype=<type> parent=<parent> name=eth1
The interface is added to the config and initialised after successful instance start:
eth1:
Type: broadcast
State: DOWN
Host interface: eth1
MAC address: 00:16:3e:6a:03:18
MTU: 1500
Bytes received: 0B
Bytes sent: 0B
Packets received: 0
Packets sent: 0
IP addresses:
Now the challenge is to bring it up in the container. In most cases OCI images don’t have the required tools installed as you don’t need them in docker. So far I have been lucky that I could run:
apt update && apt -qq install isc-dhcp-client
echo "/sbin/dhclient -q eth1" >>/init
Or add a service to s6-overlay or similar which finally brings the interface up and an IP is assigned.
eth1:
Type: broadcast
State: UP
Host interface: vlan4
MAC address: 00:16:3e:a2:13:e6
MTU: 1500
Bytes received: 119.78kB
Bytes sent: 2.18kB
Packets received: 1832
Packets sent: 18
IP addresses:
inet: 192.168.225.185/24 (global)
inet6: fd33:36c1:983b:225:216:3eff:fea2:13e6/64 (global)
inet6: fe80::216:3eff:fea2:13e6/64 (link)
The procedure pretty much depends on the base image OS and init path chosen.
As mentioned above nothing needs to be done for eth0 (default interface) but when it comes to a second one you need to add some kind of logic into the image and this can sometimes be a challenge.
Adding OCI support is definitely a great feature and I love it already. I’m impressed what the first release has to offer. This is more or less about awareness how you can do it with the current 6.3 release and I’m looking forward what comes next.