UPDATE (Jul 30 2008): The version compiled for mips (below) with the atheros-2.6 SDK is untested, so kindly let me know if it works for you or not.
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 can be found at http://miniupnp.free.fr. I downloaded the source, and patched and compiled it in the OpenWrt SDK on Debian GNU/Linux for use. You can find the Makefile and patches I made here.
MiniUPnPc test client for OpenWrt (mipsel, compiled for brcm-2.4):
Download: [miniupnpc_1.2-1_mipsel.ipk] 14KB | md5sum: e80774206fd0bfea90b6530c7a471bdf
MiniUPnPc test client for OpenWrt (mips, compiled for atheros-2.6):
Download: [miniupnpc_1.2-1_mips.ipk] 14KB | md5sum: 234884c7d7b1ee5b932d337c72681b8f
Download, scp and install, or, from OpenWrt ...
[root@OpenWrt: ~]# ipkg install http://myantihero.net/pub/openwrt/packages/mipsel/miniupnpc_1.2-1_mipsel.ipk
You can also add my micro-repository to your ipkg list:
[root@OpenWrt: ~]# echo 'src myantihero http://myantihero.net/pub/openwrt/packages/mipsel' >> /etc/ipkg.conf [root@OpenWrt: ~]# ipkg update Downloading http://myantihero.net/pub/openwrt/packages/mipsel/Packages Updated list of available packages in /usr/lib/ipkg/lists/myantihero Done. [root@OpenWrt: ~]# ipkg install miniupnpc
[root@OpenWrt: ~]# upnpc upnpc : miniupnpc library test client. (c) 2006-2008 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 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. [root@OpenWrt: ~]#
I had trouble getting the program to auto-detect my routers gateway and XML descriptor URL, 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 control port forwards for other machines as well).
If you have any questions, send me an email .