How to setup Loopback Port Forwarding on OpenWRT Kamikaze


If you use OpenWRT and have a server on your LAN, you probably want to setup loopback forwarding. Here's how to do it.

These instructions came from this page. I simply want to explain them a bit more, and confirm that these instructions for loopback forwarding work on OpenWRT Kamikaze.

iptables -t nat -A prerouting_rule -d -p tcp --dport 80 -j DNAT --to
iptables -A forwarding_rule -p tcp --dport 80 -d -j ACCEPT
iptables -t nat -A postrouting_rule -s -p tcp --dport 80 -d -j MASQUERADE

  • Replace with the public IP address given by your ISP.
  • Replace all occurrences of with your server's LAN IP.
  • Replace with CIDR notation for your LAN.
  • Replace 80 with the port you want to loopback forward. 80 is the typical webserver port, 443 is SSL webserver. You probably want to forward both ports, so make a copy of these three lines and change 80 to 443 on the second set.

Put these lines in /etc/firewall.user and restart your firewall by running /etc/init.d/firewall restart at the command line.

You must also have already set up your regular port forwards. You can do this through the Kamikaze web interface.


To enable NAT loopback for all ports just do this:

iptables -t nat -A prerouting_rule -d -p tcp -j DNAT --to
iptables -A forwarding_rule -p tcp -d -j ACCEPT
iptables -t nat -A postrouting_rule -s -p tcp -d -j MASQUERADE