S
S
Sergey Savostin2021-09-07 17:43:08
Network administration
Sergey Savostin, 2021-09-07 17:43:08

How to use another ip for VM in Proxmox?

There is Proxmox 6 on OVH.
Issued ip1 as primary and ip2 as "failover ip".
In /etc/network/interfaces:

auto lo
iface lo inet loopback
iface eno1 inet manual

auto vmbr0
iface vmbr0 inet static
        address [ip1]/24
        gateway [ip1.gateway]
        bridge-ports eno1
        bridge-stp off
        bridge-fd 0
        nameservers 1.1.1.1 8.8.8.8
auto vmbr1
iface vmbr1 inet static
        address 10.0.0.1/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up         iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE
pre-down        iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE

10.0.0.0/24 - subnet of virtual machines, they are connected to vmbr1.
Everything works fine, but virtual machines go to the Internet through ip1.
You need to leave ip1 as the main one, and connect all virtual machines via ip2.
Tried creating vmbr2 like
auto vmbr2
iface vmbr2 inet static
        address [ip2]/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0

and replace with
post-up         iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o vmbr2 -j MASQUERADE
pre-down        iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o vmbr2 -j MASQUERADE

But I can't specify [ip2.gateway] (proxmox swears that there is already a default gateway) and it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-09-07
@savostin

post-up         iptables -t nat -A POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE
pre-down        iptables -t nat -D POSTROUTING -s '10.0.0.0/24' -o vmbr0 -j MASQUERADE

Try to -j MASQUERADEsubstitute instead-j SNAT --to-source [ip2]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question