133841545SHajimu UMEMOTO.\" $KAME: gif.4,v 1.28 2001/05/18 13:15:56 itojun Exp $ 2f6038661SJun-ichiro itojun Hagino.\" 39a4365d0SYoshinobu Inoue.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 49a4365d0SYoshinobu Inoue.\" All rights reserved. 59a4365d0SYoshinobu Inoue.\" 69a4365d0SYoshinobu Inoue.\" Redistribution and use in source and binary forms, with or without 79a4365d0SYoshinobu Inoue.\" modification, are permitted provided that the following conditions 89a4365d0SYoshinobu Inoue.\" are met: 99a4365d0SYoshinobu Inoue.\" 1. Redistributions of source code must retain the above copyright 109a4365d0SYoshinobu Inoue.\" notice, this list of conditions and the following disclaimer. 119a4365d0SYoshinobu Inoue.\" 2. Redistributions in binary form must reproduce the above copyright 129a4365d0SYoshinobu Inoue.\" notice, this list of conditions and the following disclaimer in the 139a4365d0SYoshinobu Inoue.\" documentation and/or other materials provided with the distribution. 149a4365d0SYoshinobu Inoue.\" 3. Neither the name of the project nor the names of its contributors 159a4365d0SYoshinobu Inoue.\" may be used to endorse or promote products derived from this software 169a4365d0SYoshinobu Inoue.\" without specific prior written permission. 179a4365d0SYoshinobu Inoue.\" 189a4365d0SYoshinobu Inoue.\" THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 199a4365d0SYoshinobu Inoue.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 209a4365d0SYoshinobu Inoue.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 219a4365d0SYoshinobu Inoue.\" ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 229a4365d0SYoshinobu Inoue.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 239a4365d0SYoshinobu Inoue.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 249a4365d0SYoshinobu Inoue.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 259a4365d0SYoshinobu Inoue.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 269a4365d0SYoshinobu Inoue.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 279a4365d0SYoshinobu Inoue.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 289a4365d0SYoshinobu Inoue.\" SUCH DAMAGE. 299a4365d0SYoshinobu Inoue.\" 305faba7efSRuslan Ermilov.\" $FreeBSD$ 315faba7efSRuslan Ermilov.\" 329a4365d0SYoshinobu Inoue.Dd April 10, 1999 339a4365d0SYoshinobu Inoue.Dt GIF 4 3412900fe3SJeroen Ruigrok van der Werven.Os 359a4365d0SYoshinobu Inoue.Sh NAME 369a4365d0SYoshinobu Inoue.Nm gif 37eb083802SRuslan Ermilov.Nd generic tunnel interface 389a4365d0SYoshinobu Inoue.Sh SYNOPSIS 39fe403d8dSBrooks Davis.Cd "device gif" 409a4365d0SYoshinobu Inoue.Sh DESCRIPTION 419a4365d0SYoshinobu InoueThe 429a4365d0SYoshinobu Inoue.Nm 435faba7efSRuslan Ermilovinterface is a generic tunnelling device for IPv4 and IPv6. 449a4365d0SYoshinobu InoueIt can tunnel IPv[46] traffic over IPv[46]. 459a4365d0SYoshinobu InoueTherefore, there can be four possible configurations. 469a4365d0SYoshinobu InoueThe behavior of 479a4365d0SYoshinobu Inoue.Nm 4833841545SHajimu UMEMOTOis mainly based on RFC2893 IPv6-over-IPv4 configured tunnel. 4933841545SHajimu UMEMOTOOn 5033841545SHajimu UMEMOTO.Nx , 5133841545SHajimu UMEMOTO.Nm 5233841545SHajimu UMEMOTOcan also tunnel ISO traffic over IPv[46] using EON encapsulation. 53bf11e8eaSGreg LeheyNote that 54bf11e8eaSGreg Lehey.Nm 55bf11e8eaSGreg Leheydoes not perform GRE encapsulation; use 56bf11e8eaSGreg Lehey.Xr gre 4 57bf11e8eaSGreg Leheyfor GRE encapsulation. 589a4365d0SYoshinobu Inoue.Pp 59601404ecSBrooks DavisEach 60f823d4a6SBrooks Davis.Nm 61601404ecSBrooks Davisinterface is created at runtime using interface cloning. 620787ca52SRuslan ErmilovThis is 63f823d4a6SBrooks Davismost easily done with the 64ace5be68SRuslan Ermilov.Dq Nm ifconfig Cm create 65601404ecSBrooks Daviscommand or using the 66fb5293cfSRuslan Ermilov.Va gifconfig_ Ns Aq Ar interface 67601404ecSBrooks Davisvariable in 68601404ecSBrooks Davis.Xr rc.conf 5 . 69f823d4a6SBrooks Davis.Pp 709a4365d0SYoshinobu InoueTo use 714b66483fSRuslan Ermilov.Nm , 72f7560bd3STom Rhodesthe administrator needs to configure the protocol and addresses used for the outer 739a4365d0SYoshinobu Inoueheader. 749a4365d0SYoshinobu InoueThis can be done by using 754a9054abSHajimu UMEMOTO.Xr ifconfig 8 764a9054abSHajimu UMEMOTO.Cm tunnel , 779a4365d0SYoshinobu Inoueor 789a4365d0SYoshinobu Inoue.Dv SIOCSIFPHYADDR 799a4365d0SYoshinobu Inoueioctl. 80f7560bd3STom RhodesThe administrator also needs to configure the protocol and addresses for the 81f7560bd3STom Rhodesinner header, with 829a4365d0SYoshinobu Inoue.Xr ifconfig 8 . 83f7560bd3STom RhodesNote that IPv6 link-local addresses 84f7560bd3STom Rhodes(those that start with 85c4d9468eSRuslan Ermilov.Li fe80:: ) 86813ec9a8SMarc Fonvieillewill be automatically configured whenever possible. 87f7560bd3STom RhodesYou may need to remove IPv6 link-local addresses manually using 889a4365d0SYoshinobu Inoue.Xr ifconfig 8 , 89f7560bd3STom Rhodesif you want to disable the use of IPv6 as the inner header 90f7560bd3STom Rhodes(for example, if you need a pure IPv4-over-IPv6 tunnel). 91f7560bd3STom RhodesFinally, you must modify the routing table to route the packets through the 929a4365d0SYoshinobu Inoue.Nm 939a4365d0SYoshinobu Inoueinterface. 949a4365d0SYoshinobu Inoue.Pp 95f7560bd3STom RhodesThe 969a4365d0SYoshinobu Inoue.Nm 975faba7efSRuslan Ermilovdevice can be configured to be ECN friendly. 989a4365d0SYoshinobu InoueThis can be configured by 999a4365d0SYoshinobu Inoue.Dv IFF_LINK1 . 1009a4365d0SYoshinobu Inoue.Ss ECN friendly behavior 101f7560bd3STom RhodesThe 1029a4365d0SYoshinobu Inoue.Nm 1035faba7efSRuslan Ermilovdevice can be configured to be ECN friendly, as described in 104f6038661SJun-ichiro itojun Hagino.Dv draft-ietf-ipsec-ecn-02.txt . 105f7560bd3STom RhodesThis is turned off by default, and can be turned on by the 1069a4365d0SYoshinobu Inoue.Dv IFF_LINK1 1079a4365d0SYoshinobu Inoueinterface flag. 1089a4365d0SYoshinobu Inoue.Pp 1099a4365d0SYoshinobu InoueWithout 1109a4365d0SYoshinobu Inoue.Dv IFF_LINK1 , 1119a4365d0SYoshinobu Inoue.Nm 112f7560bd3STom Rhodeswill show normal behavior, as described in RFC2893. 1139a4365d0SYoshinobu InoueThis can be summarized as follows: 1149a4365d0SYoshinobu Inoue.Bl -tag -width "Ingress" -offset indent 1159a4365d0SYoshinobu Inoue.It Ingress 1169a4365d0SYoshinobu InoueSet outer TOS bit to 1179a4365d0SYoshinobu Inoue.Dv 0 . 1189a4365d0SYoshinobu Inoue.It Egress 1199a4365d0SYoshinobu InoueDrop outer TOS bit. 1209a4365d0SYoshinobu Inoue.El 1219a4365d0SYoshinobu Inoue.Pp 1229a4365d0SYoshinobu InoueWith 1239a4365d0SYoshinobu Inoue.Dv IFF_LINK1 , 1249a4365d0SYoshinobu Inoue.Nm 1259a4365d0SYoshinobu Inouewill copy ECN bits 126c4d9468eSRuslan Ermilov.Dv ( 0x02 1279a4365d0SYoshinobu Inoueand 1289a4365d0SYoshinobu Inoue.Dv 0x01 129c4d9468eSRuslan Ermilovon IPv4 TOS byte or IPv6 traffic class byte) 1309a4365d0SYoshinobu Inoueon egress and ingress, as follows: 1319a4365d0SYoshinobu Inoue.Bl -tag -width "Ingress" -offset indent 1329a4365d0SYoshinobu Inoue.It Ingress 1339a4365d0SYoshinobu InoueCopy TOS bits except for ECN CE 134c4d9468eSRuslan Ermilov(masked with 135c4d9468eSRuslan Ermilov.Dv 0xfe ) 1369a4365d0SYoshinobu Inouefrom 1379a4365d0SYoshinobu Inoueinner to outer. 138c75526d5SRuslan ErmilovSet ECN CE bit to 1399a4365d0SYoshinobu Inoue.Dv 0 . 1409a4365d0SYoshinobu Inoue.It Egress 1419a4365d0SYoshinobu InoueUse inner TOS bits with some change. 1429a4365d0SYoshinobu InoueIf outer ECN CE bit is 1439a4365d0SYoshinobu Inoue.Dv 1 , 1449a4365d0SYoshinobu Inoueenable ECN CE bit on the inner. 1459a4365d0SYoshinobu Inoue.El 1469a4365d0SYoshinobu Inoue.Pp 14733841545SHajimu UMEMOTONote that the ECN friendly behavior violates RFC2893. 148f6038661SJun-ichiro itojun HaginoThis should be used in mutual agreement with the peer. 149f6038661SJun-ichiro itojun Hagino.Ss Security 150f7560bd3STom RhodesA malicious party may try to circumvent security filters by using 151f6038661SJun-ichiro itojun Haginotunnelled packets. 152f6038661SJun-ichiro itojun HaginoFor better protection, 1539a4365d0SYoshinobu Inoue.Nm 154f7560bd3STom Rhodesperforms both martian and ingress filtering against the outer source address 155f6038661SJun-ichiro itojun Haginoon egress. 156f7560bd3STom RhodesNote that martian/ingress filters are in no way complete. 157f6038661SJun-ichiro itojun HaginoYou may want to secure your node by using packet filters. 158fc2857adSGleb SmirnoffIngress filtering can break tunnel operation in an asymmetrically 159fc2857adSGleb Smirnoffrouted network. 160fc2857adSGleb SmirnoffIt can be turned off by 16133841545SHajimu UMEMOTO.Dv IFF_LINK2 16233841545SHajimu UMEMOTObit. 163fc2857adSGleb Smirnoff.Ss Route caching 164fc2857adSGleb SmirnoffProcessing each packet requires two route lookups: first on the 165fc2857adSGleb Smirnoffpacket itself, and second on the tunnel destination. 166fc2857adSGleb SmirnoffThis second route can be cached, increasing tunnel performance. 167fc2857adSGleb SmirnoffHowever, in a dynamically routed network, the tunnel will stick 168fc2857adSGleb Smirnoffto the cached route, ignoring routing table updates. 169fc2857adSGleb SmirnoffRoute caching can be enabled with the 170fc2857adSGleb Smirnoff.Dv IFF_LINK0 171fc2857adSGleb Smirnoffflag. 1729a4365d0SYoshinobu Inoue.\" 173872f786aSBrooks Davis.Ss Miscellaneous 174d0f16f93SRuslan ErmilovBy default, 175872f786aSBrooks Davis.Nm 176872f786aSBrooks Davistunnels may not be nested. 177872f786aSBrooks DavisThis behavior may be modified at runtime by setting the 178872f786aSBrooks Davis.Xr sysctl 8 179872f786aSBrooks Davisvariable 180872f786aSBrooks Davis.Va net.link.gif.max_nesting 181872f786aSBrooks Davisto the desired level of nesting. 182872f786aSBrooks DavisAdditionally, 183872f786aSBrooks Davis.Nm 184872f786aSBrooks Davistunnels are restricted to one per pair of end points. 185872f786aSBrooks DavisParallel tunnels may be enabled by setting the 186872f786aSBrooks Davis.Xr sysctl 8 187872f786aSBrooks Davisvariable 188872f786aSBrooks Davis.Va net.link.gif.parallel_tunnels 189872f786aSBrooks Davisto 1. 1909a4365d0SYoshinobu Inoue.Sh SEE ALSO 191bf11e8eaSGreg Lehey.Xr gre 4 , 1929a4365d0SYoshinobu Inoue.Xr inet 4 , 1939a4365d0SYoshinobu Inoue.Xr inet6 4 , 1944a9054abSHajimu UMEMOTO.Xr ifconfig 8 195f6038661SJun-ichiro itojun Hagino.Rs 196f6038661SJun-ichiro itojun Hagino.%A R. Gilligan 197f6038661SJun-ichiro itojun Hagino.%A E. Nordmark 19833841545SHajimu UMEMOTO.%B RFC2893 199f6038661SJun-ichiro itojun Hagino.%T Transition Mechanisms for IPv6 Hosts and Routers 20033841545SHajimu UMEMOTO.%D August 2000 20133841545SHajimu UMEMOTO.%O ftp://ftp.isi.edu/in-notes/rfc2893.txt 202f6038661SJun-ichiro itojun Hagino.Re 2039a4365d0SYoshinobu Inoue.Rs 2049a4365d0SYoshinobu Inoue.%A Sally Floyd 2059a4365d0SYoshinobu Inoue.%A David L. Black 2069a4365d0SYoshinobu Inoue.%A K. K. Ramakrishnan 2079a4365d0SYoshinobu Inoue.%T "IPsec Interactions with ECN" 208f6038661SJun-ichiro itojun Hagino.%D December 1999 209f6038661SJun-ichiro itojun Hagino.%O draft-ietf-ipsec-ecn-02.txt 2109a4365d0SYoshinobu Inoue.Re 2119a4365d0SYoshinobu Inoue.\" 2129a4365d0SYoshinobu Inoue.Sh HISTORY 2139a4365d0SYoshinobu InoueThe 2149a4365d0SYoshinobu Inoue.Nm 215f7560bd3STom Rhodesdevice first appeared in the WIDE hydrangea IPv6 kit. 216f6038661SJun-ichiro itojun Hagino.\" 217f6038661SJun-ichiro itojun Hagino.Sh BUGS 218f7560bd3STom RhodesThere are many tunnelling protocol specifications, all 2195faba7efSRuslan Ermilovdefined differently from each other. 2205faba7efSRuslan ErmilovThe 221f6038661SJun-ichiro itojun Hagino.Nm 2225faba7efSRuslan Ermilovdevice may not interoperate with peers which are based on different specifications, 223f6038661SJun-ichiro itojun Haginoand are picky about outer header fields. 224f6038661SJun-ichiro itojun HaginoFor example, you cannot usually use 225f6038661SJun-ichiro itojun Hagino.Nm 226f6038661SJun-ichiro itojun Haginoto talk with IPsec devices that use IPsec tunnel mode. 227f6038661SJun-ichiro itojun Hagino.Pp 228f6038661SJun-ichiro itojun HaginoThe current code does not check if the ingress address 229c4d9468eSRuslan Ermilov(outer source address) 230f7560bd3STom Rhodesconfigured in the 231f6038661SJun-ichiro itojun Hagino.Nm 232f7560bd3STom Rhodesinterface makes sense. 233f7560bd3STom RhodesMake sure to specify an address which belongs to your node. 234f6038661SJun-ichiro itojun HaginoOtherwise, your node will not be able to receive packets from the peer, 235f7560bd3STom Rhodesand it will generate packets with a spoofed source address. 236f6038661SJun-ichiro itojun Hagino.Pp 23733841545SHajimu UMEMOTOIf the outer protocol is IPv4, 23833841545SHajimu UMEMOTO.Nm 23933841545SHajimu UMEMOTOdoes not try to perform path MTU discovery for the encapsulated packet 240c4d9468eSRuslan Ermilov(DF bit is set to 0). 24133841545SHajimu UMEMOTO.Pp 242f7560bd3STom RhodesIf the outer protocol is IPv6, path MTU discovery for encapsulated packets 24333841545SHajimu UMEMOTOmay affect communication over the interface. 24433841545SHajimu UMEMOTOThe first bigger-than-pmtu packet may be lost. 24533841545SHajimu UMEMOTOTo avoid the problem, you may want to set the interface MTU for 24633841545SHajimu UMEMOTO.Nm 247f7560bd3STom Rhodesto 1240 or smaller, when the outer header is IPv6 and the inner header is IPv4. 24833841545SHajimu UMEMOTO.Pp 249f7560bd3STom RhodesThe 25033841545SHajimu UMEMOTO.Nm 2515faba7efSRuslan Ermilovdevice does not translate ICMP messages for the outer header into the inner header. 25233841545SHajimu UMEMOTO.Pp 25333841545SHajimu UMEMOTOIn the past, 25433841545SHajimu UMEMOTO.Nm 25533841545SHajimu UMEMOTOhad a multi-destination behavior, configurable via 25633841545SHajimu UMEMOTO.Dv IFF_LINK0 25733841545SHajimu UMEMOTOflag. 258f7560bd3STom RhodesThe behavior is obsolete and is no longer supported. 259