xref: /openbsd/share/man/man4/gre.4 (revision 7b36286a)
1.\" $OpenBSD: gre.4,v 1.31 2008/06/26 05:42:06 ray 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: June 26 2008 $
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.Sh NOTES
181The MTU of
182.Nm
183interfaces is set to 1476 by default to match the value used by Cisco routers.
184This may not be an optimal value, depending on the link between the two tunnel
185endpoints.
186It can be adjusted via
187.Xr ifconfig 8 .
188.Pp
189For correct operation, the
190.Nm
191device needs a route to the destination, that is less specific than the
192one over the tunnel.
193(There needs to be a route to the decapsulating host that
194does not run over the tunnel, as this would create a loop.)
195.Pp
196In order for
197.Xr ifconfig 8
198to actually mark the interface as up, the keyword
199.Cm up
200must be given last on its command line.
201.Pp
202The kernel must be set to forward datagrams by issuing the appropriate
203option to
204.Xr sysctl 8 .
205.Pp
206The GRE interface will accept WCCPv1-style GRE encapsulated packets
207from a Cisco router.
208Some magic with the packet filter configuration
209and a caching proxy like squid are needed to do anything useful with
210these packets.
211.Sh SEE ALSO
212.Xr atalk 4 ,
213.Xr inet 4 ,
214.Xr ip 4 ,
215.Xr netintro 4 ,
216.Xr options 4 ,
217.Xr hostname.if 5 ,
218.Xr protocols 5 ,
219.Xr ifconfig 8 ,
220.Xr netstart 8 ,
221.Xr sysctl 8
222.Rs
223.%R RFC 1701
224.%T Generic Routing Encapsulation
225.Re
226.Rs
227.%R RFC 1702
228.%T Generic Routing Encapsulation over IPv4 networks
229.Re
230.Rs
231.%R RFC 2004
232.%T Minimal Encapsulation within IP
233.Re
234.Rs
235.%O http://www.wrec.org/Drafts/draft-ietf-wrec-web-pro-00.txt
236.%T Web Cache Coordination Protocol V1.0
237.Re
238.Rs
239.%O http://www.wrec.org/Drafts/draft-wilson-wrec-wccp-v2-00.txt
240.%T Web Cache Coordination Protocol V2.0
241.Re
242.Sh AUTHORS
243.An Heiko W.Rupp Aq hwr@pilhuhn.de
244.Sh BUGS
245The
246.Fn compute_route
247code in
248.Pa sys/net/if_gre.c
249toggles the last bit of the IP address to provoke the search for a less
250specific route than the one directly over the tunnel to prevent loops.
251This is possibly not the best solution.
252.Pp
253To avoid the address munging described above, turn on the
254.Cm link1
255flag on the
256.Xr ifconfig 8
257command line.
258This implies that the GRE packet destination and the remote host are not
259the same IP addresses, and that the GRE destination does not route over
260the
261.Nm Ns Ar X
262interface itself.
263.Pp
264GRE RFC not yet fully implemented (no GRE options).
265.Pp
266For the WCCP GRE encapsulated packets we can only reliably accept
267WCCPv1 format; WCCPv2 formatted packets add another header which will
268skew the decode, and results are not defined (i.e. don't do WCCPv2).
269