With default networkd it would be (example profile):
name: debian-test
config:
user.network-config: |
#cloud-config
version: 2
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses:
- [YOUR IP]/32
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search: []
routes:
- to: 0.0.0.0/0
via: 169.254.0.1
on-link: true
user.user-data: |
#cloud-config
package_update: true
package_upgrade: true
packages:
- openssh-server
description: Debian Test.
devices:
eth0:
host_name: veth-debtest
ipv4.address: [YOUR IP]
nictype: routed
parent: [PARENT INTERFACE. The one the host, for example: enp1s0f0]
type: nic
root:
path: /
pool: default
size: 3GB
type: disk
Just replace the placeholders I wrote. However, for some reason on-link: true is actually not applied to the networkd’s configuration, which results in the network not working. To fix this, enter the container: lxc shell [container-name], and add: GatewayOnLink=yes to /etc/systemd/network/10-cloud-init-eth0.network file. Then restart networkd with: systemctl restart systemd-networkd and it’s done. Networking will work from now on.
Now that you have access to the network, you can download/install netplan and configure it if you wish. A good idea would be to create a custom image with netplan already installed, if you really want it in all future containers, I guess.
Did you add GatewayOnLink=yes like I mentioned, and did you restart networkd? If yes, then please paste the output of ip a and ip r from inside of the container.
Actually, one more thing. You mentioned that you added GatewayOnLink=yes to the “[Network]” section, that’s wrong. Add it to the [Route] section, at the very end of the file.
I’ll be avoiding this, as working with profiles completely destroyed all LXD networking. Packets no longer route… at all…
Nothing I can do to back out changes to fix this, so a reinstall is required.
My suggestion to LXD dev is to work with whoever is rolling the Debian LXD images + add in Ubuntu style netplan setup, so networking works out of the box, rather than hacking on system + destroying networking like I’ve done.