Use full subnet in one LXC

Kopf02

New Member
Jul 25, 2020
2
0
1
23
Hey,

So I'm mostly into Networking at Hetzner now, but now I have a "problem".
I have a new /28 subnet which gets routed by Hetzner to my main IP which is assigned to vmbr0.
Now instead of assigning the first IP to the host and than route each ip the the lxc I instead simply want to route the hole subnet to ONE LXC.
(As a background Information: I need this to do outgoing load balancing with squid to have multiple different ipv4 adresses)

Is there a way to do this? Or do I realy still have to assign one IP to the Host and then bring up each ip from inside the LXC?
 
iptables is your friend, enable ipv4 forwarding and set a nat rule to forward the /28 subnet to your lxc
 
You can also just route the subnet. This approach - in my opinion the easiest - is not well known and I don't know why. This is networking 1o1:

Just use one IP from your subnet on your PVE host as router and use all other IPs on your LX(C) containers and use the router IP as your gateway. You just need to enable ip forwarding on your PVE host and you have a simple, state-of-the-art 1981 IP routing.
 
You can also just route the subnet. This approach - in my opinion the easiest - is not well known and I don't know why. This is networking 1o1:

Just use one IP from your subnet on your PVE host as router and use all other IPs on your LX(C) containers and use the router IP as your gateway. You just need to enable ip forwarding on your PVE host and you have a simple, state-of-the-art 1981 IP routing.

I'm very familiar with this method and used it a lot. But I asked if there is a way to get the hole subnet to the VM without give the PVE host a gateway ip of that subnet.

iptables is your friend, enable ipv4 forwarding and set a nat rule to forward the /28 subnet to your lxc

If I understand it right: Give the LXC an internal Bridge only IP and than forward the hole subnet to the internal IP of the LXC? After that bring up all ips on the guest by using iptables and set the gateway to the internal IP of the PVE?
Will try this later. Thanks.
 
Hello,

you can try it like described here
https://dominicpratt.de/hetzner-proxmox-network-configuration/

this also works with a subnet instead of single IPs..

in the LXC Container just configure it like this

Code:
auto eth0
iface eth0 inet static
        address 138.201.203.49
        netmask 255.255.255.255
        pointopoint 138.201.203.16
        gateway 138.201.203.16
        up ip addr add 138.201.203.50/32 dev eth0
        up ip addr add 138.201.203.51/32 dev eth0
        ....
        down ip addr del 138.201.203.50/32 dev eth0
        down ip addr del 138.201.203.51/32 dev eth0
        ....
 

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!