Multiple static IPs for multiple CT

Hi everyone,
I’m a CS teacher learning about lxd.
For an assignment to my students I need 10 containers running apache and ssh on public (static) IPs. I thought about aliasing the public IPs on the host interface and adding a proxy for each IP to each container, for ports 80 and 22, like this:

lxc config device add ct1 ct180 proxy listen=tcp:PUBLIC_1:80 connect=tcp:CONT_1_IP:80
lxc config device add ct1 ct122 proxy listen=tcp:PUBLIC_1:22 connect=tcp:CONT_1_IP:22

…and so on. But this doesn’t really feel like the good way to go.
What would be the best way to do this?

Thanks a lot

Hi!

If that LXD host has an Ethernet connection to the LAN, then you (LXD admin) can use managed macvlan to assign IP address from the LAN.

See the release notes of LXD 4.4 on how to do this, LXD 4.4 has been released
There are other options but I think from what you described, the above approach is the simplest.

Hi again,

Thanks, It works and indeed it is extremely simple!
The host is Ubuntu 20.04; here’s what I did:

Updated LXD to 4.4:
sudo snap refresh --channel=4.4/stable lxd

Created macvlan0 network on the host assigned to ens33:
sudo lxc network create macvlan0 parent=ens33 --type=macvlan

Created an instance, connected it to the network:
sudo lxc init ubuntu:20.04 ct1
sudo lxc config device add ct1 eth0 nic network=macvlan0 name=eth0
sudo lxc start ct1

1 Like