Author Topic: How to add NAT Loopback to a WHR-HP-G300N (and others)  (Read 2991 times)

brobin111

  • Calf
  • *
  • Posts: 14
How to add NAT Loopback to a WHR-HP-G300N (and others)
« on: February 03, 2014, 06:03:42 PM »
I recently upgraded to the "Pro" DD-WRT firmware for my WHR-HP-G300N that had stopped working properly.  The new firmware solved my problem and also allowed me to add NAT Loopback which enables me to use the external address to view my cameras on my tab or phone even when I'm home without having to enter the local addresses. After some quick searching on the web I found the following script which I'm sharing here. I take no credit for the work that others obviously smarter than me have done.

Here's what to do:

1. Highlight and copy these five lines:

insmod ipt_mark
insmod xt_mark
iptables -t mangle -A PREROUTING -i ! `get_wanface` -d `nvram get wan_ipaddr` -j MARK --set-mark 0xd001
iptables -t mangle -A PREROUTING -j CONNMARK --save-mark
iptables -t nat -A POSTROUTING -m mark --mark 0xd001 -j MASQUERADE


2. Open the DD-WRT web interface for your router and go to Administration:Commands and paste the above into the Commands Shell box then click the "Save Firewall" button.  Done!

For newer versions like 20180 that runs on my WZR-600DHP the following script can be used instead (same w/o 4th line above):

insmod ipt_mark
insmod xt_mark
iptables -t mangle -A PREROUTING -i ! `get_wanface` -d `nvram get wan_ipaddr` -j MARK --set-mark 0xd001
iptables -t nat -A POSTROUTING -m mark --mark 0xd001 -j MASQUERADE
« Last Edit: February 03, 2014, 06:10:56 PM by brobin111 »