Access hosts external IP from NATed container

limone

Well-Known Member
Aug 1, 2017
89
8
48
29
Hi,

I always worked around this problem, but now I'm just tired of it and want to do it right.

My containers have IP and internet connection like this: https://pve.proxmox.com/wiki/Network_Model#Masquerading_.28NAT.29_with_iptables

Lets say 10.10.10.100 is a mail server, and 10.10.10.200 is a client wanting to connect to this mailserver.
The mailserver got the domain "mail.example.org" pointing to the external IP and port forwardings from the host:
-A PREROUTING -i ens3 -p tcp -m tcp --dport 587 -j DNAT --to-destination 10.10.10.100:587
-A PREROUTING -i ens3 -p tcp -m tcp --dport 993 -j DNAT --to-destination 10.10.10.100:993
-A PREROUTING -i ens3 -p tcp -m tcp --dport 25 -j DNAT --to-destination 10.10.10.100:25

Problem now: client 10.10.10.200 can't connect to the external Ip which is resolved from the hostname mail.example.org, only to the internal IP, which will get you a certificate error.
You could edit the /etc/hosts file or setup a local dns, but that are just workarounds I don't want to use.

Is there a possibility to set iptable rules to enable NATed containers to talk with the external IP of the host node?


//////////////////

user@200:~# telnet mail.example.org 587
Trying 37.0.0.0..
telnet: Unable to connect to remote host: Connection refused

user@200:~# telnet 10.10.10.10 587
Trying 10.10.10.100...
Connected to 10.10.10.100.
Escape character is '^]'.
220 mail.example.org ESMTP Postfix
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, 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 yours easily in our online shop.

Buy now!