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