router definition: sanewall-router

5
sanewall-router

sanewall-router

create a router definition

        router
        name
        rule-params

## Description

A `router` definition consists of a set of rules for traffic passing through the host running the firewall.

The default policy for router definitions is RETURN, meaning packets are not dropped by any particular router. Packets not matched by any router are dropped at the end of the firewall.

The behaviour of the defined router is controlled by adding subcommands (listed in rt-see-also).

## Parameters

`name`

- This is a name for this router. You should use short names (10 characters maximum) without spaces or other symbols.

  A name should be unique for all Sanewall interface and router definitions.

`rule-params`

- The set of rule parameters to further restrict the traffic that is matched to this router.

  See rule-params for information on the parameters that can be used. Some examples:

      router mylan inface ppp+ outface eth0 src not ${UNROUTABLE_IPS}

      router myrouter

  See sanewall.conf for an explanation of `${UNROUTABLE_IPS}`.

## Working with routers

Routers create stateful `iptables` rules which match traffic in both directions.

To match some client or server traffic, the input/output interface or source/destination of the request must be specified. All `inface`/`outface` and `src`/`dst` rule-params can be given on the router statement (in which case they will be applied to all subcommands for the router) or just within the subcommands of the router.

For example, to define a router which matches requests from any PPP interface and destined for eth0, and on this allowing HTTP servers (on eth0) to be accessed by clients (from PPP) and SMTP clients (from eth0) to access any servers (on PPP):

    router mylan inface ppp+ outface eth0
      server http accept
      client smtp accept

The `client` subcommand reverses any optional rule parameters passed to the `router`, in this case the inface and outface.

Equivalently, to define a router which matches all forwarded traffic and within the the router allow HTTP servers on eth0 to be accessible to PPP and any SMTP servers on PPP to be accessible from eth0:

    router mylan
      server http accept inface ppp+ outface eth0
      server smtp accept inface eth0 outface ppp

In this instance two `server` subcommands are used since there are no parameters on the router to reverse. Avoid the use of the `client` subcommand in routers unless the inputs and outputs are defined as part of the router.

Any number of routers can be defined and the traffic they match can overlap. Since the default policy is RETURN, any traffic that is not matched by any rules in one will proceed to the next, in order, until none are left.

## See Also

- sanewall
- sanewall.conf
- def-interface
- cmd-policy
- cmd-protection
- cmd-client
- cmd-server
- cmd-group
- helpcmd-iptables
- helpcmd-masquerade
- helpcmd-tcpmss