GRE(4)

NAME
gre, mobileip - encapsulating network device

SYNOPSIS
pseudo-device gre

DESCRIPTION
The gre driver allows tunnel construction using the Cisco GRE or the Mobile IP (RFC 2004) encapsulation protocols.

GRE, WCCPv1, and Mobile IP are enabled with the following sysctl(3) variables respectively in /etc/sysctl.conf:

net.inet.gre.allow
    Allow GRE packets in and out of the system.

net.inet.gre.wccp
    Set to 1 to allow WCCPv1-style GRE packets into the system; set to 2 to handle the packets as WCCPv2-style GRE, truncating the redirect header. Some magic with the packet filter configuration and a caching proxy like squid are needed to do anything useful with these packets. This sysctl requires gre.allow to be set.

net.inet.mobileip.allow
    Allow Mobile IP packets in and out of the system.

This driver currently supports the following modes of operation:

gre GRE datagrams (IP protocol number 47) are prepended by an outer datagram and a GRE header. The GRE header specifies the type of the encapsulated datagram and thus allows for tunneling other protocols than IP, such as AppleTalk. GRE mode is the default tunnel mode on Cisco routers. This is also the default mode of operation of the gre interfaces.

mobileip
    MOBILE datagrams (IP protocol number 55) are encapsulated into IP, but with a much smaller encapsulation header. This protocol only supports IP in IP encapsulation, and is intended for use with Mobile IP.

A gre or mobileip interface can be created at runtime using the ifconfig greN create command or by setting up a hostname.if(5) configuration file for netstart(8). The MTU is set to 1476 by default to match the value used by Cisco routers. This may not be an optimal value, depending on the link between the two tunnel endpoints, but it can be adjusted via ifconfig(8).

For correct operation, there needs to be a route to the destination that is less specific than the one over the tunnel (there needs to be a route to the decapsulating host that does not run over the tunnel, as this would create a loop).

Note that the IP addresses of the tunnel endpoints may be the same as the ones defined with ifconfig(8) for the interface (as if IP is encapsulated) but need not be as, for example, when encapsulating AppleTalk.

EXAMPLES
Configuration example:

    Host X ---- Host A ------------ tunnel ------------ Cisco D ---- Host E
                   \                                      /
                    \                                    /
                     +------ Host B ------ Host C ------+

On Host A (OpenBSD):

    # route add default B
    # ifconfig greN create
    # ifconfig greN A D netmask 0xffffffff linkX up
    # ifconfig greN tunnel A D
    # route add E D

On Host D (Cisco):

    Interface TunnelX
     ip unnumbered D   ! e.g. address from Ethernet interface
     tunnel source D   ! e.g. address from Ethernet interface
     tunnel destination A
    ip route C <some interface and mask>
    ip route A mask C
    ip route X mask tunnelX

OR

On Host D (OpenBSD):

    # route add default C
    # ifconfig greN create
    # ifconfig greN D A
    # ifconfig greN tunnel D A

To reach Host A over the tunnel (from Host D), there has to be an alias on Host A for the Ethernet interface:

    # ifconfig <etherif> alias Y

and on the Cisco:

    ip route Y mask tunnelX

Keepalive packets may optionally be sent to the remote endpoint, which decapsulates and returns them, allowing tunnel failure to be detected. Enable them like this:

    # ifconfig greN keepalive period count

This will send a keepalive packet every period seconds. If no response is received in count * period seconds, the link is considered down. To return keepalives, the remote host must be configured to forward packets:

    # sysctl net.inet.ip.forwarding=1

If pf(4) is enabled then it is necessary to add a pass rule specific for the keepalive packets. The rule must use no state because the keepalive packet is entering the network stack multiple times. In most cases the following should work:

    pass quick on gre proto gre no state

SEE ALSO
inet(4), ip(4), netintro(4), options(4), hostname.if(5), protocols(5), ifconfig(8), netstart(8), sysctl(8)

STANDARDS
S. Hanks, T. Li, D. Farinacci, P. Traina, October 1994, RFC 1701, Generic Routing Encapsulation (GRE).

S. Hanks, T. Li, D. Farinacci, P. Traina, October 1994, RFC 1702, Generic Routing Encapsulation over IPv4 networks.

C. Perkins, October 1996, RFC 2004, Minimal Encapsulation within IP.

http://www.wrec.org/Drafts/draft-ietf-wrec-web-pro-00.txt, Web Cache Coordination Protocol V1.0.

http://www.wrec.org/Drafts/draft-wilson-wrec-wccp-v2-00.txt, Web Cache Coordination Protocol V2.0.

AUTHORS
Heiko W. Rupp <hwr@pilhuhn.de>

BUGS
The GRE RFC is not yet fully implemented (no GRE options).

The redirect header for WCCPv2 GRE encapsulated packets is skipped.