1.\"	$OpenBSD: gif.4,v 1.14 2004/02/23 10:19:18 jmc Exp $
2.\"	$KAME: gif.4,v 1.15 2000/04/19 09:39:42 itojun Exp $
3.\"
4.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the project nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd April 10, 1999
32.Dt GIF 4
33.Os
34.Sh NAME
35.Nm gif
36.Nd generic tunnel interface
37.Sh SYNOPSIS
38.Cd "pseudo-device gif" Op Ar count
39.Sh DESCRIPTION
40The
41.Nm
42interface is a generic tunnelling pseudo-device for IPv4 and IPv6.
43It can tunnel IPv[46] traffic over IPv[46], for a total of four
44possible combinations.
45The behavior of
46.Nm
47is mainly based on RFC 1933 IPv6-over-IPv4 configured tunnel.
48.Pp
49A
50.Nm
51interface can be created at runtime using the
52.Ic ifconfig gifN create
53command or by setting up a
54.Xr hostname.if 5
55configuration file for
56.Xr netstart 8 .
57.Pp
58To use
59.Nm gif ,
60the administrator needs to configure the addresses used for the outer header.
61This can be done by using
62.Xr ifconfig 8 ,
63or through the
64.Dv SIOCSIFPHYADDR
65ioctl.
66The administrator needs to also configure the addresses used for the
67inner header, by using
68.Xr ifconfig 8 .
69Note that IPv6 link-local address
70.Pq those start with Li fe80::
71will be automatically configured whenever possible.
72One may need to remove any IPv6 link-local address manually using
73.Xr ifconfig 8 ,
74to disable the use of IPv6 as inner header
75.Pq e.g., when a pure IPv4-over-IPv6 tunnel is required .
76Also, the routing table may be used to route the packets toward the
77.Nm
78interface.
79.Pp
80If plain Ethernet-over-IP is being used,
81the
82.Xr sysctl 3
83variable
84.Dv net.inet.etherip.allow
85must be set to 1.
86This is not necessary in cases where Ethernet-over-IP is being
87protected using
88.Xr ipsec 4 .
89.Pp
90Finally, the
91.Nm
92interface may be used as a
93.Xr bridge 4
94member.
95Ethernet frames forwarded by the bridge to the
96.Nm
97interface are encapsulated inside an IPv4 or IPv6 header (depending on
98how the interface is configured), with transport protocol number 97
99(etherip).
100IPv4 or IPv6 packets carrying transport protocol 97 are delivered to
101the
102.Nm
103interface whose "physical" addresses match the source/destination
104addresses of the packet (the source address of the packet must match
105the destination "physical" address, and vice versa).
106.\"
107.Sh SEE ALSO
108.Xr sysctl 3 ,
109.Xr inet 4 ,
110.Xr inet6 4 ,
111.Xr ipsec 4 ,
112.Xr ifconfig 8
113.Rs
114.%A R. Gilligan
115.%A E. Nordmark
116.%B RFC 1933
117.%T Transition Mechanisms for IPv6 Hosts and Routers
118.%D April 1996
119.%O ftp://ftp.isi.edu/in-notes/rfc1933.txt
120.Re
121.Rs
122.%A Sally Floyd
123.%A David L. Black
124.%A K. K. Ramakrishnan
125.%T IPsec Interactions with ECN
126.%D December 1999
127.%O draft-ietf-ipsec-ecn-02.txt
128.Re
129.\"
130.Sh HISTORY
131The
132.Nm
133device first appeared in WIDE hydrangea IPv6 kit.
134.\"
135.Sh BUGS
136There are many tunnelling protocol specifications,
137defined differently from each other.
138.Nm
139may not interoperate with peers which are based on different specifications,
140and are picky about outer header fields.
141For example, you cannot usually use
142.Nm
143to talk with IPsec devices that use IPsec tunnel mode.
144.Pp
145The current code does not check if the ingress address
146.Pq outer source address
147configured to
148.Nm
149makes sense.
150Make sure to configure an address which belongs to your node.
151Otherwise, your node will not be able to receive packets from the peer,
152and your node will generate packets with a spoofed source address.
153.Pp
154If the outer protocol is IPv6, path MTU discovery for encapsulated packet
155may affect communication over the interface.
156.Pp
157When used in conjunction with the
158.Xr bridge 4 ,
159only one bridge tunnel may be operational for every pair of
160source/destination addresses.
161If more than one
162.Nm
163interface is configured with the same pair of outer addresses, the
164one with the lowest index number will receive all traffic.
165