📄 network-ipv6.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>IPv6</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手册" href="index.html" /><link rel="UP" title="Advanced Networking" href="advanced-networking.html" /><link rel="PREVIOUS" title="Parallel Line IP (PLIP)" href="network-plip.html" /><link rel="NEXT" title="电子邮件" href="mail.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD 使用手册</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="network-plip.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 19. Advanced Networking</td><td width="10%" align="right" valign="bottom"><a href="mail.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="NETWORK-IPV6" name="NETWORK-IPV6">19.16. IPv6</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Originally Written by</span> AaronKaplan.</i> <i class="AUTHORGROUP"><span class="CONTRIB">Restructured and Added by</span>Tom Rhodes.</i> <p>IPv6 (also know as IPng ``IP next generation'') is the new version of the well knownIP protocol (also know as <acronym class="ACRONYM">IPv4</acronym>). Like the othercurrent *BSD systems, FreeBSD includes the <acronym class="ACRONYM">KAME</acronym> IPv6reference implementation. So your FreeBSD system comes with all you will need toexperiment with IPv6. This section focuses on getting IPv6 configured and running.</p><p>In the early 1990s, people became aware of the rapidly diminishing address space ofIPv4. Given the expansion rate of the Internet there were two major concerns:</p><ul><li><p>Running out of addresses. Today this is not so much of a concern anymore since privateaddress spaces (<tt class="HOSTID">10.0.0.0/8</tt>, <ttclass="HOSTID">192.168.0.0/24</tt>, etc.) and Network Address Translation (<acronymclass="ACRONYM">NAT</acronym>) are being employed.</p></li><li><p>Router table entries were getting too large. This is still a concern today.</p></li></ul><p>IPv6 deals with these and many other issues:</p><ul><li><p>128 bit address space. In other words theoretically there are340,282,366,920,938,463,463,374,607,431,768,211,456 addresses available. This means thereare approximately 6.67 * 10^27 IPv6 addresses per square meter on our planet.</p></li><li><p>Routers will only store network aggregation addresses in their routing tables thusreducing the average space of a routing table to 8192 entries.</p></li></ul><p>There are also lots of other useful features of IPv6 such as:</p><ul><li><p>Address autoconfiguration (RFC2462)</p></li><li><p>Anycast addresses (``one-out-of many'')</p></li><li><p>Mandatory multicast addresses</p></li><li><p>IPsec (IP security)</p></li><li><p>Simplified header structure</p></li><li><p>Mobile <acronym class="ACRONYM">IP</acronym></p></li><li><p>IPv4-to-IPv6 transition mechanisms</p></li></ul><p>For more information see:</p><ul><li><p>IPv6 overview at <a href="http://www.sun.com" target="_top">Sun.com</a></p></li><li><p><a href="http://www.ipv6.org" target="_top">IPv6.org</a></p></li><li><p><a href="http://www.kame.net" target="_top">KAME.net</a></p></li><li><p><a href="http://www.6bone.net" target="_top">6bone.net</a></p></li></ul><div class="SECT2"><h2 class="SECT2"><a id="AEN29171" name="AEN29171">19.16.1. Background on IPv6Addresses</a></h2><p>There are different types of IPv6 addresses: Unicast, Anycast and Multicast.</p><p>Unicast addresses are the well known addresses. A packet sent to a unicast addressarrives exactly at the interface belonging to the address.</p><p>Anycast addresses are syntactically indistinguishable from unicast addresses but theyaddress a group of interfaces. The packet destined for an anycast address will arrive atthe nearest (in router metric) interface. Anycast addresses may only be used byrouters.</p><p>Multicast addresses identify a group of interfaces. A packet destined for a multicastaddress will arrive at all interfaces belonging to the multicast group.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> The IPv4 broadcast address (usually <ttclass="HOSTID">xxx.xxx.xxx.255</tt>) is expressed by multicast addresses in IPv6.</p></blockquote></div><p>Reserved IPv6 addresses:</p><pre class="SCREEN">ipv6-address prefixlength(Bits) description Notes :: 128 Bits unspecified cf. 0.0.0.0 in IPv4 address ::1 128 Bits loopback address cf. 127.0.0.1 in IPv4 ::00:xx:xx:xx:xx 96 Bits embedded IPv4 The lower 32 bits are the address IPv4 address. Also called ``IPv4 compatible IPv6 address'' ::ff:xx:xx:xx:xx 96 Bits IPv4 mapped The lower 32 bits are the IPv6 address IPv4 address. For hosts which do not support IPv6 fe80:: - feb:: 10 Bits link-local cf. loopback address in IPv4 fec0:: - fef:: 10 Bits site-local ff:: 8 Bits multicast 001 (base 2) 3 Bits global unicast All global unicast addresses are assigned from this pool. The first 3 Bits are ``001''.</pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN29184" name="AEN29184">19.16.2. Reading IPv6Addresses</a></h2><p>The canonical form is represented as: <tt class="HOSTID">x:x:x:x:x:x:x:x</tt>, each``x'' being a 16 Bit hex value. For example <ttclass="HOSTID">FEBC:A574:382B:23C1:AA49:4592:4EFE:9982</tt></p><p>Often an address will have long substrings of all zeros therefore each such substringcan be abbreviated by ``::''. For example <tt class="HOSTID">fe80::1</tt> corresponds tothe canonical form <tt class="HOSTID">fe80:0000:0000:0000:0000:0000:0000:0001</tt></p><p>A third form is to write the last 32 Bit part in the well known (decimal) IPv4 stylewith dots ``.'' as separators. For example <tt class="HOSTID">2002::10.0.0.1</tt>corresponds to the (hexadecimal) canonical representation <ttclass="HOSTID">2002:0000:0000:0000:0000:0000:0a00:0001</tt> which in turn is equivalentto writing <tt class="HOSTID">2002::a00:1</tt></p><p>By now the reader should be able to understand the following:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ifconfig</kbd></pre><pre class="PROGRAMLISTING">rl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500 inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255 inet6 fe80::200:21ff:fe03:8e1%rl0 prefixlen 64 scopeid 0x1 ether 00:00:21:03:08:e1 media: Ethernet autoselect (100baseTX ) status: active</pre><p><tt class="HOSTID">fe80::200:21ff:fe03:8e1%rl0</tt> is an auto configured link-localaddress. It includes the scrambled Ethernet MAC as part of the auto configuration.</p><p>For further information on the structure of IPv6 addresses see RFC2373.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN29207" name="AEN29207">19.16.3. Getting Connected</a></h2><p>Currently there are four ways to connect to other IPv6 hosts and networks:</p><ul><li><p>Join the experimental 6bone</p></li><li><p>Getting an IPv6 network from your upstream provider. Talk to your Internet providerfor instructions.</p></li><li><p>Tunnel via 6-to-4</p></li><li><p>Use the freenet6 port if you are on a dial-up connection.</p></li></ul><p>Here we will talk on how to connect to the 6bone since it currently seems to be themost popular way.</p><p>First take a look at the 6bone site and find a 6bone connection nearest to you. Writeto the responsible person and with a little bit of luck you will be given instructions onhow to set up your connection. Usually this involves setting up a GRE (gif) tunnel.</p><p>Here is a typical example on setting up a <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">gif</span>(4)</span> tunnel:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ifconfig gif0 create</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ifconfig gif0</kbd>gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280<samp class="PROMPT">#</samp> <kbd class="USERINPUT">ifconfig gif0 tunnel <varclass="REPLACEABLE">MY_IPv4_ADDR</var> <varclass="REPLACEABLE">HIS_IPv4_ADDR</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ifconfig gif0 inet6 alias <varclass="REPLACEABLE">MY_ASSIGNED_IPv6_TUNNEL_ENDPOINT_ADDR</var></kbd></pre><p>Replace the capitalized words by the information you received from the upstream 6bonenode.</p><p>This establishes the tunnel. Check if the tunnel is working by <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ping6</span>(8)</span> 'ing <ttclass="HOSTID">ff02::1%gif0</tt>. You should receive two ping replies.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> In case you are intrigued by the address <ttclass="HOSTID">ff02:1%gif0</tt>, this is a multicast address. <varclass="LITERAL">%gif0</var> states that the multicast address at network interface <ttclass="DEVICENAME">gif0</tt> is to be used. Since we <tt class="COMMAND">ping</tt> amulticast address the other endpoint of the tunnel should reply as well).</p></blockquote></div><p>By now setting up a route to your 6bone uplink should be rather straightforward:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">route add -inet6 default -interface gif0</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ping6 -n <varclass="REPLACEABLE">MY_UPLINK</var></kbd></pre><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">traceroute6 www.jp.FreeBSD.org</kbd>(3ffe:505:2008:1:2a0:24ff:fe57:e561) from 3ffe:8060:100::40:2, 30 hops max, 12 byte packets 1 atnet-meta6 14.147 ms 15.499 ms 24.319 ms 2 6bone-gw2-ATNET-NT.ipv6.tilab.com 103.408 ms 95.072 ms * 3 3ffe:1831:0:ffff::4 138.645 ms 134.437 ms 144.257 ms 4 3ffe:1810:0:6:290:27ff:fe79:7677 282.975 ms 278.666 ms 292.811 ms 5 3ffe:1800:0:ff00::4 400.131 ms 396.324 ms 394.769 ms 6 3ffe:1800:0:3:290:27ff:fe14:cdee 394.712 ms 397.19 ms 394.102 ms</pre><p>This output will differ from machine to machine. By now you should be able to reachthe IPv6 site <a href="http://www.kame.net" target="_top">www.kame.net</a> and see thedancing tortoise -- that is if you have a IPv6 enabled browser such as <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/www/mozilla/pkg-descr"><ttclass="FILENAME">www/mozilla</tt></a>.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN29262" name="AEN29262">19.16.4. DNS in the IPv6World</a></h2><p>There are two new types of DNS records for IPv6:</p><ul><li><p>AAAA records,</p></li><li><p>A6 records</p></li></ul><p>Using AAAA records is straightforward. Assign your hostname to the new IPv6 addressyou just got by adding:</p><pre class="PROGRAMLISTING">MYHOSTNAME AAAA MYIPv6ADDR</pre><p>To your primary zone DNS file. In case you do not serve your own <acronymclass="ACRONYM">DNS</acronym> zones ask your <acronym class="ACRONYM">DNS</acronym>provider. Current versions of <b class="APPLICATION">bind</b> (version 8.3 and 9) supportAAAA records.</p></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="network-plip.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="mail.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Parallel Line IP (PLIP)</td><td width="34%" align="center" valign="top"><a href="advanced-networking.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">电子邮件</td></tr></table></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -