Showing posts with label UPnP. Show all posts
Showing posts with label UPnP. Show all posts

Saturday, September 26, 2015

How to port forward in asus router RT N14UHP

We will do something fun today. But you will need a router which has the feature universal plug and play  . In this article, I will use Asus router RT N14UHP for this demo.

Login to your router and locate the UPnP setting. Go to WAN then on the basic config, click yes for Enable UPnP. See screenshot below.


Next, get this script from github. See command line below which I have experience myself.

 user@localhost:~$ wget https://raw.githubusercontent.com/gryphius/port-forward/master/port-forward.py  
 --2015-09-04 02:53:28-- https://raw.githubusercontent.com/gryphius/port-forward/master/port-forward.py  
 Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 103.245.222.133  
 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|103.245.222.133|:443... connected.  
 HTTP request sent, awaiting response... 200 OK  
 Length: 9115 (8.9K) [text/plain]  
 Saving to: ‘port-forward.py’  
 port-forward.py                 100%[=======================================================================================================>]  8.90K --.-KB/s  in 0s     
 2015-09-04 02:53:29 (46.3 MB/s) - ‘port-forward.py’ saved [9115/9115]  
 user@localhost:~$ chmod 755 port-forward.py   
 user@localhost:~$ ./port-forward.py   
 Found 1 UPnP routers: 192.168.133.1:42917  
 No external port specified.  
 user@localhost:~$ ./port-forward.py -e 1337 -v -r 192.168.133.1 -l 9999 -d 'forward 1337 to 9999'   
 Discovering routers...  
 Found 1 UPnP routers: 192.168.133.1:42917  
 port forward on 192.168.133.1 successful, 1337->192.168.133.20:9999  
 user@localhost:~$ nc -l 9999  
 user@localhost:~$   

As you can read above, the script is downloaded and then permission is set accordingly. Noticed that UPnP is found on my router on port 42917. Then you can instruct the router to port forward, in this example port 1337 to an internal of this machine. In this example, my local ip is 192.168.133.1 and the application is running on port 9999. Now, to simulate this work, you can use command nc to listen on port 9999.

To test if this work, just get your public ip and telnet to your router on port 1337, your router should forward this traffic to internal machine 92.168.133.20 port 9999. As you can also see above, when telnet is done, nc port listen is also closed. That's it. Have fun port forwarding!