unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (OpenBSD-5.7)
Page:
Section:
Apropos / Subsearch:
optional field

GRE(4)                   BSD Kernel Interfaces Manual                   GRE(4)

NAME
     gre -- encapsulating network device

SYNOPSIS
     pseudo-device gre

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

     GRE, WCCPv1, and MobileIP are enabled with the following sysctl(3) vari-
     ables respectively in /etc/sysctl.conf:

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

     net.inet.gre.wccp        Allow WCCPv1-style GRE packets into the system
                              (depends on the above).

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

     A gre 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).

     This driver currently supports the following modes of operation:

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

     MOBILE encapsulation (IP protocol number 55).
          Datagrams are encapsulated into IP, but with a much smaller encapsu-
          lation header.  This protocol only supports IP in IP encapsulation,
          and is intended for use with mobile IP.

     The network interfaces are named gre0, gre1, etc.  The number of inter-
     faces is given by the corresponding pseudo-device line in the system con-
     figuration file.  gre interfaces support the following ioctl(2)s:

     GRESADDRS struct ifreq *
             Set the IP address of the local tunnel end.

     GRESADDRD struct ifreq *
             Set the IP address of the remote tunnel end.

     GREGADDRS struct ifreq *
             Query the IP address that is set for the local tunnel end.

     GREGADDRD struct ifreq *
             Query the IP address that is set for the remote tunnel end.

     GRESPROTO struct ifreq *
             Set the operation mode to the specified IP protocol value.  The
             protocol is passed to the interface in the ifr_flags field of the
             ifreq structure.  The operation mode can also be set with the
             following modifiers to ifconfig(8):

                   link0   IPPROTO_GRE
                   -link0  IPPROTO_MOBILE

     GREGPROTO struct ifreq *
             Query operation mode.

     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 encapsu-
     lated), but need not be, as e.g. 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

NOTES
     The MTU of gre interfaces 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.  It can be adjusted via
     ifconfig(8).

     For correct operation, the gre device needs 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.)

     In order for ifconfig(8) to actually mark the interface as up, the key-
     word up must be given last on its command line.

     The kernel must be set to forward datagrams by issuing the appropriate
     option to sysctl(8).

     The GRE interface will accept WCCPv1-style GRE encapsulated packets from
     a Cisco router.  Some magic with the packet filter configuration and a
     caching proxy like squid are needed to do anything useful with these
     packets.

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, and P. Traina, Generic Routing
     Encapsulation (GRE), RFC 1701, October 1994.

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

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

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

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

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

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

     For the WCCP GRE encapsulated packets we can only reliably accept WCCPv1
     format; WCCPv2 formatted packets add another header which will skew the
     decode, and results are not defined (i.e. don't do WCCPv2).

BSD                            October 19, 2013                            BSD