[SOLVED] Second public IP for VM

BlinTUZ

Member
Nov 3, 2022
17
1
8
Hello, dear friends.
I have a dedicated server at GTHost with Proxmox 8.4.9 installed. The network settings are shown in the picture^: 1755172266458.png

The virtual machines use the local network and access the internet through the IP 123.123.123.123. Proxmox itself is accessible via the public IP 123.123.123.123:8006.

I am planning to set up a new VM for a mail server, and I want it to use the same local network as the other VMs, but go out to the internet through a different public IP. For this purpose, I ordered an additional public IP 123.123.123.222.

Now I’m not sure how to configure it correctly so that the 123.123.123.222 IP is bound to the mail server VM. And I would be happy to get some help from specialist in this side.

Code:
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

iface lo inet6 loopback

auto eno1
iface eno1 inet static
        address 123.123.123.123/24
        gateway 123.123.123.1
        up route add -net 123.123.123.0 netmask 255.255.255.0 gw 123.123.123.1 dev eno1
# route 123.123.123.0.24 via 123.123.123.1

iface eth0 inet manual

iface eth1 inet manual

iface eno2 inet manual

auto vmbr1
iface vmbr1 inet static
        address 10.30.10.254/24
        bridge-ports none
        bridge-stp off
        bridge-fd 0
#LAN int
 
Add eno1 to a bridge and configure IP / gateway there (not need to add the route via the up command unless the gateway is outside of the subnet of the IP). Then give the VM a network device on the new bridge using eno1 and configure the IP / gateway inside the VM.
 
  • Like
Reactions: BlinTUZ
Add eno1 to a bridge and configure IP / gateway there (not need to add the route via the up command unless the gateway is outside of the subnet of the IP). Then give the VM a network device on the new bridge using eno1 and configure the IP / gateway inside the VM.
thanks for your reply

resolved by SNAT:
sudo iptables -t nat -I POSTROUTING 1 -s 10.30.10.20 -j SNAT --to-source 123.123.123.222

now vm 10.30.10.20 goes to internet with 123.123.123.222