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:

  1. gcc
  2. libglib
  3. 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:

  1. Get status info and external IP address:

    $ ./pf-upnp

  2. List port mappings:

    $ ./pf-upnp -l

  3. Query mapping (udp port 8110):

    $ ./pf-upnp -q -u -p 8110

  4. Add port mapping (open udp port 8110):

    $ ./pf-upnp -a -u -p 8110 -c 192.168.1.7 -D parole

  5. Delete mapping (close udp port 8110):

    $ ./pf-upnp -d -u -p 8110

Tested routers

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.

Changelog

version 0.0.1:

	* Initial release
			

Valid XHTML 1.0 Strict

Copyright (C) 2013 Giorgio Vazzana