miniupnp a possible replacement for upnp?

An area of the forum to discuss router binaries (utilities and applications that run on routers) etc.
Post Reply
mstombs
RouterTech Team
RouterTech Team
Posts: 3753
Joined: Wed Jan 10, 2007 11:54 pm

miniupnp a possible replacement for upnp?

Post by mstombs » Mon Dec 17, 2007 12:34 am

Hi,

I have compiled and built a version of miniupnpd

Code: Select all

/var # ls -laF /nvram
drwxr-xr-x    2 0        0             128 Jun  4  2007 ./
drwxr-xr-x   13 0        0             150 Jun  4  2007 ../
-rwxr-xr-x    1 0        0             910 Jun 28 22:12 bootmsg.sh*
-rwxr-xr-x    1 0        0           98524 Dec 16 23:23 miniupnpd*

/var # /nvram/miniupnpd --help
Reading configuration from file /etc/miniupnpd.conf
Unknown option: --help
Usage:
        /nvram/miniupnpd [-f config_file] [-i ext_ifname] [-o ext_ip]
                [-a listening_ip] [-p port] [-d] [-L] [-U]
                [-u uuid] [-s serial] [-m model_number]
                [-t notify_interval] [-P pid_filename]
                [-B down up] [-w url]

Notes:
        There can be one or several listening_ips.
        Notify interval is in seconds. Default is 30 seconds.
        Default pid file is /var/run/miniupnpd.pid.
        With -d miniupnpd will run as a standard program.
        -L sets packet log in pf on.
        -U causes miniupnpd to report system uptime instead of daemon uptime.
        -B sets bitrates reported by daemon in bits per second.
        -w sets the presentation url. Default is http address on port 80
Had to make a couple of code hacks, but it seems to run with

Code: Select all

#adding the MINIUPNPD chain for nat
iptables -t nat -N MINIUPNPD
#adding the rule to MINIUPNPD
iptables -t nat -A PREROUTING  -i ppp0 -j MINIUPNPD

#adding the MINIUPNPD chain for filter
iptables -t filter -N MINIUPNPD
#adding the rule to MINIUPNPD
iptables -t filter -A FORWARD -i ppp0 -o ! ppp0 -j MINIUPNPD

/var # /nvram/miniupnpd -i ppp0 -a 192.168.1.1 -p 5000 -U -d -B 8000 400

miniupnpd[589]: AddPortMapping: external port 29811 to 192.168.1.2:29811 protocol TCP for: utorrent
miniupnpd[589]: no permission rule matched : accept by default (n_perms=0)
miniupnpd[589]: redirecting port 29811 to 192.168.1.2:29811 protocol TCP for: utorrent
I added the iptables rules manually (not too sure about the filter one!) before plugging in phone line, the scripts and order to do this automatically will need some work!

As above the binary is less than 100k and when running there's only one instance...

Code: Select all

Mem: 12576K used, 1580K free, 0K shrd, 1284K buff, 4996K cached
Load average: 0.01 0.01 0.00  (Status: S=sleeping R=running, W=waiting)
  PID USER     STATUS   RSS  PPID %CPU %MEM COMMAND
  589 root     S        336   587  0.0  2.3 miniupnpd
Edit: doesn't seem to work with skype, not properly identified as an Internet Gateway by XP - fails Microsoft test

Code: Select all

Test 5 - UPnP Support Test Not supported  


Result: 
The operating system is Windows XP
UPnP is enabled by the firewall
UPnP services are running
UPnP Discovery is enabled
Detecting Internet Gateway Devices on the network
1 IGD(s) found
IGD Device Information:
Manufacturer Name : Linux
Model Name : Linux router
Model Number : 1
get_StaticPortMappingCollection() returned NULL IStaticPortMappingCollection
get_StaticPortMappingCollection() returned NULL IStaticPortMappingCollection
get_StaticPortMappingCollection() returned NULL IStaticPortMappingCollection
Failed to get port mapping from the IGD
Just appears as a device not like :-

http://miniupnp.free.fr/conf_igd_winxp.html

more tinkering needed!
Last edited by mstombs on Mon Dec 17, 2007 3:09 pm, edited 1 time in total.
User avatar
thechief
RouterTech Team
RouterTech Team
Posts: 12064
Joined: Wed Feb 01, 2006 10:22 pm
Location: England, the Centre of Africa
Contact:

Post by thechief » Mon Dec 17, 2007 2:19 pm

Interesting. But can this become a plug-in replacement for the standard upnpd?
The Chief: :afro: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
mstombs
RouterTech Team
RouterTech Team
Posts: 3753
Joined: Wed Jan 10, 2007 11:54 pm

Post by mstombs » Mon Dec 17, 2007 3:03 pm

Well its not there yet, but we have the source for the old upnp so it is theoretically possible to write a wrapper function calling the new with additional default parameters from the old, keeping the same interface to core logic.

The advantage of a drop in replacement would be the web enable/disable and the continuous monitoring by the core logic.

One issue is that miniupnp seems to have been designed for a newer iptables - I guess that would be a major change!

I'm also not sure what needs to happen around WAN IP change, and the order of initialization with respect to other GUI changes to portforwards etc [ans] the new iptables commands need to be executed before the WAN is up, or else they will not become effective until the WAN has gone down and come back up again.

Update: It was a Windows XP PC problem with the IGD not showing and all the windows/counters do display, and the IGD device passes the basics of the Microsoft Vista test. Amazingly though if you add the extra icon in the system bar so you can hover over to check connection speed etc - the PC polls the router continuously and takes a steady 5% router CPU just to service the requests!

Here's a screen dump - I named the device manually!


Image
Post Reply