KVM using all subnet IP addresses

moose

Member
Nov 19, 2017
19
11
23
Bavarian Alps
Hi folks,

a found a nice article in Hetzner's Wiki which describes how to use all (!) IP addresses of a given subnet for KVM VMs. I.e. not (x - 3) subnet addresses because no need of dedicated addresses for bc, gw (vmbrX) and net.

What do you think of this solution described on Hetzner's Wiki? Will it work with PVE 6? Did anybody try it? What are your experiences? Would it work with LXC also?

Many thanks in advance,

moose

PS Sorry, I'm not allowed to post links to external URLs. Therefor I'll post the ULR of the mentioned article in plain text: https : // wiki.hetzner.de/index.php/KVM_mit_Nutzung_aller_IPs_aus_Subnetz/en
 

First of all thanks for your reply, Alwin!

I read this article too before writing my first post in this thread. One time, two times, three times and got confused more and more ...

Well, I found this article confusing because the author mixes bridging (switching, Layer 2) and routing (Layer 3), singe IPs /w or /wo MAC assigned adresses and subnets. And then put all the stuff together in one and only interface conf file which makes it heavy to understand it for me.

Therefor I've been looking for a more clear and structured single solution description and found the article I mentioned in my first post.

Anyway, thanks for your hint, Alwin. Have a nice weekend!

Greetinx

moose
 
Last edited:
Hi folks,

after some more reading and testing I've got what I've been looking for - a routing solution which allows using all IP addresses contained in a subnet. I'd like to share my solution - maybe anyone else will need it ;)

First, I'll describe subnet routing (you know, you'll "lose" 3 ip addresses: net, bc, gw):

/etc/network/interfaces on PVE host:


# Loopback device:
auto lo
iface lo inet loopback

# device: enp4s0
auto enp4s0
iface enp4s0 inet static

address 1.2.3.112
netmask 255.255.255.255
pointopoint 1.2.3.97
gateway 1.2.3.97

# for subnet
auto vmbr0
iface vmbr0 inet static

address 4.5.6.110
netmask 255.255.255.248
bridge_ports none
bridge_stp off
bridge_fd 0

/etc/network/interfaces on PVE guest (VM):

# loopback device
auto lo
iface lo inet loopback

# device: ens18
auto ens18
iface ens18 inet static

address 4.5.6.105
netmask 255.255.255.248
gateway 4.5.6.110

Now I'll describe single ip routing (you wan't lose any ip address of a given subnet):


/etc/network/interfaces on PVE host:


# Loopback device:
auto lo
iface lo inet loopback

# device: enp4s0
auto enp4s0
iface enp4s0 inet static
address 1.2.3.112
netmask 255.255.255.255
pointopoint 1.2.3.97
gateway 1.2.3.97

# for single IP addresses
auto vmbr0
iface vmbr0 inet static
address 1.2.3.112
netmask 255.255.255.255
bridge_ports none
bridge_stp off
bridge_fd 0
up ip route add 4.5.6.104/32 dev vmbr0
up ip route add 4.5.6.105/32 dev vmbr0
up ip route add 4.5.6.106/32 dev vmbr0
up ip route add 4.5.6.107/32 dev vmbr0
up ip route add 4.5.6.108/32 dev vmbr0
up ip route add 4.5.6.109/32 dev vmbr0
up ip route add 4.5.6.110/32 dev vmbr0
up ip route add 4.5.6.111/32 dev vmbr0

/etc/network/interfaces on PVE guest (VM):

# loopback device

auto lo
iface lo inet loopback

# device: ens18
auto ens18
iface ens18 inet static
address 4.5.6.105
netmask 255.255.255.255
pointopoint 1.2.3.112
gateway 1.2.3.112

Meanings in both examples (subnet routing and single ip routing):


PVE host IP address: 1.2.3.112
PVE host's net gw: 1.2.3.97

don't be confused about host's netmask /32

subnet: 4.5.6.104/29
subnet's IP addr used as gw: 4.5.6.110 (1st example only)
guest ip address: 4.5.6.105

Remarks: both examples have been test with PVE 6 and debian (10) buster on host and guest (VM).

Enjoy!

Greetinx

moose
 
Last edited:
  • Like
Reactions: Don Daniello

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!