Merge branch 'vendor/OPENSSL'
[dragonfly.git] / share / man / man4 / gre.4
1 .\" $NetBSD: gre.4,v 1.28 2002/06/10 02:49:35 itojun Exp $
2 .\"
3 .\" Copyright 1998 (c) The NetBSD Foundation, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Heiko W.Rupp <hwr@pilhuhn.de>
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\"    must display the following acknowledgement:
19 .\"     This product includes software developed by the NetBSD
20 .\"     Foundation, Inc. and its contributors.
21 .\" 4. Neither the name of the The NetBSD Foundation nor the names of its
22 .\"    contributors may be used to endorse or promote products derived
23 .\"    from this software without specific prior written permission.
24 .\"
25 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 .\" TO, THE  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 .\" POSSIBILITY OF SUCH DAMAGE.
36 .\"
37 .\" $FreeBSD: src/share/man/man4/gre.4,v 1.7 2006/10/19 07:41:47 danger Exp $
38 .\" $DragonFly: src/share/man/man4/gre.4,v 1.6 2007/11/12 19:07:40 swildner Exp $
39 .\"
40 .Dd November 11, 2007
41 .Dt GRE 4
42 .Os
43 .Sh NAME
44 .Nm gre
45 .Nd encapsulating network device
46 .Sh SYNOPSIS
47 To compile the
48 .Ns Nm
49 device into the kernel, place the following line in the kernel
50 configuration file:
51 .Bd -ragged -offset indent
52 .Cd "pseudo-device gre"
53 .Ed
54 .Pp
55 Alternatively, to load the
56 .Ns Nm
57 device as a module at boot time, place the following line in
58 .Xr loader.conf 5 :
59 .Bd -literal -offset indent
60 if_gre_load="YES"
61 .Ed
62 .Sh DESCRIPTION
63 The
64 .Nm
65 network interface pseudo device encapsulates datagrams
66 into IP.
67 These encapsulated datagrams are routed to a destination host,
68 where they are decapsulated and further routed to their final destination.
69 The
70 .Dq tunnel
71 appears to the inner datagrams as one hop.
72 .Pp
73 .Nm
74 interfaces are dynamically created and destroyed with the
75 .Xr ifconfig 8
76 .Cm create
77 and
78 .Cm destroy
79 subcommands.
80 .Pp
81 This driver currently supports the following modes of operation:
82 .Bl -tag -width indent
83 .It "GRE encapsulation (IP protocol number 47)"
84 Encapsulated datagrams are
85 prepended an outer datagram and a GRE header.
86 The GRE header specifies
87 the type of the encapsulated datagram and thus allows for tunneling other
88 protocols than IP like e.g.\& AppleTalk.
89 GRE mode is also the default tunnel mode on Cisco routers.
90 This is also the default mode of operation of the
91 .Nm
92 interfaces.
93 .\"As part of the GRE mode,
94 .\".Nm
95 .\"also supports Cisco WCCP protocol, both version 1 and version 2.
96 .\"Since there is no reliable way to distinguish between WCCP versions, it
97 .\"should be configured manually using the
98 .\".Cm link2
99 .\"flag.
100 .\"If the
101 .\".Cm link2
102 .\"flag is not set (default), then WCCP version 1 is selected.
103 .It "MOBILE encapsulation (IP protocol number 55)"
104 Datagrams are
105 encapsulated into IP, but with a shorter encapsulation.
106 The original
107 IP header is modified and the modifications are inserted between the
108 so modified header and the original payload.
109 Like
110 .Xr gif 4 ,
111 only for IP-in-IP encapsulation.
112 .El
113 .Pp
114 The
115 .Nm
116 interfaces support a number of
117 .Xr ioctl 2 Ns s ,
118 such as:
119 .Bl -tag -width ".Dv GRESADDRS"
120 .It Dv GRESADDRS
121 Set the IP address of the local tunnel end.
122 This is the source address
123 set by or displayed by
124 .Xr ifconfig 8
125 for the
126 .Nm
127 interface.
128 .It Dv GRESADDRD
129 Set the IP address of the remote tunnel end.
130 This is the destination address
131 set by or displayed by
132 .Xr ifconfig 8
133 for the
134 .Nm
135 interface.
136 .It Dv GREGADDRS
137 Query the IP address that is set for the local tunnel end.
138 This is the
139 address the encapsulation header carries as local address (i.e., the real
140 address of the tunnel start point).
141 .It Dv GREGADDRD
142 Query the IP address that is set for the remote tunnel end.
143 This is the
144 address the encapsulated packets are sent to (i.e., the real address of
145 the remote tunnel endpoint).
146 .It Dv GRESPROTO
147 Set the operation mode to the specified IP protocol value.
148 The
149 protocol is passed to the interface in
150 .Po Vt "struct ifreq" Pc Ns Li -> Ns Va ifr_flags .
151 The operation mode can also be given as
152 .Pp
153 .Bl -tag -width ".Cm -link0" -compact
154 .It Cm link0
155 .Dv IPPROTO_GRE
156 .It Cm -link0
157 .Dv IPPROTO_MOBILE
158 .El
159 .Pp
160 to
161 .Xr ifconfig 8 .
162 .Pp
163 The
164 .Cm link1
165 flag is not used to choose encapsulation, but to modify the
166 internal route search for the remote tunnel endpoint, see the
167 .Sx BUGS
168 section below.
169 .It Dv GREGPROTO
170 Query operation mode.
171 .El
172 .Pp
173 Note that the IP addresses of the tunnel endpoints may be the same as the
174 ones defined with
175 .Xr ifconfig 8
176 for the interface (as if IP is encapsulated), but need not be, as e.g.\& when
177 encapsulating AppleTalk.
178 .Sh EXAMPLES
179 Configuration example:
180 .Bd -literal
181 Host X-- Host A  ----------------tunnel---------- Cisco D------Host E
182           \\                                          |
183            \\                                        /
184             +------Host B----------Host C----------+
185 .Ed
186 .Pp
187 On host A
188 .Pq Dx :
189 .Bd -literal -offset indent
190 route add default B
191 ifconfig greN create
192 ifconfig greN A D netmask 0xffffffff linkX up
193 ifconfig greN tunnel A D
194 route add E D
195 .Ed
196 .Pp
197 On Host D (Cisco):
198 .Bd -literal -offset indent
199 Interface TunnelX
200  ip unnumbered D   ! e.g. address from Ethernet interface
201  tunnel source D   ! e.g. address from Ethernet interface
202  tunnel destination A
203 ip route C <some interface and mask>
204 ip route A mask C
205 ip route X mask tunnelX
206 .Ed
207 .Pp
208 OR
209 .Pp
210 On Host D
211 .Pq Dx :
212 .Bd -literal -offset indent
213 route add default C
214 ifconfig greN create
215 ifconfig greN D A
216 ifconfig greN tunnel D A
217 .Ed
218 .Pp
219 If all goes well, you should see packets flowing ;-)
220 .Pp
221 If you want to reach Host A over the tunnel (from Host D (Cisco)), then
222 you have to have an alias on Host A for e.g.\& the Ethernet interface like:
223 .Pp
224 .Dl "ifconfig <etherif> alias Y"
225 .Pp
226 and on the Cisco:
227 .Pp
228 .Dl "ip route Y mask tunnelX"
229 .Pp
230 A similar setup can be used to create a link between two private networks
231 (for example in the 192.168 subnet) over the Internet:
232 .Bd -literal
233 192.168.1.* --- Router A  -------tunnel-------- Router B --- 192.168.2.*
234                    \\                              /
235                     \\                            /
236                      +------ the Internet ------+
237 .Ed
238 .Pp
239 Assuming router A has the (external) IP address A and the internal address
240 192.168.1.1, while router B has external address B and internal address
241 192.168.2.1, the following commands will configure the tunnel:
242 .Pp
243 On router A:
244 .Bd -literal -offset indent
245 ifconfig greN create
246 ifconfig greN 192.168.1.1 192.168.2.1 link1
247 ifconfig greN tunnel A B
248 route add -net 192.168.2 -netmask 255.255.255.0 192.168.2.1
249 .Ed
250 .Pp
251 On router B:
252 .Bd -literal -offset indent
253 ifconfig greN create
254 ifconfig greN 192.168.2.1 192.168.1.1 link1
255 ifconfig greN tunnel B A
256 route add -net 192.168.1 -netmask 255.255.255.0 192.168.1.1
257 .Ed
258 .Pp
259 Note that this is a safe situation where the
260 .Cm link1
261 flag (as discussed in the
262 .Sx BUGS
263 section below) may (and probably should) be set.
264 .Sh NOTES
265 The MTU of
266 .Nm
267 interfaces is set to 1476 by default, to match the value used by Cisco routers.
268 This may not be an optimal value, depending on the link between the two tunnel
269 endpoints.
270 It can be adjusted via
271 .Xr ifconfig 8 .
272 .Pp
273 For correct operation, the
274 .Nm
275 device needs a route to the destination that is less specific than the
276 one over the tunnel.
277 (Basically, there needs to be a route to the decapsulating host that
278 does not run over the tunnel, as this would be a loop.)
279 If the addresses are ambiguous, doing the
280 .Nm ifconfig Cm tunnel
281 step before the
282 .Xr ifconfig 8
283 call to set the
284 .Nm
285 IP addresses will help to find a route outside the tunnel.
286 .Pp
287 In order to tell
288 .Xr ifconfig 8
289 to actually mark the interface as
290 .Dq up ,
291 the keyword
292 .Cm up
293 must be given last on its command line.
294 .Pp
295 The kernel must be set to forward datagrams by setting the
296 .Va net.inet.ip.forwarding
297 .Xr sysctl 8
298 variable to non-zero.
299 .Sh SEE ALSO
300 .\".Xr atalk 4 ,
301 .Xr gif 4 ,
302 .Xr inet 4 ,
303 .Xr ip 4 ,
304 .Xr netintro 4 ,
305 .Xr protocols 5 ,
306 .Xr ifconfig 8 ,
307 .Xr sysctl 8
308 .Pp
309 A description of GRE encapsulation can be found in RFC 1701 and RFC 1702.
310 .Pp
311 A description of MOBILE encapsulation can be found in RFC 2004.
312 .Sh AUTHORS
313 .An Heiko W.Rupp Aq hwr@pilhuhn.de
314 .Sh BUGS
315 The
316 .Fn gre_compute_route
317 code in
318 .Pa if_gre.c
319 toggles the last bit of the
320 IP-address to provoke the search for a less specific route than the
321 one directly over the tunnel to prevent loops.
322 This is possibly not the best solution.
323 .Pp
324 To avoid the address munging described above, turn on the
325 .Cm link1
326 flag on the
327 .Xr ifconfig 8
328 command line.
329 This implies that the GRE packet destination and the ifconfig remote host
330 are not the same IP addresses, and that the GRE destination does not route
331 over the
332 .Nm
333 interface itself.
334 .Pp
335 The GRE RFCs are not yet fully implemented (no GRE options).