2002-06-10 06:49:35 +04:00
|
|
|
.\" $NetBSD: gre.4,v 1.28 2002/06/10 02:49:35 itojun Exp $
|
1998-09-14 00:39:35 +04:00
|
|
|
.\"
|
|
|
|
.\" Copyright 1998 (c) The NetBSD Foundation, Inc.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Heiko W.Rupp <hwr@pilhuhn.de>
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
2001-04-04 14:02:20 +04:00
|
|
|
.\" 4. Neither the name of the The NetBSD Foundation nor the names of its
|
|
|
|
.\" contributors may be used to endorse or promote products derived
|
1998-09-14 00:39:35 +04:00
|
|
|
.\" from this software without specific prior written permission.
|
|
|
|
.\"
|
2001-04-04 14:02:20 +04:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
1998-09-14 00:39:35 +04:00
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
2001-04-04 14:02:20 +04:00
|
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
1998-09-14 00:39:35 +04:00
|
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2002-06-10 00:05:55 +04:00
|
|
|
.Dd June 9, 2002
|
1998-09-14 00:39:35 +04:00
|
|
|
.Dt GRE 4
|
1999-03-16 04:19:14 +03:00
|
|
|
.Os
|
1998-09-14 00:39:35 +04:00
|
|
|
.Sh NAME
|
|
|
|
.Nm gre
|
|
|
|
.Nd encapsulating network device
|
|
|
|
.Sh SYNOPSIS
|
2000-07-05 22:14:40 +04:00
|
|
|
.Cd pseudo-device gre
|
1998-09-14 00:39:35 +04:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
1998-09-25 12:35:20 +04:00
|
|
|
.Nm gre
|
2001-11-30 02:06:14 +03:00
|
|
|
network interface pseudo device encapsulates datagrams
|
2002-06-10 00:05:55 +04:00
|
|
|
into IP. These encapsulated datagrams are routed to a destination host,
|
1998-09-14 00:39:35 +04:00
|
|
|
where they are decapsulated and further routed to their final destination.
|
2002-06-10 00:05:55 +04:00
|
|
|
The
|
|
|
|
.Dq tunnel
|
2001-11-30 02:06:14 +03:00
|
|
|
appears to the inner datagrams as one hop.
|
1998-09-14 00:39:35 +04:00
|
|
|
.Pp
|
2000-07-05 22:14:40 +04:00
|
|
|
.Nm
|
|
|
|
interfaces are dynamically created and destroyed with the
|
|
|
|
.Xr ifconfig 8
|
|
|
|
.Cm create
|
|
|
|
and
|
|
|
|
.Cm destroy
|
|
|
|
subcommands.
|
|
|
|
.Pp
|
1998-09-30 10:13:27 +04:00
|
|
|
This driver currently supports the following modes of operation:
|
1998-09-14 00:39:35 +04:00
|
|
|
.Bl -tag -width abc
|
2002-06-10 00:05:55 +04:00
|
|
|
.It GRE encapsulation (IP protocol number 47)
|
1998-09-30 10:13:27 +04:00
|
|
|
Encapsulated datagrams are
|
2002-06-10 00:05:55 +04:00
|
|
|
prepended an outer datagram and a GRE header. The GRE header specifies
|
1998-09-14 00:39:35 +04:00
|
|
|
the type of the encapsulated datagram and thus allows for tunneling other
|
2002-06-10 00:05:55 +04:00
|
|
|
protocols than IP like e.g. AppleTalk. GRE mode is also the default tunnel
|
|
|
|
mode on Cisco routers. This is also the default mode of operation of the
|
1998-09-30 10:13:27 +04:00
|
|
|
.Sy gre Ns Ar X
|
|
|
|
interfaces.
|
2002-06-10 00:05:55 +04:00
|
|
|
.It MOBILE encapsulation (IP protocol number 55)
|
2001-04-04 14:02:20 +04:00
|
|
|
Datagrams are
|
2002-06-10 00:05:55 +04:00
|
|
|
encapsulated into IP, but with a shorter encapsulation. The original
|
1998-09-30 10:13:27 +04:00
|
|
|
IP header is modified and the modifications are inserted between the
|
2002-06-10 00:05:55 +04:00
|
|
|
so modified header and the original payload. Like
|
2002-03-04 18:14:22 +03:00
|
|
|
.Xr gif 4 ,
|
2002-06-10 00:05:55 +04:00
|
|
|
only for IP in IP encapsulation.
|
1998-09-14 00:39:35 +04:00
|
|
|
.El
|
|
|
|
.Pp
|
2002-06-09 14:44:57 +04:00
|
|
|
The
|
|
|
|
.Sy gre Ns Ar X
|
|
|
|
interfaces support a number of
|
2001-04-11 22:31:23 +04:00
|
|
|
.Xr ioctl 2 Ns s ,
|
1998-09-14 00:39:35 +04:00
|
|
|
such as:
|
|
|
|
.Bl -tag -width aaa
|
2001-04-11 22:31:23 +04:00
|
|
|
.It GRESADDRS :
|
2002-06-10 00:05:55 +04:00
|
|
|
Set the IP address of the local tunnel end. This is the source address
|
2002-06-09 14:44:57 +04:00
|
|
|
set by or displayed by ifconfig for the
|
|
|
|
.Sy gre Ns Ar X
|
|
|
|
interface.
|
2001-04-11 22:31:23 +04:00
|
|
|
.It GRESADDRD :
|
2002-06-10 00:05:55 +04:00
|
|
|
Set the IP address of the remote tunnel end. This is the destination address
|
2002-06-09 14:44:57 +04:00
|
|
|
set by or displayed by ifconfig for the
|
|
|
|
.Sy gre Ns Ar X
|
|
|
|
interface.
|
2001-04-11 22:31:23 +04:00
|
|
|
.It GREGADDRS :
|
2002-06-10 00:05:55 +04:00
|
|
|
Query the IP address that is set for the local tunnel end. This is the
|
2002-06-09 14:44:57 +04:00
|
|
|
address the encapsulation header carries as local address (i.e. the real
|
|
|
|
address of the tunnel start point.)
|
2001-04-11 22:31:23 +04:00
|
|
|
.It GREGADDRD :
|
2002-06-10 00:05:55 +04:00
|
|
|
Query the IP address that is set for the remote tunnel end. This is the
|
|
|
|
address the encapsulated packets are sent to (i.e. the real address of
|
2002-06-09 14:44:57 +04:00
|
|
|
the remote tunnel endpoint.)
|
2001-04-11 22:31:23 +04:00
|
|
|
.It GRESPROTO :
|
2002-06-10 00:05:55 +04:00
|
|
|
Set the operation mode to the specified IP protocol value. The
|
2002-02-13 11:17:26 +03:00
|
|
|
protocol is passed to the interface in (struct ifreq)-\*[Gt]ifr_flags.
|
2002-06-10 00:05:55 +04:00
|
|
|
The operation mode can also be given as
|
|
|
|
.Bl -tag -width link0xxx
|
1998-09-30 10:13:27 +04:00
|
|
|
.It link0
|
|
|
|
IPPROTO_GRE
|
2002-06-09 23:17:43 +04:00
|
|
|
.It -link0
|
1998-09-30 10:13:27 +04:00
|
|
|
IPPROTO_MOBILE
|
|
|
|
.El
|
2002-06-09 23:17:43 +04:00
|
|
|
.Pp
|
1998-09-30 10:13:27 +04:00
|
|
|
to
|
2002-06-09 23:17:43 +04:00
|
|
|
.Xr ifconfig 8 .
|
2002-06-09 16:19:39 +04:00
|
|
|
.Pp
|
2002-06-10 00:05:55 +04:00
|
|
|
The link1 flag is not used to choose encapsulation, but to modify the
|
|
|
|
internal route search for the remote tunnel endpoint, see the
|
|
|
|
.Sx BUGS
|
|
|
|
section below.
|
2001-04-11 22:31:23 +04:00
|
|
|
.It GREGPROTO :
|
1998-09-14 00:39:35 +04:00
|
|
|
Query operation mode.
|
|
|
|
.El
|
|
|
|
.Pp
|
1998-10-31 15:37:59 +03:00
|
|
|
Note that the IP addresses of the tunnel endpoints may be the same as the
|
2001-04-04 14:02:20 +04:00
|
|
|
ones defined with
|
2002-06-10 00:05:55 +04:00
|
|
|
.Xr ifconfig 8
|
2001-04-04 14:02:20 +04:00
|
|
|
for the interface (as if IP is encapsulated), but need not be, as e.g. when
|
1998-09-14 00:39:35 +04:00
|
|
|
encapsulating AppleTalk.
|
2001-09-11 04:08:25 +04:00
|
|
|
.Sh EXAMPLES
|
1998-09-14 00:39:35 +04:00
|
|
|
Configuration example:
|
1999-12-22 17:55:49 +03:00
|
|
|
.Bd -literal
|
1998-09-14 00:39:35 +04:00
|
|
|
Host X-- Host A ----------------tunnel---------- cisco D------Host E
|
|
|
|
\\ |
|
|
|
|
\\ /
|
|
|
|
+------Host B----------Host C----------+
|
1999-12-22 17:55:49 +03:00
|
|
|
.Ed
|
2001-09-19 05:03:43 +04:00
|
|
|
On host A
|
|
|
|
.Ns ( Nx ) :
|
|
|
|
.Bd -literal
|
1998-09-14 00:39:35 +04:00
|
|
|
# route add default B
|
2001-11-24 17:27:03 +03:00
|
|
|
# ifconfig greN create
|
2002-06-09 14:44:57 +04:00
|
|
|
# ifconfig greN A D netmask 0xffffffff linkX up
|
2002-06-10 06:49:35 +04:00
|
|
|
# ifconfig greN tunnel A D
|
1998-09-14 00:39:35 +04:00
|
|
|
# route add E D
|
2001-09-19 05:03:43 +04:00
|
|
|
.Ed
|
|
|
|
On Host D (Cisco):
|
|
|
|
.Bd -literal
|
2001-04-04 14:02:20 +04:00
|
|
|
Interface TunnelX
|
1999-12-16 01:07:30 +03:00
|
|
|
ip unnumbered D ! e.g. address from Ethernet interface
|
|
|
|
tunnel source D ! e.g. address from Ethernet interface
|
1998-09-14 00:39:35 +04:00
|
|
|
tunnel destination A
|
2002-02-13 11:17:26 +03:00
|
|
|
ip route C \*[Lt]some interface and mask\*[Gt]
|
1998-09-14 00:39:35 +04:00
|
|
|
ip route A mask C
|
|
|
|
ip route X mask tunnelX
|
2001-09-19 05:03:43 +04:00
|
|
|
.Ed
|
|
|
|
OR
|
|
|
|
On Host D
|
|
|
|
.Ns ( Nx ) :
|
|
|
|
.Bd -literal
|
1998-09-14 00:39:35 +04:00
|
|
|
# route add default C
|
2001-11-24 17:27:03 +03:00
|
|
|
# ifconfig greN create
|
2001-04-04 14:02:20 +04:00
|
|
|
# ifconfig greN D A
|
2002-06-10 06:49:35 +04:00
|
|
|
# ifconfig tunnel greN D A
|
2001-09-19 05:03:43 +04:00
|
|
|
.Ed
|
1998-09-14 00:39:35 +04:00
|
|
|
.Pp
|
|
|
|
If all goes well, you should see packets flowing ;-)
|
|
|
|
.Pp
|
2002-06-10 00:05:55 +04:00
|
|
|
If you want to reach Host A over the tunnel (from Host D (Cisco)), then
|
1999-12-16 01:07:30 +03:00
|
|
|
you have to have an alias on Host A for e.g. the Ethernet interface like:
|
2001-09-19 05:03:43 +04:00
|
|
|
.Bd -literal
|
2002-02-13 11:17:26 +03:00
|
|
|
ifconfig \*[Lt]etherif\*[Gt] alias Y
|
2001-09-19 05:03:43 +04:00
|
|
|
.Ed
|
|
|
|
and on the cisco
|
|
|
|
.Bd -literal
|
1998-09-14 00:39:35 +04:00
|
|
|
ip route Y mask tunnelX
|
2001-09-19 05:03:43 +04:00
|
|
|
.Ed
|
2002-06-09 14:44:57 +04:00
|
|
|
.Pp
|
|
|
|
A similar setup can be used to create a link between two private networks
|
2002-06-10 00:05:55 +04:00
|
|
|
(for example in the 192.168 subnet) over the Internet:
|
2002-06-09 14:44:57 +04:00
|
|
|
.Bd -literal
|
|
|
|
192.168.1.* --- Router A -------tunnel-------- Router B --- 192.168.2.*
|
|
|
|
\\ /
|
|
|
|
\\ /
|
2002-06-10 00:05:55 +04:00
|
|
|
+----- the Internet ------+
|
2002-06-09 14:44:57 +04:00
|
|
|
.Ed
|
|
|
|
Assuming router A has the (external) IP address A and the internal address
|
|
|
|
192.168.1.1, while router B has external address B and internal address
|
|
|
|
192.168.2.1, the following commands will configure the tunnel:
|
|
|
|
.Pp
|
|
|
|
On router A:
|
|
|
|
.Bd -literal
|
|
|
|
# ifconfig greN create
|
2002-06-09 16:19:39 +04:00
|
|
|
# ifconfig greN 192.168.1.1 192.168.2.1 link1
|
2002-06-10 06:49:35 +04:00
|
|
|
# ifconfig greN tunnel A B
|
2002-06-09 14:44:57 +04:00
|
|
|
# route add -net 192.168.2 -netmask 255.255.255.0 192.168.2.1
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
On router B:
|
|
|
|
.Bd -literal
|
|
|
|
# ifconfig greN create
|
2002-06-09 16:19:39 +04:00
|
|
|
# ifconfig greN 192.168.2.1 192.168.1.1 link1
|
2002-06-10 06:49:35 +04:00
|
|
|
# ifconfig greN tunnel B A
|
2002-06-09 14:44:57 +04:00
|
|
|
# route add -net 192.168.1 -netmask 255.255.255.0 192.168.1.1
|
|
|
|
.Ed
|
2002-06-09 16:19:39 +04:00
|
|
|
.Pp
|
2002-06-10 00:05:55 +04:00
|
|
|
Note that this is a safe situation where the link1 flag (as discussed in the
|
|
|
|
.Sx BUGS
|
|
|
|
section below) may (and probably should) be set.
|
2001-09-19 05:03:43 +04:00
|
|
|
.Sh NOTES
|
2002-06-10 00:05:55 +04:00
|
|
|
The MTU of
|
2002-06-09 14:44:57 +04:00
|
|
|
.Sy gre Ns Ar X
|
|
|
|
interfaces is set to 1476 by default to match the value used by Cisco routers.
|
|
|
|
This may not be an optimal value, depending on the link between the two tunnel
|
2002-06-10 00:05:55 +04:00
|
|
|
endpoints. It can be adjusted via
|
2002-06-09 14:44:57 +04:00
|
|
|
.Xr ifconfig 8 .
|
|
|
|
.Pp
|
1998-09-14 00:39:35 +04:00
|
|
|
For correct operation, the
|
|
|
|
.Nm
|
2002-06-10 00:05:55 +04:00
|
|
|
device needs a route to the destination that is less specific than the
|
1998-09-14 00:39:35 +04:00
|
|
|
one over the tunnel.
|
|
|
|
(Basically, there needs to be a route to the decapsulating host that
|
2002-06-10 00:05:55 +04:00
|
|
|
does not run over the tunnel, as this would be a loop.)
|
|
|
|
If the addresses are ambiguous, doing the
|
2002-06-09 23:17:43 +04:00
|
|
|
.Xr ifconfig 8
|
|
|
|
.Li tunnel
|
2002-06-09 14:44:57 +04:00
|
|
|
step before the
|
|
|
|
.Xr ifconfig 8
|
|
|
|
call to set the
|
|
|
|
.Sy gre Ns Ar X
|
|
|
|
IP addresses will help to find a route outside the tunnel.
|
1998-09-30 10:13:27 +04:00
|
|
|
.Pp
|
2002-06-10 00:05:55 +04:00
|
|
|
In order to tell
|
|
|
|
.Xr ifconfig 8
|
2001-09-19 05:03:43 +04:00
|
|
|
to actually mark the interface as up, the keyword
|
|
|
|
.Dq up
|
|
|
|
must be given last on its command line.
|
1998-09-30 10:13:27 +04:00
|
|
|
.Pp
|
|
|
|
The kernel must be set to forward datagrams by either option
|
2002-06-10 00:05:55 +04:00
|
|
|
.Em GATEWAY
|
2001-09-19 05:03:43 +04:00
|
|
|
in the kernel config file or by issuing the appropriate option to
|
2001-04-04 14:02:20 +04:00
|
|
|
.Xr sysctl 8 .
|
1998-09-14 00:39:35 +04:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr atalk 4 ,
|
2002-03-04 18:14:22 +03:00
|
|
|
.Xr gif 4 ,
|
1998-09-14 00:39:35 +04:00
|
|
|
.Xr inet 4 ,
|
2001-04-04 14:02:20 +04:00
|
|
|
.Xr ip 4 ,
|
|
|
|
.Xr netintro 4 ,
|
1998-09-30 10:13:27 +04:00
|
|
|
.Xr options 4 ,
|
|
|
|
.Xr protocols 5 ,
|
2001-04-04 14:02:20 +04:00
|
|
|
.Xr ifconfig 8 ,
|
1998-09-30 10:13:27 +04:00
|
|
|
.Xr sysctl 8
|
1998-09-14 00:39:35 +04:00
|
|
|
.Pp
|
2002-06-10 00:05:55 +04:00
|
|
|
A description of GRE encapsulation can be found in RFC 1701 and RFC 1702.
|
1998-09-14 00:39:35 +04:00
|
|
|
.Pp
|
1998-09-30 10:13:27 +04:00
|
|
|
A description of MOBILE encapsulation can be found in RFC 2004.
|
2001-09-19 05:03:43 +04:00
|
|
|
.Sh AUTHORS
|
|
|
|
.An Heiko W.Rupp Aq hwr@pilhuhn.de
|
1998-09-14 00:39:35 +04:00
|
|
|
.Sh BUGS
|
|
|
|
The compute_route() code in if_gre.c toggles the last bit of the
|
|
|
|
IP-address to provoke the search for a less specific route than the
|
2002-06-10 00:05:55 +04:00
|
|
|
one directly over the tunnel to prevent loops. This is possibly not
|
1998-09-14 00:39:35 +04:00
|
|
|
the best solution.
|
|
|
|
.Pp
|
1999-06-28 11:56:56 +04:00
|
|
|
To avoid the address munging described above, turn on the link1 flag
|
2002-06-10 00:05:55 +04:00
|
|
|
on the
|
|
|
|
.Xr ifconfig 8
|
|
|
|
command line.
|
|
|
|
This implies that the GRE packet destination and the ifconfig remote host
|
|
|
|
are not the same IP addresses, and that the GRE destination does not route
|
|
|
|
over the
|
|
|
|
.Sy gre Ns Ar X
|
|
|
|
interface itself.
|
1999-06-28 11:56:56 +04:00
|
|
|
.Pp
|
2002-06-10 00:05:55 +04:00
|
|
|
The GRE RFCs are not yet fully implemented (no GRE options).
|