xref: /openbsd/share/man/man4/gre.4 (revision 891d7ab6)
1.\" $OpenBSD: gre.4,v 1.33 2011/04/04 15:54:07 claudio Exp $
2.\" $NetBSD: gre.4,v 1.10 1999/12/22 14:55:49 kleink Exp $
3.\"
4.\" Copyright 1998 (c) The NetBSD Foundation, Inc.
5.\" All rights reserved.
6.\"
7.\" This code is derived from software contributed to The NetBSD Foundation
8.\" by Heiko W.Rupp <hwr@pilhuhn.de>
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\" 2. Redistributions in binary form must reproduce the above copyright
16.\"    notice, this list of conditions and the following disclaimer in the
17.\"    documentation and/or other materials provided with the distribution.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21.\" TO, THE  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27.\" CONTRACT, STRICT  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28.\" ARISING IN ANY WAY  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd $Mdocdate: April 4 2011 $
32.Dt GRE 4
33.Os
34.Sh NAME
35.Nm gre
36.Nd encapsulating network device
37.Sh SYNOPSIS
38.Cd "pseudo-device gre"
39.Sh DESCRIPTION
40The
41.Nm
42network interface allows tunnel construction using the Cisco GRE or
43the Mobile-IP (RFC 2004) encapsulation protocols.
44.Pp
45.Tn GRE ,
46.Tn WCCPv1 ,
47and
48.Tn MobileIP
49are enabled with the following
50.Xr sysctl 3
51variables respectively in
52.Pa /etc/sysctl.conf :
53.Bl -tag -width "net.inet.mobileip.allow"
54.It Va net.inet.gre.allow
55Allow GRE packets in and out of the system.
56.It Va net.inet.gre.wccp
57Allow WCCPv1-style GRE packets into the system (depends on the above).
58.It Va net.inet.mobileip.allow
59Allow MobileIP packets in and out of the system.
60.El
61.Pp
62A
63.Nm
64interface can be created at runtime using the
65.Ic ifconfig gre Ns Ar N Ic create
66command or by setting up a
67.Xr hostname.if 5
68configuration file for
69.Xr netstart 8 .
70.Pp
71This driver currently supports the following modes of operation:
72.Bl -tag -width abc
73.It GRE encapsulation (IP protocol number 47).
74Encapsulated datagrams are prepended by an outer datagram and a GRE header.
75The GRE header specifies the type of the encapsulated datagram
76and thus allows for tunneling other protocols than IP like
77e.g. AppleTalk.
78GRE mode is the default tunnel mode on Cisco routers.
79This is also the default mode of operation of the
80.Nm
81interfaces.
82.It MOBILE encapsulation (IP protocol number 55).
83Datagrams are encapsulated into IP, but with a much smaller
84encapsulation header.
85This protocol only supports IP in IP encapsulation, and is intended
86for use with mobile IP.
87.El
88.Pp
89The network interfaces are named
90.Li gre0 ,
91.Li gre1 ,
92etc.
93The number of interfaces is given by the corresponding
94.Ic pseudo-device
95line in the system configuration file.
96.Nm gre
97interfaces support the following
98.Xr ioctl 2 Ns s :
99.Bl -tag -width Ds
100.It Dv GRESADDRS Fa "struct ifreq *"
101Set the IP address of the local tunnel end.
102.It Dv GRESADDRD Fa "struct ifreq *"
103Set the IP address of the remote tunnel end.
104.It Dv GREGADDRS Fa "struct ifreq *"
105Query the IP address that is set for the local tunnel end.
106.It Dv GREGADDRD Fa "struct ifreq *"
107Query the IP address that is set for the remote tunnel end.
108.It Dv GRESPROTO Fa "struct ifreq *"
109Set the operation mode to the specified IP protocol value.
110The protocol is passed to the interface in the
111.Va ifr_flags
112field of the
113.Vt ifreq
114structure.
115The operation mode can also be set with the following modifiers to
116.Xr ifconfig 8 :
117.Pp
118.Bl -tag -width "-link0" -offset indent -compact
119.It Cm link0
120.Dv IPPROTO_GRE
121.It Cm -link0
122.Dv IPPROTO_MOBILE
123.El
124.It Dv GREGPROTO Fa "struct ifreq *"
125Query operation mode.
126.El
127.Pp
128Note that the IP addresses of the tunnel endpoints may be the same as the
129ones defined with
130.Xr ifconfig 8
131for the interface (as if IP is encapsulated), but need not be, as e.g. when
132encapsulating AppleTalk.
133.Sh EXAMPLES
134Configuration example:
135.Bd -literal
136Host X ---- Host A ------------ tunnel ------------ Cisco D ---- Host E
137               \e                                      /
138                \e                                    /
139                 +------ Host B ------ Host C ------+
140.Ed
141.Pp
142On Host A (OpenBSD):
143.Bd -literal -offset indent
144# route add default B
145# ifconfig greN create
146# ifconfig greN A D netmask 0xffffffff linkX up
147# ifconfig greN tunnel A D
148# route add E D
149.Ed
150.Pp
151On Host D (Cisco):
152.Bd -literal -offset indent
153Interface TunnelX
154 ip unnumbered D   ! e.g. address from Ethernet interface
155 tunnel source D   ! e.g. address from Ethernet interface
156 tunnel destination A
157ip route C <some interface and mask>
158ip route A mask C
159ip route X mask tunnelX
160.Ed
161.Pp
162OR
163.Pp
164On Host D (OpenBSD):
165.Bd -literal -offset indent
166# route add default C
167# ifconfig greN create
168# ifconfig greN D A
169# ifconfig greN tunnel D A
170.Ed
171.Pp
172To reach Host A over the tunnel (from Host D), there has to be an
173alias on Host A for the Ethernet interface:
174.Pp
175.Dl # ifconfig <etherif> alias Y
176.Pp
177and on the Cisco:
178.Pp
179.Dl ip route Y mask tunnelX
180.Pp
181Keepalive packets may optionally be sent to the remote endpoint, which
182decapsulates and returns them, allowing tunnel failure to be detected.
183Enable them like this:
184.Bd -literal -offset indent
185# ifconfig greN keepalive period count
186.Ed
187.Pp
188This will send a keepalive packet every
189.Ar period
190seconds.
191If no response is received in
192.Ar count
193*
194.Ar period
195seconds, the link is considered down.
196To return keepalives, the remote host must be configured to forward packets:
197.Bd -literal -offset indent
198# sysctl net.inet.ip.forwarding=1
199.Ed
200.Sh NOTES
201The MTU of
202.Nm
203interfaces is set to 1476 by default to match the value used by Cisco routers.
204This may not be an optimal value, depending on the link between the two tunnel
205endpoints.
206It can be adjusted via
207.Xr ifconfig 8 .
208.Pp
209For correct operation, the
210.Nm
211device needs a route to the destination, that is less specific than the
212one over the tunnel.
213(There needs to be a route to the decapsulating host that
214does not run over the tunnel, as this would create a loop.)
215.Pp
216In order for
217.Xr ifconfig 8
218to actually mark the interface as up, the keyword
219.Cm up
220must be given last on its command line.
221.Pp
222The kernel must be set to forward datagrams by issuing the appropriate
223option to
224.Xr sysctl 8 .
225.Pp
226The GRE interface will accept WCCPv1-style GRE encapsulated packets
227from a Cisco router.
228Some magic with the packet filter configuration
229and a caching proxy like squid are needed to do anything useful with
230these packets.
231.Sh SEE ALSO
232.Xr atalk 4 ,
233.Xr inet 4 ,
234.Xr ip 4 ,
235.Xr netintro 4 ,
236.Xr options 4 ,
237.Xr hostname.if 5 ,
238.Xr protocols 5 ,
239.Xr ifconfig 8 ,
240.Xr netstart 8 ,
241.Xr sysctl 8
242.Rs
243.%R RFC 1701
244.%T Generic Routing Encapsulation
245.Re
246.Rs
247.%R RFC 1702
248.%T Generic Routing Encapsulation over IPv4 networks
249.Re
250.Rs
251.%R RFC 2004
252.%T Minimal Encapsulation within IP
253.Re
254.Rs
255.%O http://www.wrec.org/Drafts/draft-ietf-wrec-web-pro-00.txt
256.%T Web Cache Coordination Protocol V1.0
257.Re
258.Rs
259.%O http://www.wrec.org/Drafts/draft-wilson-wrec-wccp-v2-00.txt
260.%T Web Cache Coordination Protocol V2.0
261.Re
262.Sh AUTHORS
263.An Heiko W.Rupp Aq hwr@pilhuhn.de
264.Sh BUGS
265GRE RFC not yet fully implemented (no GRE options).
266.Pp
267For the WCCP GRE encapsulated packets we can only reliably accept
268WCCPv1 format; WCCPv2 formatted packets add another header which will
269skew the decode, and results are not defined (i.e. don't do WCCPv2).
270