5 ***Originally Written by Aaron Kaplan. ******Restructured and Added by Tom Rhodes. ***
9 IPv6 (also know as IPng ***IP next generation***) is the new version of the well known IP protocol (also know as IPv4). Like the other current *BSD systems, DragonFly includes the KAME IPv6 reference implementation. So your DragonFly system comes with all you will need to experiment with IPv6. This section focuses on getting IPv6 configured and running.
13 In the early 1990s, people became aware of the rapidly diminishing address space of IPv4. Given the expansion rate of the Internet there were two major concerns:
18 * Running out of addresses. Today this is not so much of a concern anymore since private address spaces (`10.0.0.0/8`, `192.168.0.0/24`, etc.) and Network Address Translation (NAT) are being employed.
21 * Router table entries were getting too large. This is still a concern today.
25 IPv6 deals with these and many other issues:
30 * 128 bit address space. In other words theoretically there are 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses available. This means there are approximately 6.67 * 10^27 IPv6 addresses per square meter on our planet.
33 * Routers will only store network aggregation addresses in their routing tables thus reducing the average space of a routing table to 8192 entries.
37 There are also lots of other useful features of IPv6 such as:
42 * Address autoconfiguration ([RFC2462](http://www.ietf.org/rfc/rfc2462.txt))
45 * Anycast addresses (***one-out-of many***)
48 * Mandatory multicast addresses
54 * Simplified header structure
60 * IPv4-to-IPv6 transition mechanisms
64 For more information see:
69 * IPv6 overview at [playground.sun.com](http://playground.sun.com/pub/ipng/html/ipng-main.html)
72 * [KAME.net](http://www.kame.net)
75 * [6bone.net](http://www.6bone.net)
79 ### 19.16.1 Background on IPv6 Addresses
83 There are different types of IPv6 addresses: Unicast, Anycast and Multicast.
87 Unicast addresses are the well known addresses. A packet sent to a unicast address arrives exactly at the interface belonging to the address.
91 Anycast addresses are syntactically indistinguishable from unicast addresses but they address a group of interfaces. The packet destined for an anycast address will arrive at the nearest (in router metric) interface. Anycast addresses may only be used by routers.
95 Multicast addresses identify a group of interfaces. A packet destined for a multicast address will arrive at all interfaces belonging to the multicast group.
99 **Note:** The IPv4 broadcast address (usually `xxx.xxx.xxx.255`) is expressed by multicast addresses in IPv6.
103 **Table 19-2. Reserved IPv6 addresses**
108 | IPv6 address | Prefixlength (Bits) | Description | Notes
109 `::` | 128 bits | unspecified | cf. `0.0.0.0` in IPv4
110 `::1` | 128 bits | loopback address | cf. `127.0.0.1` in IPv4
111 `::00:xx:xx:xx:xx` | 96 bits | embedded IPv4 | The lower 32 bits are the IPv4 address. Also called ***IPv4 compatible IPv6 address***
112 `::ff:xx:xx:xx:xx` | 96 bits | IPv4 mapped IPv6 address | The lower 32 bits are the IPv4 address. For hosts which do not support IPv6.
113 `fe80::` - `feb::` | 10 bits | link-local | cf. loopback address in IPv4
114 `fec0::` - `fef::` | 10 bits | site-local |
115 `ff::` | 8 bits | multicast |
116 `001` (base 2) | 3 bits | global unicast | All global unicast addresses are assigned from this pool. The first 3 bits are ***001***. |
120 ### 19.16.2 Reading IPv6 Addresses
124 The canonical form is represented as: `x:x:x:x:x:x:x:x`, each ***x*** being a 16 Bit hex value. For example `FEBC:A574:382B:23C1:AA49:4592:4EFE:9982`
128 Often an address will have long substrings of all zeros therefore each such substring can be abbreviated by ***::***. For example `fe80::1` corresponds to the canonical form `fe80:0000:0000:0000:0000:0000:0000:0001`.
132 A third form is to write the last 32 Bit part in the well known (decimal) IPv4 style with dots ***.*** as separators. For example `2002::10.0.0.1` corresponds to the (hexadecimal) canonical representation `2002:0000:0000:0000:0000:0000:0a00:0001` which in turn is equivalent to writing `2002::a00:1`.
136 By now the reader should be able to understand the following:
147 rl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
149 inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255
151 inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1
153 ether 00:00:21:03:08:e1
155 media: Ethernet autoselect (100baseTX )
163 `fe80::200:21ff:fe03:8e1%rl0` is an auto configured link-local address. It includes the scrambled Ethernet MAC as part of the auto configuration.
167 For further information on the structure of IPv6 addresses see [RFC3513](http://www.ietf.org/rfc/rfc3513.txt).
171 ### 19.16.3 Getting Connected
175 Currently there are five ways to connect to other IPv6 hosts and networks:
179 * Join the experimental 6bone (Appears to be discontinued)
181 * Getting an IPv6 network from your upstream provider. Talk to your Internet provider for instructions.
185 * Join [Sixxs](http://www.sixxs.net/), a free tunnel broker and use the [`net/aiccu`](http://pkgsrc.se/net/aiccu) package to set up your connection.
187 * Join [gogo6](http://gogonet.gogo6.com/page/freenet6-tunnelbroker), another free tunnel broker and use the [[gw6c]] package to set up your connection.
190 ###Connect to 6bone (discontinued)
193 Here we will talk on how to connect to the 6bone since it currently seems to be the most popular way.
196 First take a look at the [6bone](http://www.6bone.net/) site and find a 6bone connection nearest to you. Write to the responsible person and with a little bit of luck you will be given instructions on how to set up your connection. Usually this involves setting up a GRE (gif) tunnel.
198 Here is a typical example on setting up a [gif(4)](http://leaf.dragonflybsd.org/cgi/web-man?command#gif§ion4) tunnel:
200 # ifconfig gif0 create
204 gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
206 # ifconfig gif0 tunnel `***MY_IPv4_ADDR***` `***HIS_IPv4_ADDR***`
208 # ifconfig gif0 inet6 alias `***MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR***`
211 Replace the capitalized words by the information you received from the upstream 6bone node.
214 This establishes the tunnel. Check if the tunnel is working by [ping6(8)](http://leaf.dragonflybsd.org/cgi/web-man?command#ping6§ion8) 'ing `ff02::1%gif0`. You should receive two ping replies.
217 **Note:** In case you are intrigued by the address `ff02:1%gif0`, this is a multicast address. `%gif0` states that the multicast address at network interface `gif0` is to be used. Since we `ping` a multicast address the other endpoint of the tunnel should reply as well.
220 By now setting up a route to your 6bone uplink should be rather straightforward:
223 # route add -inet6 default -interface gif0
225 # ping6 -n `***MY_UPLINK***`
227 # traceroute6 www.jp.FreeBSD.org
229 (3ffe:505:2008:1:2a0:24ff:fe57:e561) from 3ffe:8060:100::40:2, 30 hops max, 12 byte packets
231 1 atnet-meta6 14.147 ms 15.499 ms 24.319 ms
233 2 6bone-gw2-ATNET-NT.ipv6.tilab.com 103.408 ms 95.072 ms *
235 3 3ffe:1831:0:ffff::4 138.645 ms 134.437 ms 144.257 ms
237 4 3ffe:1810:0:6:290:27ff:fe79:7677 282.975 ms 278.666 ms 292.811 ms
239 5 3ffe:1800:0:ff00::4 400.131 ms 396.324 ms 394.769 ms
241 6 3ffe:1800:0:3:290:27ff:fe14:cdee 394.712 ms 397.19 ms 394.102 ms
244 This output will differ from machine to machine. By now you should be able to reach the IPv6 site [www.kame.net](http://www.kame.net) and see the dancing tortoise -- that is if you have a IPv6 enabled browser such as [`www/mozilla`](http://pkgsrc.se/www/mozilla).
248 I have not been able to get NAT traversal to work with gogo6. Your machine must have a world-routable IPv4 address to connect. If you are using DSL or Cable internet, this may mean putting your DragonflyBSD machine in the DMZ.
250 Create an account on [gogo6](http://gogonet.gogo6.com/page/freenet6-tunnelbroker) if you want a static address or a /56 block
252 Compile the [[gw6c]] client
254 Edit /usr/local/gw6c/bin/gw6c.conf
256 gwc6 can be configure for anonymous or authenticated access. Authenticated access give you a DNS name, a more stable address and optionally a /56 block of addresses (that is, 256 IPV6 addresses).
258 #Set userid and password if you want authenticated access
262 #Set servername to an anonymous or authenticated server
263 server=montreal.freenet6.net
264 #server=anon-montreal.freenet6.net
266 #Set auth_method to anonymous or any depending on above
268 #auth_method=anonymous
270 #host_type should be router only if you want a full /56 block. We do in this case so we can give IPs to a jail, or example.
274 #prefixlen is either 64 or 56. Set to 56 if you want 256 IPv6 addresses.
278 #if_prefix should be set only if host_type=router. This interface should be connected to your LAN (or in this case to the only interface)
281 #if_tunnel_v6v4 should be set to gif0 always
284 #template. We compiled gw6c as if we were on a netbsd system
288 Create gif0 interface
294 cd /usr/local/gw6c/bin
301 gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
302 tunnel inet 99.23.159.141 --> 64.86.88.116
303 inet6 2001:5c0:1000:b::4567 --> 2001:5c0:1000:b::4566 prefixlen 128
304 inet6 fe80::221:70ff:fef6:8ced%gif0 prefixlen 64 scopeid 0x6
306 In this case we can see our address is 2001:5c0:1000:b::4567
308 # ping6 ipv6.google.com
309 PING6(56=40+8+8 bytes) 2001:5c0:1000:b::4567 --> 2001:4860:b002::68
310 16 bytes from 2001:4860:b002::68, icmp_seq=0 hlim=53 time=79.582 ms
314 If you have an authenticated connection and a /56 address block, you will see an additional IPv6 address attached to the interface defined in if_prefix= in gw6c.conf.
317 re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
318 options=1b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING>
319 inet6 fe80::221:70ff:fef6:8ced%re0 prefixlen 64 scopeid 0x1
320 inet 99.23.159.141 netmask 0xfffffffc broadcast 99.23.159.143
321 inet6 2001:5c0:1105:1200::1 prefixlen 64
322 ether 00:21:70:f6:8c:ed
323 media: Ethernet autoselect (100baseTX <full-duplex>)
326 In this case, we have an IPv6 address of 2001:5c0:1105:1200::1. This is the start of the /56 block we have been assigned.
328 We can bind to additional addresses in the 2001:5c0:1105:1200::1/56 range. Example:
330 ifconfig re0 inet6 alias 2001:5c0:1105:1201::1
332 ### 19.16.4 DNS in the IPv6 World
335 There are two new types of DNS records for IPv6:
345 Using AAAA records is straightforward. Assign your hostname to the new IPv6 address you just got by adding:
349 MYHOSTNAME AAAA MYIPv6ADDR
353 To your primary zone DNS file. In case you do not serve your own DNS zones ask your DNS provider. Current versions of **bind** (version 8.3 and 9) support AAAA records.
359 CategoryHandbook-advancednetworking