I am very sorry for the confusion. @tomp was kind enough to offer a very quick and comprehensive answer to my question, yet I discovered I had to delete this very question, because it included some network information I did not want to share. So this is a redacted version. If you are reading this thread, this is the question that tomp answered to in his comment above. I will study his answer and provide feedback in another comment, as soon as I find the time.
For me, this doesn’t happen. No routes are created inside the container. I used the commands you list below:
- lxc profile copy default rnic
- lxc profile device remove rnic eth0
- lxc profile device add rnic eth0 nic nictype=routed parent=ens3
- lxc init ubuntu:18.04 c1 -p rnic
- lxc config device override c1 eth0 ipv4.address=[MY-PUBLIC-IP]
- lxc start c1
- lxc exec c1 ip r
The last command turns up nothing. No routes are created inside the container. Can I set them up manually? Because when I use this as my /etc/netplan/50-cloud-init.yaml below, I can ping in and out, but nameserver resolution doesn’t work.
network:
version: 2
ethernets:
eth0:
addresses: [MY-PUBLIC-IP]
nameservers:
addresses: [8.8.8.8]
routes:
- to: 0.0.0.0/0
via: 169.254.0.1
on-link: true
And ip r only comes up like this:
default via 169.254.0.1 dev eth0 proto static onlink
The second line, beginning with the IP, is missing.
I use Bionic and the LXD Snap, currently at 3.22.
This Netplan gives me the same result:
network:
version: 2
ethernets:
eth0:
addresses: [MY-PUBLIC-IP]
gateway4: 169.254.0.1
nameservers:
addresses: [8.8.8.8]
I can ping fine, but name resolution doesn’t work. And “ip r” only produces this line, nothing, more:
default via 169.254.0.1 dev eth0
When I change /etc/netplan/50-cloud-init.yaml inside the container to the following, I still don’t have dns, but some changes:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses: [My-Public-IP/32]
dhcp4: no
nameservers:
addresses: [8.8.8.8]
gateway4: 169.254.0.1
routes:
- to: 169.254.0.1/32
via: 169.254.0.1
scope: link
“ip r” now results in this:
default via 169.254.0.1 dev eth0
default via 169.254.0.1 dev eth0 proto static
169.254.0.1 dev eth0 scope link
But still no name resolution, even though it looks fine to me:
Link 73 (eth0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 8.8.8.8
journalctl says:
Using degraded feature set (UDP) for DNS server 8.8.8.8.
or
Using degraded feature set (TCP) for DNS server 8.8.8.8.
Btw. this is a KVM guest rented from Netcup, where I purchased additional IPv4, which Netcup itself says should be added like this: https://www.netcup-wiki.de/wiki/Zus%C3%A4tzliche_IP_Adresse_konfigurieren