How to get internet working on VM's?

Dec 23, 2021
3
0
6
23
Hi, I'm hosting Proxmox at Hetzner, which gives me a Proxmox instance behind a public IP. I managed to get proxmox to have an internet connection with the following /etc/network/interfaces config. And vmbr1 and the #nat is my attempt to get it to work for VM's.


Code:
auto lo
iface lo inet loopback

iface ens3 inet manual

iface enp0s31f6 inet manual

auto vmbr0
iface vmbr0 inet static
        address <<publicIPV4>>
        gateway <<publicIPV4gateway>>
        bridge-ports enp0s31f6
        bridge-stp off
        bridge-fd 0

auto vmbr1
iface vmbr1 inet static
        address 192.168.10.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

#NAT
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.10.0/24' -o vmbr0 -j MASQUERADE
post-down iptables -t nat -D POSTROUTING -s '192.168.10.0/24' -o vmbr0 -j MASQUERADE

But I'm at a loss on how to get my VM's and LXC's to get an internet connection. I'm not much of a Linux man when it comes to networking. My end goal is hosting websites on the LXC's and maybe the VM's. So they'd have to share the same public IP my Proxmox host has. I know how to set it up in Nginx once I have a public IP for my containers/vm's so any help with getting that would be appreciated.
 
Last edited:
Where it says "bridge-ports enp0s31f6" you seem to have a configuration error. It should match one of the iface settings. So, either "iface ens3 inet manual" is wrong (the ens3 part) or "bridge-ports enp0s31f6" is wrong (the enp0s31f6 part).

You are referencing two different network interfaces in these two strings, and they need to match. Perform an "ip a" on the command line or from the shell in your Proxmox web interface and see what the correct id for the NIC is. Then change one of these settings in /etc/network/interfaces
 
Where it says "bridge-ports enp0s31f6" you seem to have a configuration error. It should match one of the iface settings. So, either "iface ens3 inet manual" is wrong (the ens3 part) or "bridge-ports enp0s31f6" is wrong (the enp0s31f6 part).

You are referencing two different network interfaces in these two strings, and they need to match. Perform an "ip a" on the command line or from the shell in your Proxmox web interface and see what the correct id for the NIC is. Then change one of these settings in /etc/network/interfaces
Are you sure that part is wrong? Because all the hetzner related videos are telling me to use the interface that has the pub IP in the rescue image, which is enp0s31f6

ip a in the Hetzner shell:
Code:
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 noprefixroute
       valid_lft forever preferred_lft forever
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master vmbr0 state UP group default qlen 1000
    link/ether 90:1b:0e:da:c9:c5 brd ff:ff:ff:ff:ff:ff
3: vmbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 90:1b:0e:da:c9:c5 brd ff:ff:ff:ff:ff:ff
    inet <<publicIPV4>> scope global vmbr0
       valid_lft forever preferred_lft forever
    inet6 <<publicIPV6>> scope link
       valid_lft forever preferred_lft forever
29: vmbr1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether ee:a8:42:77:0c:48 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.1/24 scope global vmbr1
       valid_lft forever preferred_lft forever
    inet6 <<publicIPV6 for whatever reason??>> scope link
       valid_lft forever preferred_lft forever
 
Last edited:

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!