Answer the question
In order to leave comments, you need to log in
How to set up SNAT for 4 addresses in iptables in Proxmox for a virtual machine with iredmail?
A server is rented from Hetzner, Proxmox is deployed on it with 5 white IPs (1.2.3.1 - 1.2.3.5).
By default, 1.2.3.5 is used to control the hypervisor itself, internal 192.168.0.1 for NAT of all virtual machines.
Iredmail is installed on a virtual machine with Ubuntu 18.04, 5 interfaces are configured on it via netplan (192.168.0.101 - 192.168.0.105). Interface 192.168.0.105 main with gateway 192.168.0.1. 192.168.0.101 - 192.168.0.104 are configured in iredmail for 4 domains.
In Proxmox, the following rules are configured for mail:
-A PREROUTING -d 1.2.3.1/32 -p tcp -m multiport --dports 25,587,110,995,143,993 -j DNAT --to-destination 192.168.0.101
-A PREROUTING -d 1.2.3.2/32 -p tcp -m multiport --dports 25,587,110,995,143,993 -j DNAT --to-destination 192.168.0.102
-A PREROUTING -d 1.2.3.3/32 -p tcp -m multiport --dports 25,587,110,995,143,993 -j DNAT --to-destination 192.168.0.103
-A PREROUTING -d 1.2.3.4/32 -p tcp -m multiport --dports 25,587,110,995,143,993 -j DNAT --to-destination 192.168.0.104
-A POSTROUTING -s 192.168.0.101/32 -j SNAT --to-source 1.2.3.1
-A POSTROUTING -s 192.168.0.102/32 -j SNAT --to-source 1.2.3.2
-A POSTROUTING -s 192.168.0.103/32 -j SNAT --to-source 1.2.3.3
-A POSTROUTING -s 192.168.0.104/32 -j SNAT --to-source 1.2.3.4
-A POSTROUTING -s 192.168.0.0/24 -o vmbr0 -j MASQUERADE
-A POSTROUTING -s 192.168.0.104/32 -j SNAT --to-source 1.2.3.4
put first in the chain, then the rest of the rules with SNAT stop working. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question