No network access in containers

pawel221

New Member
Dec 31, 2023
2
0
1
Hi, i have problem with my containers, i think i have tried everything.
I'm trying to ping my router from container, ping google dns's and nothing working. I can ping only other container.
This is my network setup.
Proxmox:
Code:
auto lo
iface lo inet loopback

iface enp1s0 inet manual

auto enp2s0
iface enp2s0 inet manual
        post-up /usr/sbin/ethtool -s enp2s0 wol g
        post-down /usr/sbin/ethtool -s enp2s0 wol g

auto vmbr0
iface vmbr0 inet static
        address 192.168.0.11/24
        gateway 192.168.0.1
        bridge-ports enp2s0
        bridge-stp off
        bridge-fd 0
        post-up iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o enp2s0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o enp2s0 -j MASQUERADE

Container1:
Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Container2:
Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 192.168.0.122/24
        gateway 192.168.0.11
 
hi, you don't need to nat on vmbr0 - use vmbr0 without these lines:
Code:
post-up iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o enp2s0 -j MASQUERADE
        post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o enp2s0 -j MASQUERADE

and give container your router as gateway

Code:
auto eth0
iface eth0 inet static
        address 192.168.0.122/24
        gateway 192.168.0.1
 
Thank you, this configuration worked for me.
But every change in proxmox network I have to restart my containers, basically when I just restart networking without any changes in interfaces file I have to restart the container (restarting networking doesn't work) That's kinda weird for me, maybe that was my main problem.
Final configuration:

Proxmox:
Code:
auto lo
iface lo inet loopback
iface enp1s0 inet manual

auto enp2s0
iface enp2s0 inet manual

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

Container:
Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 192.168.0.122/24
        gateway 192.168.0.1