gre.4 revision 1.54
$OpenBSD: gre.4,v 1.54 2018/02/15 02:09:21 dlg Exp $
$NetBSD: gre.4,v 1.10 1999/12/22 14:55:49 kleink Exp $

Copyright 1998 (c) The NetBSD Foundation, Inc.
All rights reserved.

This code is derived from software contributed to The NetBSD Foundation
by Heiko W. Rupp <hwr@pilhuhn.de>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

.Dd $Mdocdate: February 15 2018 $ .Dt GRE 4 .Os .Sh NAME .Nm gre , .Nm egre .Nd encapsulating network device .Sh SYNOPSIS .Cd "pseudo-device gre" .Sh DESCRIPTION The .Nm gre pseudo-device provides interfaces for tunnelling protocols across IPv4 and IPv6 networks using the Generic Routing Encapsulation (GRE) encapsulation protocol.

p GRE datagrams (IP protocol number 47) consist of a GRE and outer IP header encapsulationg another protocols datagram. The GRE header specifies the type of the encapsulated datagram, allowing for the tunneling of multiple protocols. Different tunnels between the same endpoints may be distinguised by an optional Key field in the GRE header.

p This pseudo driver provides the clonable network interfaces: l -tag -width nvgreXXX t Nm gre Layer 3 protocols, specifically IPv4, IPv6, and MPLS, are encapsulated by GRE and IP headers. The MTU is set to 1476 by default to match the value used by Cisco routers. .Nm gre also supports reception of WCCP encapsulated IPv4 packets. t Nm egre Layer 2 Ethernet packets are encapsulated by GRE and IP headers. Transparent Ethernet (0x6558) is used as the protocol identifier in the GRE header as per RFC 1701. The MTU is set to 1500 by default. .El

p GRE and WCCP are enabled with the following .Xr sysctl 2 variables respectively in

a /etc/sysctl.conf : l -tag -width "net.inet.wccp.allow" t Va net.inet.gre.allow Allow GRE packets in and out of the system. t Va 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 .Va gre.allow to be set. .El

p .Nm gre and .Nm egre interfaces can be created at runtime using the c ifconfig iface Ns Ar N Ic create command or by setting up a .Xr hostname.if 5 configuration file for .Xr netstart 8 .

p The default MTU may not be an optimal value depending on the link between the tunnel endpoints, but can be adjusted.

p For correct operation, the route to the tunnel destination must not go over the interface itself. This can be implemented by adding a distinct or a more specific route to the tunnel destination than the hosts or networks routed via the tunnel interface. Alternatively, the tunnel traffic may be configured in a separate routing table to the encapsulated traffic.

p Each interface supports use of the optional GRE Key field as a virtual network idenfitier.

p .Nm gre optionally supports sending keepalive packets to the remote endpoint, which allows tunnel failure to be detected. .Sh EXAMPLES .Nm gre Configuration example: d -literal Host X ---- Host A ------------ tunnel ------------ Cisco D ---- Host E \e / \e / +------ Host B ------ Host C ------+ .Ed

p On Host A

q Ox : d -literal -offset indent # route add default B # ifconfig greN create # ifconfig greN A D netmask 0xffffffff up # ifconfig greN tunnel A D # route add E D .Ed

p On Host D (Cisco): d -literal -offset indent 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 .Ed

p OR

p On Host D

q Ox : d -literal -offset indent # route add default C # ifconfig greN create # ifconfig greN D A # ifconfig greN tunnel D A .Ed

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

p .Dl # ifconfig <etherif> alias Y

p and on the Cisco:

p .Dl ip route Y mask tunnelX

p Keepalive packets may be enabled like this: d -literal -offset indent # ifconfig greN keepalive period count .Ed

p This will send a keepalive packet every .Ar period seconds. If no response is received in .Ar count * .Ar period seconds, the link is considered down. To return keepalives, the remote host must be configured to forward packets: d -literal -offset indent # sysctl net.inet.ip.forwarding=1 .Ed

p If .Xr pf 4 is enabled then it is necessary to add a pass rule specific for the keepalive packets. The rule must use .Cm no state because the keepalive packet is entering the network stack multiple times. In most cases the following should work: d -literal -offset indent pass quick on gre proto gre no state .Ed .Sh SEE ALSO .Xr inet 4 , .Xr ip 4 , .Xr netintro 4 , .Xr options 4 , .Xr hostname.if 5 , .Xr protocols 5 , .Xr ifconfig 8 , .Xr netstart 8 , .Xr sysctl 8 .Sh STANDARDS .Rs .%A S. Hanks .%A "T. Li" .%A D. Farinacci .%A P. Traina .%D October 1994 .%R RFC 1701 .%T Generic Routing Encapsulation (GRE) .Re

p .Rs .%A S. Hanks .%A "T. Li" .%A D. Farinacci .%A P. Traina .%D October 1994 .%R RFC 1702 .%T Generic Routing Encapsulation over IPv4 networks .Re

p .Rs .%A D. Farinacci .%A "T. Li" .%A S. Hanks .%A D. Meyer .%A P. Traina .%D March 2000 .%R RFC 2784 .%T Generic Routing Encapsulation (GRE) .Re

p .Rs .%A G. Dommety .%D September 2000 .%R RFC 2890 .%T Key and Sequence Number Extensions to GRE .Re

p .Rs .%U https://tools.ietf.org/html/draft-ietf-wrec-web-pro-00.txt .%T Web Cache Coordination Protocol V1.0 .Re

p .Rs .%U https://tools.ietf.org/html/draft-wilson-wrec-wccp-v2-00.txt .%T Web Cache Coordination Protocol V2.0 .Re .Sh AUTHORS .An Heiko W. Rupp Aq Mt hwr@pilhuhn.de .Sh CAVEATS

p RFC 1701 and RFC 2890 describe a variety of optional GRE header fields in the protocol that are not implemented in the .Nm gre driver. The only optional field the driver implements support for is the Key header.

p The redirect header for WCCPv2 GRE encapsulated packets is skipped.