# Shorewall and UPnP

Tom
Eastep
2005
Thomas M. Eastep

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover, and with no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.

## UPnP

In Shorewall 2.2.4, support was added for UPnP (Universal Plug and Play) using linux-igd (http://linux-igd.sourceforge.net). UPnP is required by a number of popular applications including MSN IM.

From a security architecture viewpoint, UPnP is a disaster. It assumes that:

1. All local systems and their users are completely trustworthy.

2. No local system is infected with any worm or trojan.

If either of these assumptions are not true then UPnP can be used to totally defeat your firewall and to allow incoming connections to arbitrary local systems on any port whatsoever. In short: USE UPnP AT YOUR OWN RISK.

The linux-igd project was inactive for a long time and has just been resurrected. I haven't tried to build using the current code (as of 2006-07-22) but the last time I did, I found that building and installing linux-igd was not for the faint of heart. You must download the source from CVS and I had to do quite a bit of fiddling with the include files from libupnp (which is required to build and/or run linux-igd).

## linux-igd Configuration

In /etc/upnpd.conf, you will want:

    insert_forward_rules = yes
    prerouting_chain_name = UPnP
    forward_chain_name = forwardUPnP

## Shorewall Configuration

In `/etc/shorewall/interfaces`, you need the 'upnp' option on your external interface.

Example:

    #ZONE   INTERFACE       BROADCAST       OPTIONS
    net     eth1            detect          dhcp,routefilter,norfc1918,tcpflags,upnp

If your fw->loc policy is not ACCEPT then you need this rule:

    #ACTION            SOURCE  DEST
    allowoutUPnP       $FW     loc

To use 'allowoutUPnP', your iptables and kernel must support the 'owner match' feature (see the output of "shorewall show capabilities") and you may not be running kernel version 2.6.14 or later. If you are running 2.6.14 or later, then replace the above rule with:

>     #ACTION            SOURCE  DEST   PROTO     DEST PORT(S)     SOURCE     ORIGINAL     RATE     USER/
>     #                                                            PORT(S)    DESTINATION  LIMIT    GROUP
>     ACCEPT             $FW     loc    all       -                -          -            -        root

If your loc->fw policy is not ACCEPT then you need this rule:

    #ACTION            SOURCE  DEST
    allowinUPnP        loc     $FW

You MUST have this rule:

    #ACTION            SOURCE  DEST
    forwardUPnP        net     loc

You must also ensure that you have a route to 224.0.0.0/4 on your internal (local) interface as described in the linux-igd documentation.