### Install miniupnpd Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=926 Demonstrates the installation process for miniupnpd, including configuration file setup and binary installation. ```bash bash-3.2# PREFIX=/usr/local make install mv miniupnpd.conf miniupnpd.conf.before sed -e "s/^uuid=[-0-9a-f]*/uuid=00000000-0000-0000-0000-000000000000/" miniupnpd.conf.before > miniupnpd.conf rm -f miniupnpd.conf.before strip miniupnpd install -m 555 miniupnpd /usr/local/sbin install miniupnpd.conf /usr/local/etc ``` -------------------------------- ### Run Python setup installation Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=1815 Command to initiate the installation of the Python extension. ```bash python setup.py install ``` -------------------------------- ### Initialize MiniUPnP Daemon Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=274 Example command to start the miniupnpd daemon with specific interface and port configurations. ```bash miniupnpd -i eth0 -p 5000 -U -a 192.168.1.1 ``` -------------------------------- ### MiniUPnP Daemon Configuration and Execution Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=175 Example of a manual configuration file for miniupnpd and the command to start the daemon with that configuration. ```bash cat /tmp/miniupnpd.conf ext_ifname=vlan1 listening_ip=192.168.1.1 port=5000 bitrate_up=100000000 bitrate_down=100000000 system_uptime=yes notify_interval=30 uuid=fc4ec57e-b051-000f-6651-568401d0009d clean_ruleset_threshold=2 clean_ruleset_interval=1 allow 1024-65535 192.168.1.1/24 1024-65535 deny 0-65535 0.0.0.0/0 0-65535 /tmp # miniupnpd -f /tmp/miniupnpd.conf Reading configuration from file /tmp/miniupnpd.conf perm rule added : allow 1024-65535 c0a80101/ffffff00 1024-65535 perm rule added : deny 0-65535 00000000/00000000 0-65535 ``` -------------------------------- ### Configure MiniUPnP Daemon Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=584 Example configuration file and command to start the miniupnpd daemon with rule cleanup thresholds. ```bash cat /tmp/miniupnpd.conf ext_ifname=vlan1 listening_ip=192.168.1.1 port=5000 bitrate_up=100000000 bitrate_down=100000000 system_uptime=yes notify_interval=30 uuid=fc4ec57e-b051-000f-6651-568401d0009d clean_ruleset_threshold=2 clean_ruleset_interval=1 allow 1024-65535 192.168.1.1/24 1024-65535 deny 0-65535 0.0.0.0/0 0-65535 /tmp # miniupnpd -f /tmp/miniupnpd.conf Reading configuration from file /tmp/miniupnpd.conf perm rule added : allow 1024-65535 c0a80101/ffffff00 1024-65535 perm rule added : deny 0-65535 00000000/00000000 0-65535 ``` -------------------------------- ### Configure miniupnpd Daemon Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=22 Example configuration file and command to start the miniupnpd daemon with rule threshold settings. ```bash cat /tmp/miniupnpd.conf ext_ifname=vlan1 listening_ip=192.168.1.1 port=5000 bitrate_up=100000000 bitrate_down=100000000 system_uptime=yes notify_interval=30 uuid=fc4ec57e-b051-000f-6651-568401d0009d clean_ruleset_threshold=2 clean_ruleset_interval=1 allow 1024-65535 192.168.1.1/24 1024-65535 deny 0-65535 0.0.0.0/0 0-65535 /tmp # miniupnpd -f /tmp/miniupnpd.conf Reading configuration from file /tmp/miniupnpd.conf perm rule added : allow 1024-65535 c0a80101/ffffff00 1024-65535 perm rule added : deny 0-65535 00000000/00000000 0-65535 ``` -------------------------------- ### MiniUPnPd Build Configuration and Compilation Output Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?t=2375&view=next Example of the build output showing the configuration process and the start of the compilation phase for MiniUPnPd. ```bash >>> Configuring source in /tmp/portage/net-misc/miniupnpd-2.1.20191003/work/miniupnpd-2.1.20191003 ... make -j12 'CONFIG_OPTIONS=--vendorcfg --ipv6 --leasefile' config.h ./genconfig.sh --vendorcfg --ipv6 --leasefile ./genconfig.sh: line 331: /sbin/sysctl: No such file or directory Configuring compilation for [Gentoo] [2.6] with [nftables] firewall software. Please edit config.h for more compilation options. >>> Source configured. >>> Compiling source in /tmp/portage/net-misc/miniupnpd-2.1.20191003/work/miniupnpd-2.1.20191003 ... make -j12 CC=x86_64-pc-linux-gnu-gcc-9.2.0 STRIP=true miniupnpd x86_64-pc-linux-gnu-gcc-9.2.0 -march=x86-64 -mtune=k8 -mcx16 -msahf -msse3 --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -O2 -pipe -frecord-gcc-switches -fno-strict-aliasing -fno-common -fstack-protector -fPIE -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wstrict-prototypes -Wdeclaration-after-statement -D_GNU_SOURCE -DIPTABLES_143 -c -o miniupnpd.o miniupnpd.c ``` -------------------------------- ### miniupnpd Command Line Execution Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=600 Example of starting the miniupnpd daemon with specific interface, address, and configuration file parameters. ```bash miniupnpd -i vlan2 -a 192.168.1.1 -f miniupnpd.conf ``` -------------------------------- ### Get miniupnpd Version Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=2497 Use this command to check the installed version of miniupnpd. Ensure you are using a compatible version for your setup. ```bash miniupnpd --version ``` -------------------------------- ### Full Qt Main Implementation Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=5336 Complete main.cpp example demonstrating device discovery and parsing. ```cpp #include "dialog.h" #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); Dialog w; w.show(); const char * multicastif = 0; const char * minissdpdpath = 0; struct UPNPDev * devlist = 0; int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); if (devlist) { qDebug() << "devlist true!" << endl; struct UPNPDev * dev; dev = devlist; while (dev) { if (strstr (dev->st, "InternetGatewayDevice")) break; dev = dev->pNext; } if (!dev) dev = devlist; /* defaulting to first device */ qDebug("UPnP device :\n" " desc: %s\n st: %s\n", dev->descURL, dev->st); } else { qDebug() << "devlist false!" << endl; } return a.exec(); } ``` -------------------------------- ### Example Build Command with Options Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?t=2375&view=next This command demonstrates how to configure miniupnpd with specific options like vendor configuration, IPv6 support, and a lease file. ```bash make -j12 'CONFIG_OPTIONS=--vendorcfg --ipv6 --leasefile' config.h ``` -------------------------------- ### miniupnpd Debug Output with Configuration Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1029 Example of miniupnpd's verbose output when started with the -d flag, including configuration loading and initial network listening. This helps in verifying the daemon's startup and basic network setup. ```log Reading configuration from file /etc/miniupnpd.conf perm rule added : allow 10-65535 0a000000/ffffff00 10-65535 perm rule added : deny 0-65535 00000000/00000000 0-65535 miniupnpd[2121]: HTTP listening on port 51507 miniupnpd[2121]: Listening for NAT-PMP traffic on port 5351 miniupnpd[2121]: HTTP connection from 10.0.0.2:4153 miniupnpd[2121]: HTTP REQUEST : GET /rootDesc.xml (HTTP/1.1) miniupnpd[2121]: HTTP connection from 10.0.0.2:4154 miniupnpd[2121]: HTTP REQUEST : POST /ctl/IPConn (HTTP/1.1) miniupnpd[2121]: SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress miniupnpd[2121]: HTTP connection from 10.0.0.2:4156 miniupnpd[2121]: HTTP REQUEST : GET /rootDesc.xml (HTTP/1.1) miniupnpd[2121]: HTTP connection from 10.0.0.2:4158 miniupnpd[2121]: HTTP REQUEST : GET /rootDesc.xml (HTTP/1.1) miniupnpd[2121]: HTTP connection from 10.0.0.2:4159 miniupnpd[2121]: HTTP REQUEST : GET /L3F.xml (HTTP/1.1) ``` -------------------------------- ### Full setup.py Configuration for miniupnpc Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=4481 A complete example of a setup.py file configured to build the miniupnpc extension with the necessary static library definitions. ```python from distutils.core import setup, Extension from distutils import sysconfig sysconfig.get_config_vars()["OPT"] = '' sysconfig.get_config_vars()["CFLAGS"]= '-DMINIUPNP_STATICLIB' setup(name="miniupnpc", version=open('VERSION').read().strip(), author='Thomas BERNARD', author_email='miniupnp@free.fr', license=open('LICENSE').read(), url='http://miniupnp.free.fr/', ``` -------------------------------- ### Install miniupnpc Python module Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1668 Command to install the miniupnpc Python module using the setup script. ```bash derek@derek-laptop:/tmp/miniupnpc-1.4$ sudo make installpythonmodule python setup.py install running install running build running build_ext running install_lib copying build/lib.linux-i686-2.6/miniupnpc.so -> /usr/local/lib/python2.6/dist-packages running install_egg_info Removing /usr/local/lib/python2.6/dist-packages/miniupnpc-1.4.egg-info Writing /usr/local/lib/python2.6/dist-packages/miniupnpc-1.4.egg-info derek@derek-laptop:/tmp/miniupnpc-1.4$ python pymoduletest.py inital(default) values : discoverdelay 0 lanaddr multicastif None minissdpdsocket None Discovering... delay=200ms 0 device(s) detected Exception : No UPnP device discovered ``` -------------------------------- ### SSDP and HTTP Request Log Example Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&p=4521 Example log output showing an SSDP M-SEARCH and an HTTP GET request from a client. ```text SSDP M-SEARCH from 192.168.1.174:51245 ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1 HTTP REQUEST : GET /rootDesc.xml (HTTP/1.1) ``` -------------------------------- ### miniupnpd startup output Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1248 Example output showing the initialization of permission rules during service startup. ```text Starting miniupnpd. Reading configuration from file /usr/pkg/etc/miniupnpd.conf perm rule added : allow 1024-65535 c0a80000/ffffff00 1024-65535 perm rule added : allow 1024-65535 c0a80100/ffffff00 1024-65535 perm rule added : allow 1024-65535 c0a80000/fffffe00 22-22 perm rule added : allow 12345-12345 c0a80771/ffffffff 54321-54321 perm rule added : deny 0-65535 00000000/00000000 0-65535 ``` -------------------------------- ### Install miniupnpd from Source Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?t=407&view=previous To install miniupnpd, download the sources, unpack them, and then run 'make' followed by 'sudo make install'. This will place the daemon in /sbin/miniupnpd and its configuration file in /etc/miniupnpd.conf. ```shell make sudo make install ``` -------------------------------- ### HTTP GET Request for InternetGatewayDevice.xml Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=5326 This is an example of an HTTP GET request sent to a router's IP address and port to retrieve the InternetGatewayDevice.xml file. This is typically used to get device information. ```http GET /InternetGatewayDevice.xml HTTP/1.1 Host: 192.168.0.1:1980 ``` -------------------------------- ### miniupnpd Configuration Example Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=5072 An example of a miniupnpd.conf file. Ensure your configuration matches your network setup, especially interface names and IP ranges. ```ini ext_ifname=enp2s0 listening_ip=172.17.2.1 port=0 enable_natpmp=yes enable_upnp=yes lease_file=/var/lib/miniupnpd/upnp.leases bitrate_up=1000000 bitrate_down=10000000 secure_mode=yes system_uptime=yes notify_interval=60 clean_ruleset_interval=600 uuid=60943e58-b9ff-42bc-a825-5cd04c359f57 serial=12345678 model_number=1 allow 1024-65535 192.168.0.0/16 1024-65535 allow 1024-65535 10.0.0.0/8 1024-65535 allow 0-65535 172.16.0.0/12 1024-65535 deny 0-65535 0.0.0.0/0 0-65535 ``` -------------------------------- ### Configuration File Example Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=544 Example miniupnpd.conf configuration file. ```ini # WAN network interface #ext_ifname=eth0 ext_ifname=wan # if the WAN interface has several IP addresses, you # can specify the one to use below #ext_ip= # LAN network interfaces IPs / networks # there can be multiple listening ips for SSDP traffic. # should be under the form nnn.nnn.nnn.nnn/nn # HTTP is available on all interfaces #listening_ip=192.168.0.1/24 listening_ip=192.168.1.1/24 #listening_ip= # port for HTTP (descriptions and SOAP) traffic. set 0 for autoselect. port=0 # path to the unix socket used to communicate with MiniSSDPd # If running, MiniSSDPd will manage M-SEARCH answering. # default is /var/run/minissdpd.sock #minissdpdsocket=/var/run/minissdpd.sock # enable NAT-PMP support (default is no) enable_natpmp=yes # enable UPNP support (default is yes) enable_upnp=yes # chain names for netfilter (not used for pf or ipf). # default is MINIUPNPD for both #upnp_forward_chain=forwardUPnP #upnp_nat_chain=UPnP # lease file location #lease_file=/var/lib/miniupnpd/upnp.leases # bitrates reported by daemon in bits per second bitrate_up=1000000 bitrate_down=10000000 # "secure" mode : when enabled, UPnP client are allowed to add mappings only # to their IP. secure_mode=yes #secure_mode=no # default presentation url is http address on port 80 #presentation_url=http://www.mylan/index.php # report system uptime instead of daemon uptime system_uptime=yes ``` -------------------------------- ### MiniUPnPd Installation Error on Debian Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=1211 This error occurs during miniupnpd installation if the START_DAEMON variable in /etc/default/miniupnpd is not set to 1. Ensure this configuration is correct before starting the daemon. ```bash [FAIL] MiniUPnPd: /etc/default/miniupnpd isn't set to START_DAEMON=1: exiting: failed! ``` -------------------------------- ### Example libnatpmp program Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1978 A sample C program demonstrating the initialization, port mapping request, and cleanup using libnatpmp. ```c #include #include #include int main() { printf("Compilation reussie"); return 0; } void redirect(uint16_t privateport, uint16_t publicport) { int r; natpmp_t natpmp; natpmpresp_t response; initnatpmp(&natpmp); sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, privateport, publicport, 3600); do { fd_set fds; struct timeval timeout; FD_ZERO(&fds); FD_SET(natpmp.s, &fds); getnatpmprequesttimeout(&natpmp, &timeout); select(FD_SETSIZE, &fds, NULL, NULL, &timeout); r = readnatpmpresponseorretry(&natpmp, &response); } while(r==NATPMP_TRYAGAIN); printf("mapped public port %hu to localport %hu liftime %u\n", response.pnu.newportmapping.mappedpublicport, response.pnu.newportmapping.privateport, response.pnu.newportmapping.lifetime); closenatpmp(&natpmp); } ``` -------------------------------- ### miniupnpd Configuration Example Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=2497 This is an example configuration for miniupnpd when using the 'Override WAN address' option. Adjust 'ext_ifname', 'port', 'listening_ip', and 'ext_ip' according to your network setup. ```ini ext_ifname=vtnet0 port=2189 listening_ip=vtnet1 ext_ip=MY.ISP.158.254 secure_mode=yes presentation_url=https://192.168.1.1/ model_number=23.01-RELEASE allow 1024-65535 192.168.1.91/32 1024-65535 enable_upnp=yes enable_natpmp=yes ``` -------------------------------- ### Configure miniupnpd service on NetBSD Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=545 This snippet shows how to enable the miniupnpd service to start on boot by creating a configuration file in /etc/rc.conf.d. ```bash echo "miniupnpd=YES" > /etc/rc.conf.d/miniupnpd ``` -------------------------------- ### MiniUPnPd Service Log Output Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=811 Example log output when starting MiniUPnPd in debug mode. ```text /sbin/miniupnpd -d miniupnpd[16291]: HTTP listening on port 9955 miniupnpd[16291]: bind(udp): Address already in use miniupnpd[16291]: Failed to open socket for receiving SSDP. Trying to use MiniSSDPd ``` -------------------------------- ### Expected Socket Configuration Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=492 Example of successful socket setup with SO_REUSEADDR as seen in strace output. ```c socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4 setsockopt(4, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 bind(4, {sa_family=AF_INET, sin_port=htons(1900), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 ``` -------------------------------- ### Configure setup.py for Windows static linking Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=1815 Modified setup script to reference a .lib file instead of a .a file for Windows compatibility. ```python from distutils.core import setup, Extension from distutils import sysconfig sysconfig.get_config_vars()["OPT"] = '' sysconfig.get_config_vars()["CFLAGS"] = '' setup(name="miniupnpc", version=open('VERSION').read().strip(), author='Thomas BERNARD', author_email='miniupnp@free.fr', license=open('LICENSE').read(), url='http://miniupnp.free.fr/', description='miniUPnP client', ext_modules=[ Extension(name="miniupnpc", sources=["miniupnpcmodule.c"], libraries=["ws2_32", "iphlpapi"], extra_objects=[r"msvc\Release\upnpc-static.lib"]) ]) ``` -------------------------------- ### Build and Install MiniUPnP Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?t=485 Commands to compile the source code and install the binary and configuration files. ```bash make gcc -Wall -Os -o miniupnpd miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o options.o upnppermissions.o minissdp.o natpmp.o upnpevents.o upnpreplyparse.o minixml.o bsd/getifstats.o pf/obsdrdr.o -lkvm gcc -Wall -Os -o testupnpdescgen testupnpdescgen.o upnpdescgen.o gcc -Wall -Os -o testgetifstats testgetifstats.o bsd/getifstats.o -lkvm gcc -Wall -Os -o testupnppermissions testupnppermissions.o upnppermissions.o gcc -Wall -Os -o miniupnpdctl miniupnpdctl.o PREFIX=/usr/local make install mv miniupnpd.conf miniupnpd.conf.before sed -e "s/^uuid=[-0-9a-f]*/uuid=00000000-0000-0000-0000-000000000000/" miniupnpd.conf.before > miniupnpd.conf rm -f miniupnpd.conf.before strip miniupnpd install -m 555 miniupnpd /usr/local/sbin install miniupnpd.conf /usr/local/etc ``` -------------------------------- ### HTTP GET Request for Router XML Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=5327 This example shows an HTTP GET request to retrieve the InternetGatewayDevice.xml from a router. Ensure the Host header matches the router's IP address and port. ```http GET /InternetGatewayDevice.xml HTTP/1.1 Host: 192.168.0.1:1980 ``` ```http HTTP/1.1 200 OK Content-Type: text/xml Content-Length: 3039 Connection: close Pragma: no-cache ``` -------------------------------- ### Troubleshoot Lease File Creation and Permissions Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=622 These commands demonstrate how to create a lease file, check its permissions, start the miniupnpd service, and then verify if the lease file was created as expected. This helps in diagnosing issues where the service might fail due to missing or inaccessible lease files. ```bash # touch /var/spool/upnp.leases # ls -l /var/spool/upnp.leases -rw-r--r-- 1 root root 0 2010-03-11 22:17 /var/spool/upnp.leases # /etc/init.d/miniupnpd start Starting miniupnpd: [ OK ] # ls -l /var/spool/upnp.leases ls: cannot access /var/spool/upnp.leases: No such file or directory ``` -------------------------------- ### Start miniupnpd service on NetBSD Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=545 Execute this command to start the miniupnpd service. The service will read its configuration from /usr/pkg/etc/miniupnpd.conf. ```bash etc/rc.d/miniupnpd start ``` -------------------------------- ### FreeBSD PF Configuration Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1065 Example pf.conf file showing anchor setup for MiniUPnPd and NAT/RDR rules. ```text int_if = "vr1" ext_if = "vr0" tcp_services = "{ ssh, smtp, http, auth, imap, https, smtps, imaps, xmpp-client, xmpp-server }" udp_services = "{ sip, 5004:5023 }" icmp_types = "echoreq" priv_nets = "{ 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8 }" # options set block-policy return set loginterface $ext_if # scrub scrub in all # nat/rdr nat-anchor "ftp-proxy/*" nat on $ext_if from $int_if:network to any -> ($ext_if) rdr-anchor "ftp-proxy/*" rdr pass on $int_if proto tcp from any to any port ftp -> 127.0.0.1 port 8021 rdr-anchor "miniupnpd" ``` -------------------------------- ### MiniDLNA HTTP Request and Response Example Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=1442 This example shows the HTTP GET request and the subsequent response from MiniDLNA, including headers like ACCEPT-LANGUAGE, Host, and Content-Language. It is provided for comparison with miniupnpd's behavior. ```http [1980/01/06 00:29:14] upnphttp.c:948: debug: HTTP REQUEST: GET / HTTP/1.1 ACCEPT-LANGUAGE: en Host: 192.168.225.1:8200 [1980/01/06 00:29:14] upnphttp.c:1272: debug: HTTP RESPONSE: HTTP/1.1 200 OK Content-Type: text/html Connection: close Content-Length: 183 Server: Ubuntu/10.04 DLNADOC/1.50 UPnP/1.0 MiniDLNA/1.0.25 Content-Language: en Date: Sun, 06 Jan 1980 00:29:14 GMT EXT: MiniDLNA 1.0.25

