Custom Port Forwarding

maximallist

New Member
Mar 5, 2024
5
0
1
Hello everyone!
Help me to configure port forwarding from WAN (IP 10.100.1.71) to Exchange (IP 192.168.1.71) using port 993 as an example.
Through ufw configured rule:
Code:
ufw allow 993/tcp
Then in the file /etc/ufw/before.rules, before the filter section I added:
Code:
*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -i ens224 -p tcp --dport 993 -j DNAT --to 192.168.1.71:993
COMMIT
Changed in /etc/default/ufw:
Code:
DEFAULT_FORWARD_POLICY="DROP"
to
Code:
DEFAULT_FORWARD_POLICY="ACCEPT"

Uncommented the line in /etc/ufw/before.rules:
Code:
net/ipv4/ip_forward=1
Restarted ufw.
Telnet connection to port 993 fails.
 
Last edited:
Hey,

I think you're missing a
Code:
-A POSTROUTING -j MASQUERADE
without it packets can't come back out.
 
after the changes now /etc/ufw/before.rules:
Code:
*nat
 :PREROUTING ACCEPT [0:0]
-A PREROUTING -i ens224 -p tcp --dport 993 -j DNAT --to-destination 192.168.1.71:993
-A POSTROUTING -s 192.168.1.71 -p tcp --dport 993 -o ens224 -j SNAT --to-source 10.100.1.71:993
COMMIT

but the port is still unavailable via telnet

Code:
netstat -pnltu
result (see attachment)
 

Attachments

  • netstat.png
    netstat.png
    62.1 KB · Views: 13
Greetings!
Yes, the problem is solved. I contacted a specialist who installed and configured the HAProxy service on PMG.
There are still problems:
1) automatic renewal of Let's Encrypt certificate on Exchange and PMG
2) ufw rules disappear after rebooting PMG
 

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!