OPNsense Forum

English Forums => General Discussion => Topic started by: crash on November 17, 2023, 05:32:31 PM

Title: using a VPS IP for mail locally hosted mail server.
Post by: crash on November 17, 2023, 05:32:31 PM
so here is my network:

(https://i.imgur.com/Gp6YXJB.png)

vps is running ubuntu server and I'm running ospf on all of the nodes.

What I want to do is to forward all traffic on specific ports to my mail local mail server which I have done by running this command on my vps:

iptables -t nat -A PREROUTING -i eth0 -p tcp -m multiport --dports 25,110,143,465,587,993,995,4190  -j DNAT --to-destination x.x.x.1

However I'm not sure how should I do the return path on opnsense so packets originating from x.x.x.1:(port range above) be sent out via vps's public ip.(z.z.z.z).

The best thing that I can think of is to set a second ip on my vps's wan interface (eth0) with a local ip (say 192.168.20.1/24) and set that IP as a gateway for specific traffic originating from x.x.x.1 but It doesn't work unfortunately .

do note I have put the gw on LAN reason being I want to to be independent of tunnel interfaces (so I can have one rule doing all the work).


any tips would be appreciated.