MiniDLNA status

Audio fil es: 0
Video files: 0
Image files: 0
``` -------------------------------- ### Example libnatpmp Program Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1975 A basic C program demonstrating the initialization, port mapping request, and cleanup using libnatpmp. ```c #include #include #include int main() { printf("Compilation reussie"); return 0; } void redirect(uint16_t privateport, uint16_t publicport) { int r; natpmp_t natpmp; natpmpresp_t response; initnatpmp(&natpmp); sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, privateport, publicport, 3600); do { fd_set fds; struct timeval timeout; FD_ZERO(&fds); FD_SET(natpmp.s, &fds); getnatpmprequesttimeout(&natpmp, &timeout); select(FD_SETSIZE, &fds, NULL, NULL, &timeout); r = readnatpmpresponseorretry(&natpmp, &response); } while(r==NATPMP_TRYAGAIN); printf("mapped public port %hu to localport %hu liftime %u\n", response.pnu.newportmapping.mappedpublicport, response.pnu.newportmapping.privateport, response.pnu.newportmapping.lifetime); closenatpmp(&natpmp); } ``` -------------------------------- ### MiniUPnPd Configuration File Examples Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1012 Sample configuration file content for miniupnpd, demonstrating the use of lease_file and firewall rules. ```text ext_ifname=nfe0 listening_ip=10.0.0.1 port=2689 lease_file=/var/db/upnpd/upnpd.leases allow 1024-65535 10.0.0.0/24 1024-65535 deny 0-65535 0.0.0.0/0 0-65535 ``` ```text ext_ifname=nfe0 listening_ip=10.0.0.1 port=2689 lease_file=/var/db/upnpd/upnpd.leases allow 0-65535 10.0.0.0/8 0-65535 deny 0-65535 0.0.0.0/32 0-65535 ``` -------------------------------- ### miniupnpd compilation and installation steps Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=545 These are the basic steps to compile and install miniupnpd from source. Download the latest sources, untar, and then run make and make install. ```bash download latest sources on http://miniupnp.free.fr/files/ tar, make, make install configure and enjoy it ``` -------------------------------- ### Build and Install MiniUPnP Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=588 Commands for generating the configuration, compiling the source code, and installing the resulting binaries. ```bash -bash-3.2# make -f Makefile.linux config.h ./genconfig.sh which: no lsb_release in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin) Configuring compilation for [Linux] [2.6.18-164.6.1.el5xen] with [netfilter] firewall software. Please edit config.h for more compilation options. ``` ```bash -bash-3.2# make -f Makefile.linux gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o miniupnpd.o miniupnpd.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnphttp.o upnphttp.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnpdescgen.o upnpdescgen.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnpsoap.o upnpsoap.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnpreplyparse.o upnpreplyparse.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o minixml.o minixml.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnpredirect.o upnpredirect.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o getifaddr.o getifaddr.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o daemonize.o daemonize.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnpglobalvars.o upnpglobalvars.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o options.o options.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnppermissions.o upnppermissions.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o minissdp.o minissdp.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o natpmp.o natpmp.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o upnpevents.o upnpevents.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o linux/getifstats.o linux/getifstats.c gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o netfilter/iptcrdr.o netfilter/iptcrdr.c gcc miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o upnpreplyparse.o minixml.o upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o options.o upnppermissions.o minissdp.o natpmp.o upnpevents.o linux/getifstats.o netfilter/iptcrdr.o /usr/lib/libiptc.a -o miniupnpd /usr/bin/ld: warning: i386 architecture of input file `/usr/lib/libiptc.a(libip4tc.o)' is incompatible with i386:x86-64 output gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o testupnpdescgen.o testupnpdescgen.c gcc testupnpdescgen.o upnpdescgen.o -o testupnpdescgen gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o testgetifstats.o testgetifstats.c gcc testgetifstats.o linux/getifstats.o -o testgetifstats gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o testupnppermissions.o testupnppermissions.c gcc testupnppermissions.o upnppermissions.o -o testupnppermissions gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o miniupnpdctl.o miniupnpdctl.c gcc miniupnpdctl.o -o miniupnpdctl gcc -Wall -O -D_GNU_SOURCE -g -DDEBUG -c -o testgetifaddr.o testgetifaddr.c gcc testgetifaddr.o getifaddr.o -o testgetifaddr ``` ```bash -bash-3.2# make -f Makefile.linux install sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen) 2>/dev/null`/" miniupnpd.conf strip miniupnpd install -d /usr/sbin install miniupnpd /usr/sbin install -d /etc/miniupnpd install netfilter/iptables_init.sh /etc/miniupnpd install netfilter/iptables_removeall.sh /etc/miniupnpd install --mode=0644 -b miniupnpd.conf /etc/miniupnpd install -d /etc/init.d install linux/miniupnpd.init.d.script /etc/init.d/miniupnpd ``` -------------------------------- ### Configure MiniUPnPd for Boot Startup Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=408 Commands to add to /etc/rc.local to ensure the daemon starts automatically at boot. ```bash echo "starting miniupnpd" /sbin/miniupnpd ``` -------------------------------- ### SOAP Request for GetExternalIPAddress Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=15&t=513 This is an example of a SOAP request to get the external IP address, used as a reference for a working request. ```http POST /wipc_cont HTTP/1.1 HOST: 192.168.1.1:80 CONTENT-LENGTH: 296 CONTENT-TYPE: text/xml; charset="utf-8" SOAPACTION: "urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress" ``` -------------------------------- ### OpenBSD pf.conf rule syntax example with new syntax Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=578 This is an example of a pf.conf rule with the new syntax, including redirection and labeling. ```shell rdr pass on xl1 inet proto udp from any to any port = 12345 label "testing" -> 10.10.42.42 port 54321 ``` -------------------------------- ### miniupnpd compilation and installation steps Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1250 These are the general steps to compile and install miniupnpd from source. This method is an alternative if a pre-compiled package is not available or suitable. ```bash download latest sources on http://miniupnp.free.fr/files/ tar -xzf miniupnpd-*.tar.gz cd miniupnpd-* ./configure make make install ``` -------------------------------- ### GetGenericPortMappingEntry SOAP Request Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=499 This is an example of a SOAP request to get a generic port mapping entry. It specifies the port mapping index to retrieve. ```xml POST /control?WANIPConnection HTTP/1.1 Host: 192.168.0.1:1780 User-Agent: POSIX, UPnP/1.0, miniUPnPc/1.0 Content-Length: 341 Content-Type: text/xml SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry" Connection: Close Cache-Control: no-cache Pragma: no-cache 2 ``` ```xml POST /control?WANIPConnection HTTP/1.1 Host: 192.168.0.1:1780 User-Agent: POSIX, UPnP/1.0, miniUPnPc/1.0 Content-Length: 341 Content-Type: text/xml SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry" Connection: Close Cache-Control: no-cache Pragma: no-cache 1 ``` ```xml POST /control?WANIPConnection HTTP/1.1 Host: 192.168.0.1:1780 User-Agent: POSIX, UPnP/1.0, miniUPnPc/1.0 Content-Length: 341 Content-Type: text/xml SOAPAction: "urn:schemas-upnp-org:service:WANIPConnection:1#GetGenericPortMappingEntry" Connection: Close Cache-Control: no-cache Pragma: no-cache 0 ``` -------------------------------- ### Test miniupnpc with GetListOfPortMappings Source: https://miniupnp.tuxfamily.org/forum/viewtopic.php?highlight=&postdays=0&postorder=asc&start=0&t=728 This command-line example demonstrates how to use the upnpc executable to list existing port mappings. It requires the miniupnpc library to be installed. ```bash $ ./upnpc-static -L ``` ```text upnpc : miniupnpc library test client. (c) 2006-2011 Thomas Bernard Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ for more information. Found valid IGD : http://192.168.0.1:11604/ctl/IPConn Local LAN ip address : 192.168.0.80 0 TCP 22407->:22407 'Azureus UPnP 22407 TCP' '' 1 TCP 8000->:8000 'libminiupnpc' '' 2 UDP 22407->:22407 'Azureus UPnP 22407 UDP' '' ```