gre.4 revision 1.20
$OpenBSD: gre.4,v 1.20 2003/11/09 16:06:07 jmc 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.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by the NetBSD
Foundation, Inc. and its contributors.
4. Neither the name of the The NetBSD Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

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 September 13, 1998 .Dt GRE 4 .Os .Sh NAME .Nm gre .Nd encapsulating network device .Sh SYNOPSIS .Cd pseudo-device gre Op Ar count .Sh NOTE .Tn GRE , .Tn WCCPv1 , and .Tn MobileIP are enabled with the following .Xr sysctl 3 variables respectively in

a /etc/sysctl.conf : l -tag -width xxxxxxxxxxxxxxxxxxxxx t net.inet.gre.allow Allow GRE packets in and out of the system. t net.inet.gre.wccp Allow WCCPv2-style GRE packets into the system (depends on the above). t net.inet.mobileip.allow Allow MobileIP packets in and out of the system. .El .Sh DESCRIPTION The .Nm network interface allows tunnel construction using the Cisco GRE or the Mobile-IP (RFC 2004) encapsulation protocols.

p This driver currently supports the following modes of operation: l -tag -width abc t 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 datagram 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 .Sy gre Ns Ar X interfaces. t MOBILE encapsulation (IP protocol number 55). Datagrams 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. .El

p The network interfaces are named .Sy gre Ns Ar 0 , .Sy gre Ns Ar 1 , etc. The number of interfaces is given by the corresponding .Sy pseudo-device line in the system config file. .Nm gre interfaces support the following .Xr ioctl 2 Ns s : l -tag -width aaa t GRESADDRS: Set the IP address of the local tunnel end. t GRESADDRD: Set the IP address of the remote tunnel end. t GREGADDRS: Query the IP address that is set for the local tunnel end. t GREGADDRD: Query the IP address that is set for the remote tunnel end. t GRESPROTO: Set the operation mode to the specified IP protocol value. The protocol is passed to the interface in (struct ifreq)->ifr_flags. The operation mode can also be given as l -tag -width bbb t link0 IPPROTO_GRE t -link0 IPPROTO_MOBILE .El t GREGPROTO: Query operation mode. .El

p Note that the IP addresses of the tunnel endpoints may be the same as the ones defined with .Xr ifconfig 8 for the interface (as if IP is encapsulated), but need not be, as e.g. when encapsulating AppleTalk. .Sh EXAMPLES Configuration example: d -literal Host X-- Host A ----------------tunnel---------- Cisco D------Host E \ | \ / +------Host B----------Host C----------+ .Ed On Host A (OpenBSD): d -literal -offset indent # route add default B # ifconfig greN A D netmask 0xffffffff linkX 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 (OpenBSD): d -literal -offset indent # route add default C # 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: .Dl ifconfig <etherif> alias Y and on the Cisco .Dl ip route Y mask tunnelX .Sh NOTE For correct operation, the .Nm 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.)

p In order for .Xr ifconfig 8 to actually mark the interface as up, the keyword ``up'' must be given last on its command line.

p The kernel must be set to forward datagrams by including option ``GATEWAY'' in the kernel config file and issuing the appropriate option to .Xr sysctl 8 .

p 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. .Sh SEE ALSO .Xr atalk 4 , .Xr inet 4 , .Xr ip 4 , .Xr netintro 4 , .Xr options 4 , .Xr protocols 5 , .Xr ifconfig 8 , .Xr sysctl 8

p A description of GRE encapsulation can be found in RFC 1701, RFC 1702.

p A description of MOBILE encapsulation can be found in RFC 2004.

p A description of WCCPv1 can be found in draft-ietf-wrec-web-pro-00.txt, and WCCPv2 in draft-wilson-wrec-wccp-v2-00.txt. Both of these documents can be found at http://www.wrec.org/ (at the time of this writing). .Sh AUTHORS .An Heiko W.Rupp Aq hwr@pilhuhn.de .Sh BUGS The compute_route() code in

a net/if_gre.c toggles the last bit of the IP-address to provoke the search for a less specific route than the one directly over the tunnel to prevent loops. This is possibly not the best solution.

p To avoid the address munging described above, turn on the link1 flag on the ifconfig command line. This implies that the GRE packet destination and the remote host are not the same IP addresses, and that the GRE destination does not route over the .Sy gre Ns Ar X interface itself.

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

p 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).