[SOLVED] Set route for private network on vm startup

Discussion in 'Proxmox VE: Networking and Firewall' started by exii88, Apr 12, 2016.

  1. exii88

    exii88 New Member
    Proxmox VE Subscriber

    Joined:
    Apr 11, 2016
    Messages:
    4
    Likes Received:
    0
    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
     
    #1 exii88, Apr 12, 2016
    Last edited: Apr 13, 2016
  2. wbumiller

    wbumiller Proxmox Staff Member
    Staff Member

    Joined:
    Jun 23, 2015
    Messages:
    631
    Likes Received:
    73
    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)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. exii88

    exii88 New Member
    Proxmox VE Subscriber

    Joined:
    Apr 11, 2016
    Messages:
    4
    Likes Received:
    0
    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.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice