Multiple IP Adresses on one interface on-the-fly change

Timon Michel

Member
Nov 29, 2017
8
1
23
25
Dear Community of Proxmox,

This is an english translation to my initial thread in the german forum.
I'm sorry if i didn't translate right - don't hesitate to ask if you don't understand something.

I've got multiple subnets bound to one interface.
That's my current /etc/network/interfaces:
Code:
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback
iface lo inet6 loopback

auto eth0
iface eth0 inet static
  address 94.***.***.169
  netmask 255.255.255.192
  gateway 94.***.***.129
  up route add -net 94.***.***.128 netmask 255.255.255.192 gw 94.***.***.129 dev eth0

auto vmbr0
iface vmbr0 inet static
    address 94.***.***.169
    netmask 255.255.255.255
    bridge_ports none
    bridge_stp off
    bridge_fd 0
    bridge_maxwait 0
    pre-up brctl addbr vmbr0
    up ip route add 88.***.***.121/32 dev vmbr0
    up ip route add 88.***.***.122/32 dev vmbr0
    up ip route add 88.***.***.123/32 dev vmbr0
    up ip route add 88.***.***.124/32 dev vmbr0
    up ip route add 88.***.***.125/32 dev vmbr0
    up ip route add 88.***.***.126/32 dev vmbr0
    up ip route add 88.***.***.127/32 dev vmbr0
    up ip route add 94.***.***.97/32 dev vmbr0

auto vmbr1
iface vmbr1 inet static
    address 192.168.178.1
    netmask 255.255.255.0
    bridge_ports none
    bridge_stp off
    bridge_fd 0
    post-up iptables -t nat -A POSTROUTING -s '192.168.178.0/24' -o eth0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s '192.168.178.0/24' -o eth0 -j MASQUERADE

Legend:
94.***.***.169 - The Address of my host (PVE 4.4)
88.***.***.120/29 - Additional subnet I (.121-.127 usable)
94.***.***.96/28 - Additional subnet II (.97-.110 usable)
vmbr0 - The bridge, connected to eth0
vmbr1 - I used it for internal traffic between the VM's, i actually don't use it anymore

All VM's (lxc) have their IP Address with a /32 Mask and the Host (94.***.***.169) as Gateway.

So far everything worked out well.

About half a week ago i began adding 94.***.***.97 in /etc/network/interfaces.
But it didn't quite work like i expected:
As i restarted the networking service after adding the Address i couldn't reach any VM behind that IP.
After a little bit of trial and error - it worked. But then all my other VM's got unreachable, so i had to restart each of them.

It should be possible to add new ip addresses on the fly, right?
Am i doing something wrong?
Maybe it's a completely crappy configuration, if it is please explain why...

Happy to hear from you guys :)

~Timon Michel
 
this works? i highly doubt that :)

you cannto give eth0 AND vmbr0 the same ip that wont work ever.

i assume you wanna go for a simple bridge and allow all vms on vmbr0 to have direct access to public ips
- first your provider need to support that and you need to usually configure the mac of each vm somewhere at your hosters portal
- second eth0 shall have no ip
-leave config for vmbr0 but change --- bridge_ports eth0
-get rid of adding ips to that bridge, you wont need em there you config them in your vm

third why does vmbr1 has masquerading?
do you have additional vms that have only a private ip?
besides do not use maquerade but SNAT

both are almsot the same but masquerade has much more overhead.
it needs to check the target ip at every paket as its designed for dynamic ip.
snat will be set a fixed ip and wont need to check anything
 

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!