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