Updated: Jun 17 2010
miniupnp client for OpenWrt
Forward ports from a connected AP to your OpenWrt device in routed client mode
miniupnpc for OpenWrt will let you script port forwarding to your machine from a connected AP. This is useful as UPnP will not traverse from a client on your OpenWrt device to the host AP in routed client mode.
Assuming UPnP hasn't been disabled on the access point, you can use miniupnpc to forward a port from the AP to any local IP in that AP's subnet. miniupnpc includes libraries and a standalone 'test' UPnP client. It's most useful in a routed client environment, although it may work inside of scripts in bridged client mode (although then you should be able to use any UPnP program from the client).
The miniupnp project's homepage is located at http://miniupnp.free.fr. You can find the Makefile and patches used here.
Send me an email if you have any questions or comments.
miniupnpc test client for OpenWrt (brcm-2.4)
Filename: miniupnpc_1.4-2_brcm-2.4.ipkFilesize: 14.5KB
md5sum: 43e99bdd64681036328719827d33b3db
Download, scp and install, or, from OpenWrt:
[root@OpenWrt: ~]# opkg install http://myantihero.net/pub/openwrt/packages/brcm-2.4/miniupnpc_1.4-2_brcm-2.4.ipk
You can also add my micro-repository to your opkg list:
[root@OpenWrt: ~]# echo 'src/gz myantihero http://myantihero.net/pub/openwrt/packages/brcm-2.4' >> /etc/opkg.conf [root@OpenWrt: ~]# opkg update Downloading http://myantihero.net/pub/openwrt/packages/brcm-2.4/Packages.gz. Inflating http://myantihero.net/pub/openwrt/packages/brcm-2.4/Packages.gz. Updated list of available packages in /var/opkg-lists/myantihero. [root@OpenWrt: ~]# opkg install miniupnpc
[root@OpenWrt: ~]# upnpc upnpc : miniupnpc library test client. (c) 2006-2009 Thomas Bernard Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ for more information. Usage : upnpc [options] -a ip port external_port protocol Add port redirection upnpc [options] -d external_port protocol [port2 protocol2] [...] Delete port redirection upnpc [options] -s Get Connection status upnpc [options] -l List redirections upnpc [options] -r port1 protocol1 [port2 protocol2] [...] Add all redirections to the current host protocol is UDP or TCP Options: -u url : bypass discovery process by providing the XML root description url. -m address : provide ip address of the interface to use for sending SSDP multicast packets. -p path : use this path for MiniSSDPd socket.
I had trouble getting the program to auto-detect my routers gateway and XML descriptor URI, so you may have to specify it. For a Linksys WRT54G/GL (and other models), use:
[root@OpenWrt: ~]# upnpc -u http://192.168.1.1:2869/IGatewayDeviceDescDoc -l
From there, you should get back a list of currently enabled UPnP port forwards. Then you can just add your own forwards in the form of:
[root@OpenWrt: ~]# upnpc -u http://192.168.1.1:2869/IGatewayDeviceDescDoc -a 192.168.1.115 80 8080 tcp
... which will forward incoming tcp port 8080 (on the WAN side of the AP) to tcp port 80 on 192.168.1.115 (which doesn't have to be your OpenWrt device -- you can create port forwards for other machines as well).