Minimal STUN client for finding external IP

Alexander Kriegisch kriegaex at freetz.org
Thu Dec 15 12:02:17 UTC 2011


Someone in our project had the idea of using a STUN client like the one at https://sourceforge.net/projects/stun to determine a router's external IP address quickly and efficiently. Actually this is much faster than wget-ting the address from an external site via HTTP request. We tested this on a desktop Linux system. BTW, the IP can be determined like this:

stun -v 1 stun.1und1.de 2>&1 | sed -nr 's/^MappedAddress = (.*):.*$/\1/p'

Now the STUN package mentioned above is coded in C++ and does a lot more than just determine. I had the idea that having a minimal stun_get_ip Applet in BB would be a nice thing, because BB runs on many embedded systems, many of them router firmwares, and it is a common task to determine an external IP address from behind a NAT.

I know that I should rather provide a patch than ask for one, but unfortunately I do not speak C. Maybe there is a developer on this list who has a similar use case and would volunteer to implement a minimal STUN IP detection applet which could be used like this:

stun_get_ip stun_server

A full port of the STUN test client with the complete suite of three test methods might be useful for others, but me personally, I do not need it.

I hope you do not mind me asking for a new applet on this list, I hope it is the right place for it. I am not greedy, so if nobody sees any value in it or it is too expensive to implement, it is okay and we continue to use the slower method of querying the address via HTTP. STUN was made for NAT traversal though, so it seems like the natural solution to this problem.
--
Alexander Kriegisch (kriegaex)
http://freetz.org





More information about the busybox mailing list