lxcmanualip
LXC – Disable DHCP
With regular LXC, I wasn't able to set the IP in the container config. The networking config format seems to have changed a few times, or across distros, and a lot of the solutions seem to refer to wrappers like LXD.
So instead, here's just the default way to manually configure the IPs within the container – it doesn't necessarily work that way in a distro from an ISO, but in the versions you'd get with lxc-create -t download.
netplan (Ubuntu)
- /etc/netplan/10-lxc.yaml
- network:
- version: 2
- ethernets:
- eth0:
- dhcp4: false
- addresses:
- - 192.168.122.114/24
- routes:
- - to: default
- via: 192.168.122.1
- dhcp-identifier: mac
- nameservers:
- addresses:
- - 192.168.122.31
- - 9.9.9.9
Apply with netplan apply.
systemd-networkd (Debian)
Debian uses systemd-networkd. This will also work on Ubuntu (and others, of course), if you disable or uninstall netplan.
- /etc/systemd/network/eth0.network
- [Match]
- Name=eth0
- [Network]
- Address=192.168.122.57/24
- Gateway=192.168.122.1
- DNS=192.168.122.31
lxcmanualip.txt · Last modified: by wolfo
