GIF(4)
π GIF(4) β the generic tunnel interface page, bestie edition π
okay so gather round, we're talking about gif β the generic tunnel interface. No, not the file format, bestie, put the reaction image down. π«Ά
β¨ SYNOPSIS β¨
device gif
That's it. That's the whole vibe. π
π DESCRIPTION π
The gif interface is a generic tunnelling device for IPv4 and IPv6. It can tunnel IPv[46] traffic over IPv[46]. Do the math, that's four possible configurations, and honestly? Versatile queen behavior. π
The behavior of gif is mainly based on RFC2893, the IPv6-over-IPv4 configured tunnel spec. And on NetBSD, gif can also tunnel ISO traffic over IPv[46] using EON encapsulation. Iconic.
β οΈ Not me letting you get this wrong:gifdoes not perform GRE encapsulation. For that you wantgre(4). Different device, different slay.
Each gif interface is created at runtime using interface cloning. Easiest way to do it is the βifconfig createβ command, or the ifconfig_β¨interfaceβ© variable in rc.conf(5). No cap, that's the move. β¨
To actually use gif, the administrator needs to configure the protocol and addresses used for the outer header. You do that with ifconfig(8) tunnel, or the SIOCSIFPHYADDR ioctl. Then you also need to configure the protocol and addresses for the inner header, with ifconfig(8).
Little heads up though: IPv6 link-local addresses (the ones that start with fe80::) will be automatically configured whenever possible. So if you want to disable IPv6 as the inner header β say, you need a pure IPv4-over-IPv6 tunnel β you may need to remove those IPv6 link-local addresses manually using ifconfig(8). π
And finally? You must modify the routing table to route the packets through the gif interface. It's giving "do the homework or the tunnel doesn't work." π
The gif device can be configured to be ECN friendly. This can be configured by IFF_LINK1. More on that below. π
πΈ ECN friendly behavior πΈ
The gif device 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 the IFF_LINK1 interface flag. π
Without IFF_LINK1, gif will show normal behavior, as described in RFC2893. Summarized, it's:
- 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, like this:
- Ingress β Copy TOS bits except for ECN CE (masked with
0xfe) from inner to outer. Set ECN CE bit to0. - Egress β Use inner TOS bits with some change. If outer ECN CE bit is
1, enable ECN CE bit on the inner.
π¨ Okay important: the ECN friendly behavior violates RFC2893. This should be used in mutual agreement with the peer. Do not just turn this on and ghost them, bestie.
π‘οΈ Security π‘οΈ
A malicious party may try to circumvent security filters by using tunnelled packets. Rude. π€
For better protection, gif performs both martian and ingress filtering against the outer source address on egress.
β οΈ Note that martian/ingress filters are in no way complete. You may want to secure your node by using packet filters. Also β ingress filtering can break tunnel operation in an asymmetrically routed network. It can be turned off by the IFF_LINK2 bit.
π¦ Miscellaneous π¦
By default, gif tunnels may not be nested. This behavior may be modified at runtime by setting the sysctl(8) variable net.link.gif.max_nesting to the desired level of nesting. Nest away, bestie. πͺΊ
π SEE ALSO π
R. Gilligan and E. Nordmark, βTransition Mechanisms for IPv6 Hosts and Routersβ, RFC2893, http://tools.ietf.org/html/rfc2893, August 2000.
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 the WIDE hydrangea IPv6 kit. A true elder icon. πΈ
π BUGS π
Okay so here's the messy part, and we're being honest about it:
- There are many tunnelling protocol specifications, all defined differently from each other. The
gifdevice may not interoperate with peers which are based on different specifications, and are picky about outer header fields. For example, you cannot usually usegifto talk with IPsec devices that use IPsec tunnel mode. It's giving "we're not compatible, sorry babe." π - If the outer protocol is IPv4,
gifdoes not try to perform path MTU discovery for the encapsulated packet (DF bit is set to0). - If the outer protocol is IPv6, path MTU discovery for encapsulated packets may affect communication over the interface. The first bigger-than-pmtu packet may be lost. To avoid the problem, you may want to set the interface MTU for
gifto1240or smaller, when the outer header is IPv6 and the inner header is IPv4. Write that down. π - The
gifdevice does not translate ICMP messages for the outer header into the inner header. - In the past,
gifhad a multi-destination behavior, configurable via theIFF_LINK0flag. That behavior is obsolete and is no longer supported. Rip to a real one. πͺ¦
And that's the whole page, bestie! This one came from the Debian folks, dated October 21, 2018, and it's the GIF(4) page living in the Kernel Interfaces Manual. Go configure your tunnel, drink some water, and remember: ECN friendly mode is a conversation, not a monologue. πβ¨ππ¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms