Configuring Multiple Managed NICs with OCI Containers

I am looking to better understand if it is possible use multiple NICs with an OCI instance.

My goal is to to run a OCI reverse proxy in front of multiple instances from distinct networks. The idea here is that unrelated instances can be on separate managed networks, but the reverse proxy can connect to all networks and access instances on them, ideally using Incus’s DNS resolution.

I believe that similar isolation can be achieved with firewall configuration and/or that I can manually configure multiple NICs, Subnets, DNS, using LXC + Cloud-Init instead of OCI or by using macvlan and managing networking almost entirely outside of Incus. However I’d rather not move away from managed bridge networks if possible to avoid added complexity.

I found the following issue is resolved: Default routes and multiple DHCP clients for OCI containers · Issue #2403 · lxc/incus · GitHub

This seems to imply that multiple DHCP clients should work across multiple NICs, but in my experience only the “eth0” NIC appears to get an IPv4 address from it’s managed network. Other configured NICs seem to only have a self-assigned IPv6 address.

With the desired setup I described I suppose I’d also need a way to specify a default gateway (or at least expect a reasonable default like “eth0”), but otherwise the hope would be that DNS would be automatically configured to resolve each managed network based on it’s configured dns.domain.

Please have a look at my/our incus-compose oci containers with many networks as well as external ones are easy with it.

Networks doc: docs/compose-compatibility.md · main · René Jochum / incus-compose · GitLab

Note that we gonna move incus-compose soon to github.

The many dependencies example might be interesting for you: examples/many-dependencies · main · René Jochum / incus-compose · GitLab

Thank you for sharing. I’m very familiar with docker compose, but unfortunately the compose model doesn’t really meet my needs in this particular case. That said, I’ll take a look at the source and try to figure out how you manage multiple networks like this and see if I can extrapolate how to do so manually for the issue I am facing.

I would still love to understand how incus OCI is expected to behave with multiple managed NICs and/or how to adjust configuration for better default handling.

@davek I’m sorry I didn’t read you’r OP trough and trough, incus-compose isn’t doing what you want, yet as it doesn’t handle internal / as in firewalled bridges yet.

About DNS for managed bridges I found an easy way to configure additional hosts raw.dnsmasq on the network like:

$ incus-compose incus network show ic-h3vxrnqwhm

config:
  ipv4.address: 10.131.32.1/24
  ipv4.dhcp.ranges: 10.131.32.64-10.131.32.254
  ipv4.nat: "true"
  ipv6.address: fd42:83ec:4e22:80f::1/64
  ipv6.nat: "true"
  raw.dnsmasq: |
    address=/database/10.131.32.229
    address=/database/fd42:83ec:4e22:80f:1266:6aff:fe0a:58d2
    address=/machine-learning/10.131.32.145
    address=/machine-learning/fd42:83ec:4e22:80f:1266:6aff:fe86:47dc
    address=/microservices/10.131.32.217
    address=/microservices/fd42:83ec:4e22:80f:1266:6aff:fef0:d288
    address=/redis/10.131.32.144
    address=/redis/fd42:83ec:4e22:80f:1266:6aff:fed7:89c3
    address=/server/10.131.32.17
    address=/server/fd42:83ec:4e22:80f:1266:6aff:fe0a:f4b5
description: 'incus-compose: immich:default'
name: ic-h3vxrnqwhm
type: bridge
used_by:
  - /1.0/instances/machine-learning?project=immich
  - /1.0/instances/microservices?project=immich
  - /1.0/instances/postgres?project=immich
  - /1.0/instances/redis?project=immich
  - /1.0/instances/server?project=immich
managed: true
status: Created
locations:
  - none
project: default

Please let us know when you found a solution for that.

Just found Network Isolation · mensfeld/code-on-incus Wiki · GitHub they use firewalld for network isolation.

I haven’t had much time to dedicate to investigation here, though I imagine raw.dnsmasq and external firewalld (or similar firewall) could help with the DNS and isolation goals I outlined. It certainly doesn’t maintain the simplicity of default managed bridge networks, but perhaps the simplicity I am looking for isn’t attainable.

That said, I think the root of my issue still goes back to this issue here: Default routes and multiple DHCP clients for OCI containers · Issue #2403 · lxc/incus · GitHub

If I understand it correctly, it appears that multiple DHCP clients should work across multiple NICs for OCI, but in my experience only the “eth0” NIC appears to get an IPv4 address from it’s managed network. Other configured still NICs seem to only have a self-assigned IPv6 address.