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.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!