1 .\" $NetBSD: gre.4,v 1.28 2002/06/10 02:49:35 itojun Exp $
3 .\" Copyright 1998 (c) The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Heiko W.Rupp <hwr@pilhuhn.de>
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
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.
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.
44 .Nd encapsulating network device
50 network interface pseudo device encapsulates datagrams
52 These encapsulated datagrams are routed to a destination host,
53 where they are decapsulated and further routed to their final destination.
56 appears to the inner datagrams as one hop.
59 interfaces are dynamically created and destroyed with the
66 This driver currently supports the following modes of operation:
67 .Bl -tag -width indent
68 .It "GRE encapsulation (IP protocol number 47)"
69 Encapsulated datagrams are
70 prepended an outer datagram and a GRE header.
71 The GRE header specifies
72 the type of the encapsulated datagram and thus allows for tunneling other
73 protocols than IP like e.g.\& AppleTalk.
74 GRE mode is also the default tunnel mode on Cisco routers.
75 This is also the default mode of operation of the
78 As part of the GRE mode,
80 also supports Cisco WCCP protocol, both version 1 and version 2.
81 Since there is no reliable way to distinguish between WCCP versions, it
82 should be configured manually using the
87 flag is not set (default), then WCCP version 1 is selected.
88 .It "MOBILE encapsulation (IP protocol number 55)"
90 encapsulated into IP, but with a shorter encapsulation.
92 IP header is modified and the modifications are inserted between the
93 so modified header and the original payload.
96 only for IP-in-IP encapsulation.
101 interfaces support a number of
104 .Bl -tag -width ".Dv GRESADDRS"
106 Set the IP address of the local tunnel end.
107 This is the source address
108 set by or displayed by
114 Set the IP address of the remote tunnel end.
115 This is the destination address
116 set by or displayed by
122 Query the IP address that is set for the local tunnel end.
124 address the encapsulation header carries as local address (i.e., the real
125 address of the tunnel start point).
127 Query the IP address that is set for the remote tunnel end.
129 address the encapsulated packets are sent to (i.e., the real address of
130 the remote tunnel endpoint).
132 Set the operation mode to the specified IP protocol value.
134 protocol is passed to the interface in
135 .Po Vt "struct ifreq" Pc Ns Li -> Ns Va ifr_flags .
136 The operation mode can also be given as
138 .Bl -tag -width ".Cm -link0" -compact
150 flag is not used to choose encapsulation, but to modify the
151 internal route search for the remote tunnel endpoint, see the
155 Query operation mode.
158 Note that the IP addresses of the tunnel endpoints may be the same as the
161 for the interface (as if IP is encapsulated), but need not be, as e.g.\& when
162 encapsulating AppleTalk.
164 Configuration example:
166 Host X-- Host A ----------------tunnel---------- Cisco D------Host E
169 +------Host B----------Host C----------+
174 .Bd -literal -offset indent
177 ifconfig greN A D netmask 0xffffffff linkX up
178 ifconfig greN tunnel A D
183 .Bd -literal -offset indent
185 ip unnumbered D ! e.g. address from Ethernet interface
186 tunnel source D ! e.g. address from Ethernet interface
188 ip route C <some interface and mask>
190 ip route X mask tunnelX
197 .Bd -literal -offset indent
201 ifconfig greN tunnel D A
204 If all goes well, you should see packets flowing ;-)
206 If you want to reach Host A over the tunnel (from Host D (Cisco)), then
207 you have to have an alias on Host A for e.g.\& the Ethernet interface like:
209 .Dl "ifconfig <etherif> alias Y"
213 .Dl "ip route Y mask tunnelX"
215 A similar setup can be used to create a link between two private networks
216 (for example in the 192.168 subnet) over the Internet:
218 192.168.1.* --- Router A -------tunnel-------- Router B --- 192.168.2.*
221 +------ the Internet ------+
224 Assuming router A has the (external) IP address A and the internal address
225 192.168.1.1, while router B has external address B and internal address
226 192.168.2.1, the following commands will configure the tunnel:
229 .Bd -literal -offset indent
231 ifconfig greN 192.168.1.1 192.168.2.1 link1
232 ifconfig greN tunnel A B
233 route add -net 192.168.2 -netmask 255.255.255.0 192.168.2.1
237 .Bd -literal -offset indent
239 ifconfig greN 192.168.2.1 192.168.1.1 link1
240 ifconfig greN tunnel B A
241 route add -net 192.168.1 -netmask 255.255.255.0 192.168.1.1
244 Note that this is a safe situation where the
246 flag (as discussed in the
248 section below) may (and probably should) be set.
252 interfaces is set to 1476 by default, to match the value used by Cisco routers.
253 This may not be an optimal value, depending on the link between the two tunnel
255 It can be adjusted via
258 For correct operation, the
260 device needs a route to the destination that is less specific than the
262 (Basically, there needs to be a route to the decapsulating host that
263 does not run over the tunnel, as this would be a loop.)
264 If the addresses are ambiguous, doing the
265 .Nm ifconfig Cm tunnel
270 IP addresses will help to find a route outside the tunnel.
274 to actually mark the interface as
278 must be given last on its command line.
280 The kernel must be set to forward datagrams by setting the
283 variable to non-zero.
295 A description of GRE encapsulation can be found in RFC 1701 and RFC 1702.
297 A description of MOBILE encapsulation can be found in RFC 2004.
299 .An Heiko W.Rupp Aq hwr@pilhuhn.de
305 toggles the last bit of the
306 IP-address to provoke the search for a less specific route than the
307 one directly over the tunnel to prevent loops.
308 This is possibly not the best solution.
310 To avoid the address munging described above, turn on the
315 This implies that the GRE packet destination and the ifconfig remote host
316 are not the same IP addresses, and that the GRE destination does not route
321 The GRE RFCs are not yet fully implemented (no GRE options).