LXC container - Ubuntu22.04 and UP no longer have LAN connetion

First of First hello.
I am not very active user here as i am not very good with linux and i stumble across problem that i cannot find online.
I am user of Turris Omnia 2GB with USB3 drive for LXC that was running Pihole filter on Ubuntu 20.
Yesterday Turris start to “lag” on loading websites so i turn it off and scan USB3 drive for wear and find that flashdrive had many dead sectors so i replaced it.
Sadly the volume image from USB that i have as “backup” did not work i must start over again configure LXC Ubuntu with PI hole


First i noticed Ubuntu20 is no longer option for LXC container only u22.04-u23.04-u23.10.
I did install 22.04 (supported by pi-hole) and even 23.10 but both have same problem…
Upon “lxc-attach -n ubuntu1” and trying “nslookup github.com” the container have no connection.

;; communications error to ::1#53: connection refused
;; communications error to 127.0.0.1#53: connection refused
;; no servers could be reached

“ip a” tell me i have none IPv4 address on eth0.

Without connection i cannot install PI-hole.
Very little info from web that tell me something about not generated/created “netplan” and also that Ubuntu 22+ have problem with “legacy iptables” like = “# Warning: iptables-legacy tables present”

So i am stuck with Ubuntu as Pi hole install script support this OS and i did not find LXC Debian (armv7l) for my Turris

Yes i also did search this forum, and i did not find this problem.
Thank you for any reply

Remove package cloud-init and restart container

If you want Debian use this repo:

Thank you for reply
By removing cloud-init package and container restart = Turris no longer see and index LXC container with IP in client list.
nslookup command run inside Ubuntu LXC container bring 4 lines of comunication error instead of 3.
This give me feels that cloud package was doing something and by removing it render Ubuntu total invisible to Turris…

Looks like Ubuntu is no longer useable…
Thank you for mirror link i try to run different OS

You didnt provide any error message nor logs so I based on this that worked in the past:

Maybe you didnt wait long enough for the container to get IP or you could force it with dhclient. Just guesses here

Thank you for reply
Well removing that package Turris totally lost all LAN connection with LXC container.
I am open to any suggestion that can point me to right direction.

I did same command setup as i done with LXC Ubuntu 20 long ago and after USB flash fail i reverted my changes to default (before i install Pi-Hole) as if not revert some settings i will have no connection.

I have feel my problem resides inside that more recent Ubuntu 22 as if i got hands on that “older version” (Ubuntu 20) it will work out of box.
Yes i also find some not clear topics about Ubuntu 22 “netplan failure” and i must create some YAML file and reset some manager.
Sadly none of those things work that is why i search more skilled people that maybe had same problem with LXC container using Ubuntu 22+
It is quite frustrating that i just install the U22 LXC container and it is broken while i done same setup like with Ubuntu20. I know 20----22 is major leap but something has changed that render it broken.

I reinstall the new container with u22 and Turris give it IP address.
Doing “lxc-attach -n ubuntu2” and “nslookup github.com” just give me 3 errors as my 1 post.
sending “ip a” tell me LXC ubuntu22 have no ip4 address while Turris see the LXC container and assign IP as like new PC.

regards

Trying that alternate repo you suggest and i install (debian sid) (default) (armv7l) to new LXC container.
Upon “lxc-attach -n debsid” and trying apt-get install htop the LAN is working fine and installation success
Turris see the debsid LXC container and LXC container upon “ip a” show same IP as Turris assign.
I can install packages and install pi hole.
The problem is Ubuntu22+

The problem is probably the official Turris LXC container repository. The network was not configured for any container that I tried in the official repository. The containers in the alternative repo that I tried all had the network configured.

You might want to read the thread referenced above.

Thanky you for reply.
While i solved my problem by using different OS (Debian) and using different LXC repository, i am still curious why U22+ just not work.

—For future failures when even U22-24 OR that second repository no longer exist.

I did read referenced topic and while it say that by removing cloud-init from the container fix the problem, it did not fix it in my scenario.

My search say very little something about

  1. netplan failure
  2. legacy iptables problem

Again thank you for reply and helpfull information :slight_smile:

Hi,

personally I am using Arch container (with Adguard Home) and no problems here, network works “out-of-the-box” but I will look closer to the Ubuntu, because, when I tested I got the same issue as you mentioned above.
We are using official containers from Ubuntu repo → Ubuntu Cloud Images

As workaround for Ubuntu I can only recommend for now this simple script:

#!/bin/bash
#
ip link set eth0 up
ip addr add IP_ADDR_OF_CONT dev eth0
ip route add IP_OF_DNS/GATEWAY dev eth0
ip route add IP_ADDR_SPACE/24 via IP_OF_DNS/GATEWAY
ip route add default via IP_OF_DNS/GATEWAY
resolvectl dns eth0 IP_OF_DNS/GATEWAY

And add it into cron after restart with some delay. (10 - 15 sec.)

for example:
container ip - 10.0.0.138
Main router ip - 10.0.0.1

ip link set eth0 up
ip addr add 10.0.0.138 dev eth0
ip route add 10.0.0.1 dev eth0
ip route add 10.0.0.0/24 via 10.0.0.1
ip route add default via 10.0.0.1
resolvectl dns eth0 10.0.0.1

No the best solution, but it should work.

So, after short discussion with @miska, one of the good way how to run ubuntu container with functional network is to use systemd network.

Here is the guidline:
https://www.linode.com/docs/products/compute/compute-instances/guides/systemd-networkd/

Short manual:

Assume, that name of ethernet adapter is eth0 (usual case).

  1. Create file, for example: “05-eth0.network” under: /etc/systemd/network/
  2. Then add this as “the minimum”:
[Match]
Name=eth0

[Network]
DHCP=yes

Save it and call command: “systemctl restart systemd-networkd”

In few seconds your container should have an connection.
After the restart of container, the connection is established again after few seconds.

I tried it for all Ubuntu distros what we offer in LXC and it should be functional.

Reason why this is necessary under “Ubuntu” distros is, that we moved from linuxcontainers (where ubuntu images are not available anymore) to official site from Ubuntu.

Hope this help. :slight_smile:

2 Likes

Thank you for reply and guide for non very linux people. I was curious how to solve this in future USB drive failures.
Thank you

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.