2 minutes reading time (303 words)

OPNsense NAT port forward rules with NAT reflection (Loopback/Hairpin)

How to configure OPNsense firewall NAT port forward rules with NAT reflection (Loopback/Hairpinning) for web servers 

What is NAT reflection, and why would you enable it?

NAT reflection allows clients inside your network to access web servers using the servers external WAN IP address. NAT reflection redirects client requests to the web server's internal IP address.

This means that firewall rules meant for external traffic are not applied and you don't have to manage internal DNS entries for your web server.

OPNsense port forward rules with NAT reflection

Create inbound firewall rules for web server allowing HTTP port 80 and HTTPS port 443 with NAT reflection/hairpinning

Firewall - NAT - Port Forward - Add

Example: OPNsense NAT port foward rule for HTTP

Interface: WAN
TCP/IP version: IPv4
Protocol: TCP
Destination: WAN address
Destination port range: HTTP
Redirect target IP: single host/network IP 192.168.1.50
Redirect target port: HTTP
Description: web server
NAT reflection: Enable

Save and apply changes

Example: OPNsense NAT port foward rule for HTTPS

Repeat the steps to create a port forwarding rule for HTTPS

Interface: WAN
TCP/IP version: IPv4
Protocol: TCP
Destination: WAN address
Destination port range: HTTPS
Redirect target IP: single host/network IP 192.168.1.50
Redirect target port: HTTPS
Description: web server
NAT reflection: Enable

Save and apply changes

Reference:

OPNsense docs - Network Address Translation
https://docs.opnsense.org/manual/nat.html

Related Posts

 

Comments 3

Guest - d on Tuesday, 16 May 2023 22:07

need to enable lan interface as well.

need to enable lan interface as well.
Guest - EdRetroTech on Friday, 08 September 2023 22:29

Excellent tutorial! I was having a hard time figuring out how to use that address inside my network as well as outside using NGINX. I managed to access it from outside, but OPNSense was blocking using the same address when inside my network. NAT Reflection set to "Enable" instead of Default was the issue! Thanks for your help.

Excellent tutorial! I was having a hard time figuring out how to use that address inside my network as well as outside using NGINX. I managed to access it from outside, but OPNSense was blocking using the same address when inside my network. NAT Reflection set to "Enable" instead of Default was the issue! Thanks for your help.
TechLabs on Monday, 11 September 2023 19:16

Thanks for taking the time to comment. I’m glad you found the guide helpful!

Thanks for taking the time to comment. I’m glad you found the guide helpful!
Already Registered? Login Here
Saturday, 23 September 2023
You can help support this website by buying me a coffee!
Buy Me A Coffee