Proxmox and LXC with separate public ip addresses

AxAn

Member
Jan 15, 2020
25
5
8
44
I'm trying to setup Proxmox, with a container (LXC) using 2 public ip's on a cloud-based server. One ip for Proxmox and one ip for the container.
Proxmox is working fine but I can't get the container to access the internet.
I have tried many things but this is my current setup:

Code:
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto ens1
iface ens1 inet static
        address 111.111.111.7/24
        gateway 111.111.111.1

auto vmbr0
iface vmbr0 inet static
        address 111.111.111.218/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

In the container .conf file:
Code:
net0: name=eth0,bridge=vmbr0,gw=111.111.111.7,hwaddr=xxxxxxxx,ip=111.111.111.218/24,type=veth

111.111.111.7 is Proxmox.
111.111.111.128 is what I'm trying to get to work with the container.

Can someone see what the problem is?

The above configuration is based on "Routed Configuration" here: https://pve.proxmox.com/wiki/Network_Configuration
Before that I tried this (which doesn't work either):

Code:
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto ens1
iface ens1 inet manual

auto vmbr0
iface vmbr0 inet static
        address 111.111.111.7/24
        gateway 111.111.111.1
        bridge-ports ens1
        bridge-stp off
        bridge-fd 0

Container:
Code:
net0: name=eth0,bridge=vmbr0,hwaddr=2A:BD:E2:B6:7C:CE,ip=111.111.111.218/24,type=veth
 
Any suggestions what to do to get this working?
I'm starting to think that maybe the provider is blocking something since nothing seem to work.
 
I found a solution. I thought that this could simply be done using the Proxmox GUI but I was wrong.

Note about the configs below:
Code:
111.111.111.1 => Gateway
111.111.111.7 => Proxmox public ip
111.111.111.219 => LXC container public ip

To get this solution to work:

On Proxmox (host):
Code:
nano /etc/network/interfaces

auto ens1
iface ens1 inet static
   address 111.111.111.7
   netmask 255.255.255.255
   pointopoint 111.111.111.1
   gateway 111.111.111.1

auto vmbr0
iface vmbr0 inet static
   address 111.111.111.7
   netmask 255.255.255.255
   bridge_ports none
   bridge_stp off
   bridge_fd 0
   pre-up brctl addbr vmbr0
   up ip route add 111.111.111.219/32 dev vmbr0
   down ip route del 111.111.111.219/32 dev vmbr0

You also need to enable IPv4/IPv6 forwarding:
Code:
sudo nano /etc/sysctl.conf
net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

After creating the LXC container go it it's Network tab in Proxmox and add an interface:
Name: eth0
Bridge: vmbr0
IPv4 : static
IPv6 : static

Then inside the LXC container (my example is a Debian 11 container):

Code:
nano /etc/network/interfaces

auto eth0
iface eth0 inet static
   address 111.111.111.219
   netmask 255.255.255.255
   pointopoint 111.111.111.7
   gateway 111.111.111.7

Restart everything and it should work.

I got info from here: https://serverfault.com/questions/1...vm-from-outside-not-reachable/1121266#1121266
 
Last edited:
On Proxmox (host):
Code:
nano /etc/network/interfaces

auto ens1
iface ens1 inet static
   address 111.111.111.7
   netmask 255.255.255.255
   pointopoint 111.111.111.1
   gateway 111.111.111.1

auto vmbr0
iface vmbr0 inet static
   address 111.111.111.7
   netmask 255.255.255.255
   bridge_ports none
   bridge_stp off
   bridge_fd 0
   pre-up brctl addbr vmbr0
   up ip route add 111.111.111.219/32 dev vmbr0
   down ip route del 111.111.111.219/32 dev vmbr0

Could someone explain how/why this works? I thought it should not be allowed to assign the same IP address to 2 different interface
 
I have the exact same use case and this fixed the connection but, while I can ping or ssh into the lxc, it cannot connect via http.
This means that apt is not working so cannot really use it.
DNS from the container works ok.
 

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!