I developed a small program allowing you to administrate your UPnP router at work or at home. It can reconnect, print statistics, add a port mapping entry, remove one, print a list and clear the entire entry list.
The program depends on libnet-upnp-perl. So you first have to install it to use the script. The packet contains the Perl extension Net::UPnP which allows you to control UPnP devices in Perl.
sudo apt-get install libnet-upnp-perl -y
Now download the script and unpack it. Now you can open a terminal and navigate to the script’s directory. Make the script executable with this command:
chmod +x ./router.pl
You can use it. This one-liner reconnects your router’s internet connection.
./router.pl -r
If you have more then one UPnP device, the script will ask you for the right one. Instead of being asked every time executing the command, you can use the -d parameter followed by the device number.
./router.pl -r -d 0
You can add a port mapping entry with this:
./router.pl -a -e 1033 -I 192.168.0.5 -i 1033 -P TCP
This will add a port mapping entry mapping the external port 1033 to the IP address 192.168.0.5.
For further information, use the -h option.
Please write a comment after you executed this script. In this comment post your router’s model name, the command you executed and the program’s output so I can correct mistakes if there are any. Thanks.

3 responses so far ↓
1 Alvaro // Apr 24, 2009 at 04:53
I have to use a Linksys SRX200 (a very crappy router) and it gives this error:
Can’t call method “getservicebyname” on an undefined value at ./router.pl line 221.
2 vwochnik // Apr 25, 2009 at 12:00
I moved my blog to http://mydeblog.hostcell.net. Try this:
http://mydeblog.hostcell.net/2009/04/21/administrating-your-gateway-device-via-upnp/
If it doesn’t work, post your comment there!
Cheers.
3 出会い // Dec 4, 2009 at 05:10
よろしくおねがいします。good good nice
Leave a Comment