OpenWrt Forum Archive

Topic: (double)NAT access to modem

The content of this topic has been archived on 29 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi!

I have my Asus WL500G Deluxe connected to an ADSL modem.

For some reasons , I need to access the modem configuration (web) from outside.

Can some fluent in iptables help me out ?

Here is the setup:
- internet is PPoE, over ppp0 device
- modem GUI is on http://192.168.1.254
- modem is connected over vlan1, which has the IP 192.168.1.1
- the modem GUI accepts connections only from 192.168.1.x !

Optional: limit access to a single global IP address, for example 1.2.3.4.

Thanks !

I solved it...

Here is how:

For the record, this worked:

# I used port 8085 on outside, as 80 is already used for the routers GUI

iptables -A FORWARD -i ppp0 -o vlan1 -j ACCEPT

# 1.2.3.4 is the remote IP I only allow access
iptables -t nat -A prerouting_rule -i ppp0 -p tcp -s 1.2.3.4 --dport 8085 -j DNAT --to 192.168.1.254:80

iptables -t nat -A POSTROUTING -o vlan1 -p tcp -d 192.168.1.254 --dport 80 -j SNAT --to-source 192.168.1.1

To remove this change, just run the same commands, but replace -A with -D in all three lines.

(Last edited by xerces8 on 8 Jul 2009, 12:24)

The discussion might have continued from here.