No internet when using DHCP in LXC containers

radostin_t

New Member
Mar 9, 2024
2
1
1
Hey everyoone! I have an issue where any LXC container I create has no internet access. I also tried running some of tteck's proxmox scripts and end to an 'IPv4 Internet not connected' error. Proxmox itself has internet access and I can ping google(or any other domain from it).

If I manually set up static IP and gateway for the container network setting, internet magically appears, but when using DHCP it does not work.
If I run dhclient -v eth0 in the container it manages to obtain IP address and everything works until the next reboot, where it again does not obtain IP from DHCP.

This is the proxmox network config:
auto lo
iface lo inet loopback

iface enp2s0 inet manual

auto vmbr0
iface vmbr0 inet static
address 192.168.100.14/24
gateway 192.168.100.1
bridge-ports enp2s0
bridge-stp off
bridge-fd 0

iface wlo1 inet manual

source /etc/network/interfaces.d/*

The LXC config:
arch: amd64
cores: 4
hostname: CT101
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=BC:24:11:F3:0B:5B,ip=dhcp,type=veth
ostype: ubuntu
rootfs: local-zfs:subvol-101-disk-0,size=8G
swap: 512

And the content of /etc/systemd/network/eth0.network:
[Match]
Name = eth0

[Network]
Description = Interface eth0 autoconfigured by PVE
DHCP = ipv4
IPv6AcceptRA = false

I've tried the following:
LXC + DHCP = No Internet (internet appears only after manually running dhclient -v eth0 after every reboot)
LXC + Static IP = Works fine
VM + DHCP = Works Fine
VM + Static IP = Works Fine

This is what I get from running ip a in the LXC:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether bc:24:11:f3:0b:5b brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::be24:11ff:fef3:b5b/64 scope link
valid_lft forever preferred_lft forever

I suspect that also this is the reason tteck's scripts (Homer dashboard and Jellyfin) I tried running fail with No Network error.
 
I also have this issue, but only on my VLANs. Essentially any LXC I create - if I use DHCP, I get an IP but not internet. If I manually dictate gateway and IP, I get internet.

Is this a VLAN issue? Because the Proxmox Host can only have one gateway, and my VLAN gateway is different than the Proxmox host gateway, I wonder if something is going wrong there. The weird thing is that VMs still work fine. So I don't know what's going on there.

Maybe VMs - because they don't share the kernel - they have to get their gateway reassigned, and once it gets reassigned it identifies/infers the proper gateway whereas LXCs on a VLAN share the kernel and make certain assumptions about the network that are not correct? I guess I'm just confused about why VMs using DHCP on second NIC/different subnet are fine when LXCs using DHCP on that same (different) subnet do not work (without manually entering the proper gateway and an available IP).