pf-upnp
Introduction
pf-upnp is a simple cli program to list/query/add/remove port forwarding entries using UPnP.
License
pf-upnp is released under the GNU GPLv3 license.
How to compile pf-upnp
pf-upnp is written in C an uses libgupnp to communicate with your router. Since it is a simple program, there is no configure script. In order to compile pf-upnp you need:
- gcc
- libglib
- libgupnp
Under Debian/Ubuntu all the dependencies should be satisfied by installing the following
packages:
sudo apt-get install build-essential libgupnp-1.0-dev
To produce the executable run the following command:
gcc -Wall -O2 $(pkg-config --cflags gupnp-1.0) -o pf-upnp pf-upnp.c $(pkg-config --libs gupnp-1.0 gssdp-1.0 libxml-2.0 libsoup-2.4)
Using pf-upnp
You can access the help by running:
$ ./pf-upnp -h Usage: pf-upnp [OPTION...] - Port Forwarding via UPnP Help Options: -h, --help Show help options Application Options: -l, --list List port mappings -q, --query Query mapping -a, --add Add mapping -d, --del Delete mapping -p, --port=N Port number -u, --udp udp port (tcp otherwise) -c, --client=IP Internal client -D, --desc=STRING Description -t, --timeout=N Timeout (default 5s)
Using this program should be pretty straightforward. Let's look at some examples:
- Get status info and external IP address:
$ ./pf-upnp
- List port mappings:
$ ./pf-upnp -l
- Query mapping (udp port 8110):
$ ./pf-upnp -q -u -p 8110
- Add port mapping (open udp port 8110):
$ ./pf-upnp -a -u -p 8110 -c 192.168.1.7 -D parole
- Delete mapping (close udp port 8110):
$ ./pf-upnp -d -u -p 8110
Tested routers
- D-Link DSL-2640B
Download
The following versions of pf-upnp are available for download. Please note that pf-upnp should be considered beta software. We recommend you to download the latest version.
- e0fd76e3bd28b4a14d88575e62211efd pf-upnp-0.0.1.tar.gz (Thu, 26 Dec 2013)
Changelog
version 0.0.1: * Initial release