GIF(4) BSD Programmer's Manual GIF(4)NAMEgif - generic tunnel interface
SYNOPSIS
pseudo-device gif [count]
DESCRIPTION
The gif interface is a generic tunnelling pseudo device for IPv4 and
IPv6. It can tunnel IPv[46] traffic over IPv[46]. Therefore, there can
be four possible configurations. The behavior of gif is mainly based on
RFC2893 IPv6-over-IPv4 configured tunnel. On gif can also tunnel ISO
traffic over IPv[46] using EON encapsulation.
To use gif, administrator needs to configure protocol and addresses used
for the outer header. This can be done by using gifconfig(8), or
SIOCSIFPHYADDR ioctl. Also, administrator needs to configure protocol
and addresses used for the inner header, by using ifconfig(8). Note that
IPv6 link-local address (those start with fe80::) will be automatically
configured whenever possible. You may need to remove IPv6 link-local ad-
dress manually using ifconfig(8), when you would like to disable the use
of IPv6 as inner header (like when you need pure IPv4-over-IPv6 tunnel).
Finally, use routing table to route the packets toward gif interface.
gif interface can be configued to perform bidirectional tunnel, or multi-
destination tunnel. This is controlled by IFF_LINK0 interface flag. Al-
so, gif can be configured to be ECN friendly. This can be configured by
IFF_LINK1.
Bidirectional and multi-destination mode
Usually, gif implements bidirectional tunnel. gifconfig(8) should con-
figure a tunnel ingress point (this node) and an egress point (tunnel
endpoint), and one gif interface will tunnel to only a single tunnel end-
point, and accept from only a single tunnel endpoint. Source and desti-
nation address for outer IP header is always the ingress and the egress
point configued by gifconfig(8).
With IFF_LINK0 interface flag, gif can be configured to implement multi-
destination tunnel. With IFF_LINK0, it is able to configure egress point
to IPv4 wildcard address (0.0.0.0) or IPv6 unspecified address (0::0). In
this case, destination address for the outer IP header is determined
based on the routing table setup. Therefore, one gif interface can tun-
nel to multiple destinations. Also, gif will accept tunneled traffic
from any outer source address.
When finding a gif interface from the inbound tunneled traffic, bidirec-
tional mode interface is preferred than multi-destination mode interface.
For example, if you have the following three gif interfaces on node A,
tunneled traffic from C to A will match the second gif interface, not the
third one.
o bidirectional, A to B
o bidirectional, A to C
o multi-destination, A to any
Please note that multi-destination mode is far less secure than bidirec-
tional mode. Multi-destination mode gif can accept tunneled packet from
anybody, and can be attacked from a malicious node.
ECN friendly behavior
gif can be configured to be ECN friendly, as described in draft-ietf-
ipsec-ecn-02.txt. This is turned off by default, and can be turned on by
IFF_LINK1 interface flag.
Without IFF_LINK1, gif will show a normal behavior, like described in
RFC2893. This can be summarized as follows:
Ingress Set outer TOS bit to 0.
Egress Drop outer TOS bit.
With IFF_LINK1, gif will copy ECN bits (0x02 and 0x01 on IPv4 TOS byte or
IPv6 traffic class byte) on egress and ingress, as follows:
Ingress Copy TOS bits except for ECN CE (masked with 0xfe) from
inner to outer. set ECN CE bit to 0.
Egress Use inner TOS bits with some change. If outer ECN CE bit
is 1, enable ECN CE bit on the inner.
Note that the ECN friendly behavior violates RFC2893. This should be
used in mutual agreement with the peer.
Security
Malicious party may try to circumvent security filters by using tunnelled
packets. For better protection, gif performs martian filter and ingress
filter against outer source address, on egress. Note that mar-
tian/ingress filters are no way complete. You may want to secure your
node by using packet filters. Ingress filter can be turned off by
IFF_LINK2 bit.
As mentioned above, multi-destination mode (IFF_LINK0) is far less secure
than bidirectional mode.
SEE ALSOinet(4), inet6(4), gifconfig(8)
R. Gilligan, and E. Nordmark, "Transition Mechanisms for IPv6 Hosts and
Routers", RFC2893, August 2000, ftp://ftp.isi.edu/in-notes/rfc2893.txt.
Sally Floyd, David L. Black, and K. K. Ramakrishnan, IPsec Interactions
with ECN, December 1999, draft-ietf-ipsec-ecn-02.txt.
HISTORY
The gif device first appeared in WIDE hydrangea IPv6 kit.
BUGS
There are many tunnelling protocol specifications, defined differently
from each other. gif may not interoperate with peers which are based on
different specifications, and are picky about outer header fields. For
example, you cannot usually use gif to talk with IPsec devices that use
IPsec tunnel mode.
The current code does not check if the ingress address (outer source
address) configured to gif makes sense. Make sure to configure an ad-
dress which belongs to your node. Otherwise, your node will not be able
to receive packets from the peer, and your node will generate packets
with a spoofed source address.
If the outer protocol is IPv6, path MTU discovery for encapsulated packet
may affect communication over the interface.
gif(4) is an IFF_POINTOPOINT device, however, it supports NBMA behavior
in multi-destination mode.
KAME April 10, 1999 2