[SOLVED] Set route for private network on vm startup

Apr 11, 2016
4
0
1
Hello,

i want a setup like the attached picture.

Unbenannt.png

The most of the setup works.

When i connect from any application server to the database server (this server is only private available) the application server has not the private ip but rather the public ip.
I get it working when i set an route for the private network subnet go over the second network interface (private network interface).
My problem is that i try to create an persistent route for the server. It doesn't works.

The interface config for one of the vms:
Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 138.***.***.***
        netmask 255.255.255.255
        post-up ip route add 138.***.***.*** dev eth0
        post-up ip route add default via 138.***.***.***
        pre-down ip route del default via 138.***.***.***
        pre-down ip route del 138.***.***.*** dev eth0

iface eth0 inet6 static

auto eth1
iface eth1 inet static
        address 192.168.99.101
        netmask 255.255.255.255
        post-up ip route add 192.168.99.1 dev eth1
        post-up ip route add default via 192.168.99.1
        pre-down ip route del default via 192.168.99.1
        pre-down ip route del 192.168.99.1 dev eth1
        up route add -net 192.168.99.0 netmask 255.255.255.0 gw 192.168.99.1 dev eth1
When i manually execute the last line it works. But not automatically on startup.

Thanks for help

Best regards,
exii88
 
Last edited:

wbumiller

Proxmox Staff Member
Staff member
Jun 23, 2015
645
84
28
Do you see an error if you bring the interface down and up from the console?
Code:
# ifdown eth1
# ifup eth1
Maybe `post-up` would be better timed for this? After all, the other routes seem to work and they're also in post-up lines.

(And why is your network bigger than the internet :p)
 
Apr 11, 2016
4
0
1
If found the problem...

I had the wrong prefix for the ip address in proxmox.

I set i like 192.168.99.101/32. But i must set it to 192.168.99.101/24 and then the vm create the right route by default.

I'm so stupid :D But thanks for the help wbumiller.
 

Mustafa YILDIZ

New Member
Dec 1, 2018
5
0
1
39
Hi,
I bought a Server from Hetzner recently. I added 2 Failover IPs to it. I'm testing on it everything now. I want to add some VM over Failover IPs. I have only one NIC. How can i do it?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE 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 your own in 60 seconds.

Buy now!