OPNsense Forum

English Forums => General Discussion => Topic started by: srijan on August 27, 2016, 11:12:07 am

Title: [SOLVED] Redirection (Destination NAT/Port Forwarding) explanation
Post by: srijan on August 27, 2016, 11:12:07 am
Hello Everyone,

I need a bit of an explanation on how Port Forwarding works in Opnsense. I have a simple setup. One WAN (PPPoE) and one LAN and a server connected to LAN.

LAN Address is 172.16.1.1 and IP Address of Server is 172.16.1.80. Default Gateway on Server is set to 172.16.1.1.

I have created a Port Forwarding Rule on Opnsense, to allow traffic on the WAN interface on port 2226 to forward it to the server 172.16.1.80 on port 2224. These can be seen below:

rdr on pppoe0 inet proto tcp from any to X.X.X.X port 2226 -> 172.16.1.80 port 2224
# Reflection redirect
rdr on { em0 em3 enc0 } inet proto tcp from any to X.X.X.X port 2226 -> 172.16.1.80 port 2224
no nat on em0 proto tcp from em0 to 172.16.1.80 port 2224.

When i run a tcpdump on the pppoe interface. I can see the traffic as stated below:

08:14:11.753002 IP 1.39.86.152.32254 > X.X.X.X.2226
08:14:46.574063 IP 1.39.86.152.33519 > X.X.X.X.2226

Now when I run a tcpdump on the internal interface (em0) of Opnsense, I see traffic as below:

08:14:11.753157 IP 1.39.86.152.32254 > 172.16.1.80.2224
08:14:11.753768 IP 172.16.1.80.2224 > 1.39.86.152.32254

My question here is, if i have configured a port forwarding (rdr) rule, shouldn't I see the WAN IP of the Opnsense device when I run a tcpdump on the internal port (em0) of Opnsense.

The same problem I see when I run a tcpdump on the server as well. I am getting the public client IP address instead of the WAN IP Address of the Opnsense device.

Shouldn't I see X.X.X.X instead of the client IP of 1.39.86.152. Is this now how it is supposed to work. It would be great help if someone can explain me this.

Thanks and Regards,
-=Srijan Nandi
Title: Re: Redirection (Destination NAT/Port Forwarding) explanation
Post by: srijan on August 27, 2016, 06:57:30 pm
Opnsense is doing exactly what it is supposed to do.This is how it should work.

My bad. My networking fundamentals needed a little brush-up.

Thanks and Regards,
-=Srijan Nandi