存档

文章标签 ‘linux’

Iptables 规则 一些简单实例和详细介绍(转)

2011年10月30日 16hot 没有评论

设定规则
iptables -p INPUT DROP
iptables -p OUTPUT ACCEPT
iptables -p FORWARD DROP
1、防止外网用内网IP欺骗
iptables -t nat -A PREROUTING -i eth0 -s 10.0.0.0/8 -j DROP
iptables -t nat -A PREROUTING -i eth0 -s 172.16.0.0/12 -j DROP
iptables -t nat -A PREROUTING -i eth0 -s 192.168.0.0/16 -j DROP
查看nat规则
iptables -t nat -L
2、如果想取消上面所加的规则:
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
3、阻止一个IP连接本机
iptables -t filter -A INPUT -s 192.168.1.5 -i eth0 -j DROP
4、查看本机的IPTABLES的所填规则
iptables -L -n
5、清除filter中所有的规则连接
iptables -F
清除filter中使用者自定义连接中的规则
iptables -X
6、保存所修改的iptables规则
/etc/rc.d/init.d/iptables save
重新启动iptables服务
service iptables restart
7、关闭不安全的端口连接本机
iptables -A OUTPUT -p tcp –sport 31337 -j DROP
iptables -A OUTPUT -p tcp –dport 31337 -j DROP
8、开启所需要的端口
22
iptables -A INPUT -p tcp –dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp –sport 22 -j ACCEPT
80
iptables -A OUTPUT -p tcp –sport 80 -j ACCEPT
iptables -A INPUT -p tcp –dport 80 -j ACCEPT
9、禁止一个IP或者一个IP段访问服务器端口服务
80端口
iptables -t filter -I INPUT 2 -s 192.168.5.0/24 -p tcp –dport http -j DROP
FTP端口
iptables -t filter -I INPUT 2 -s 192.168.7.9 -p tcp –dport ftp -j DROP

用iptables -ADC 来指定链的规则,-A添加 -D删除 -C 修改

iptables – [RI] chain rule num rule-specification[option]
用iptables – RI 通过规则的顺序指定

iptables -D chain rule num[option]
删除指定规则
iptables -[LFZ] [chain][option]
用iptables -LFZ 链名 [选项]

iptables -[NX] chain
用 -NX 指定链

iptables -P chain target[options]
指定链的默认目标

iptables -E old-chain-name new-chain-name
-E 旧的链名 新的链名
用新的链名取代旧的链名
说明
Iptalbes 是用来设置、维护和检查Linux内核的IP包过滤规则的。
可以定义不同的表,每个表都包含几个内部的链,也能包含用户定义的链。每个链都是一个规则列表,对对应的包进行匹配:每条规则指定应当如何处理与之相匹配的包。这被称作’target’(目标),也可以跳向同一个表内的用户定义的链。

TARGETS
防火墙的规则指定所检查包的特征,和目标。如果包不匹配,将送往该链中下一条规则检查;如果匹配,那么下一条规则由目标值确定.该目标值可以是用户定义的链名,或是某个专用值,如ACCEPT[通过], DROP[删除], QUEUE[排队], 或者 RETURN[返回]。
ACCEPT 表示让这个包通过。DROP表示将这个包丢弃。QUEUE表示把这个包传递到用户空间。RETURN表示停止这条链的匹配,到前一个链的规则重新开始。如果到达了一个内建的链(的末端),或者遇到内建链的规则是RETURN,包的命运将由链准则指定的目标决定。

TABLES
当前有三个表(哪个表是当前表取决于内核配置选项和当前模块)。
-t table
这个选项指定命令要操作的匹配包的表。如果内核被配置为自动加载模块,这时若模块没有加载,(系统)将尝试(为该表)加载适合的模块。这些表如下:filter,这是默认的表,包含了内建的链INPUT(处理进入的包)、FORWORD(处理通过的包)和OUTPUT(处理本地生成的包)。nat,这个表被查询时表示遇到了产生新的连接的包,由三个内建的链构成:PREROUTING (修改到来的包)、OUTPUT(修改路由之前本地的包)、POSTROUTING(修改准备出去的包)。mangle 这个表用来对指定的包进行修改。它有两个内建规则:PREROUTING(修改路由之前进入的包)和OUTPUT(修改路由之前本地的包)。
OPTIONS
这些可被iptables识别的选项可以区分不同的种类。

COMMANDS
这些选项指定执行明确的动作:若指令行下没有其他规定,该行只能指定一个选项.对于长格式的命令和选项名,所用字母长度只要保证iptables能从其他选项中区分出该指令就行了。
-A -append
在所选择的链末添加一条或更多规则。当源(地址)或者/与 目的(地址)转换为多个地址时,这条规则会加到所有可能的地址(组合)后面。

-D -delete
从所选链中删除一条或更多规则。这条命令可以有两种方法:可以把被删除规则指定为链中的序号(第一条序号为1),或者指定为要匹配的规则。

-R -replace
从选中的链中取代一条规则。如果源(地址)或者/与 目的(地址)被转换为多地址,该命令会失败。规则序号从1开始。

-I -insert
根据给出的规则序号向所选链中插入一条或更多规则。所以,如果规则序号为1,规则会被插入链的头部。这也是不指定规则序号时的默认方式。

-L -list
显示所选链的所有规则。如果没有选择链,所有链将被显示。也可以和z选项一起使用,这时链会被自动列出和归零。精确输出受其它所给参数影响。

-F -flush
清空所选链。这等于把所有规则一个个的删除。

–Z -zero
把所有链的包及字节的计数器清空。它可以和 -L配合使用,在清空前察看计数器,请参见前文。

-N -new-chain
根据给出的名称建立一个新的用户定义链。这必须保证没有同名的链存在。

-X -delete-chain
删除指定的用户自定义链。这个链必须没有被引用,如果被引用,在删除之前你必须删除或者替换与之有关的规则。如果没有给出参数,这条命令将试着删除每个非内建的链。

-P -policy
设置链的目标规则。

-E -rename-chain
根据用户给出的名字对指定链进行重命名,这仅仅是修饰,对整个表的结构没有影响。TARGETS参数给出一个合法的目标。只有非用户自定义链可以使用规则,而且内建链和用户自定义链都不能是规则的目标。

-h Help.
帮助。给出当前命令语法非常简短的说明。

PARAMETERS
参数
以下参数构成规则详述,如用于add、delete、replace、append 和 check命令。

-p -protocal [!]protocol
规则或者包检查(待检查包)的协议。指定协议可以是tcp、udp、icmp中的一个或者全部,也可以是数值,代表这些协议中的某一个。当然也可以使用在/etc/protocols中定义的协议名。在协议名前加上”!”表示相反的规则。数字0相当于所有all。Protocol all会匹配所有协议,而且这是缺省时的选项。在和check命令结合时,all可以不被使用。
-s -source [!] address[/mask]
指定源地址,可以是主机名、网络名和清楚的IP地址。mask说明可以是网络掩码或清楚的数字,在网络掩码的左边指定网络掩码左边”1″的个数,因此,mask值为24等于255.255.255.0。在指定地址前加上”!”说明指定了相反的地址段。标志 –src 是这个选项的简写。

-d –destination [!] address[/mask]
指定目标地址,要获取详细说明请参见 -s标志的说明。标志 –dst 是这个选项的简写。

-j –jump target
-j 目标跳转
指定规则的目标;也就是说,如果包匹配应当做什么。目标可以是用户自定义链(不是这条规则所在的),某个会立即决定包的命运的专用内建目标,或者一个扩展(参见下面的EXTENSIONS)。如果规则的这个选项被忽略,那么匹配的过程不会对包产生影响,不过规则的计数器会增加。

-i -in-interface [!] [name]
i -进入的(网络)接口 [!][名称]
这是包经由该接口接收的可选的入口名称,包通过该接口接收(在链INPUT、FORWORD和PREROUTING中进入的包)。当在接口名前使用”!”说明后,指的是相反的名称。如果接口名后面加上”+”,则所有以此接口名开头的接口都会被匹配。如果这个选项被忽略,会假设为”+”,那么将匹配任意接口。

-o –out-interface [!][name]
-o –输出接口[名称]
这是包经由该接口送出的可选的出口名称,包通过该口输出(在链FORWARD、OUTPUT和POSTROUTING中送出的包)。当在接口名前使用”!”说明后,指的是相反的名称。如果接口名后面加上”+”,则所有以此接口名开头的接口都会被匹配。如果这个选项被忽略,会假设为”+”,那么将匹配所有任意接口。

[!] -f, –fragment
[!] -f –分片
这意味着在分片的包中,规则只询问第二及以后的片。自那以后由于无法判断这种把包的源端口或目标端口(或者是ICMP类型的),这类包将不能匹配任何指定对他们进行匹配的规则。如果”!”说明用在了”-f”标志之前,表示相反的意思。

OTHER OPTIONS
其他选项
还可以指定下列附加选项:

-v –verbose
-v –详细
详细输出。这个选项让list命令显示接口地址、规则选项(如果有)和TOS(Type of Service)掩码。包和字节计数器也将被显示,分别用K、M、G(前缀)表示1000、1,000,000和1,000,000,000倍(不过请参看-x标志改变它),对于添加,插入,删除和替换命令,这会使一个或多个规则的相关详细信息被打印。

-n –numeric
-n –数字
数字输出。IP地址和端口会以数字的形式打印。默认情况下,程序试显示主机名、网络名或者服务(只要可用)。

-x -exact
-x -精确
扩展数字。显示包和字节计数器的精确值,代替用K,M,G表示的约数。这个选项仅能用于 -L 命令。

–line-numbers
当列表显示规则时,在每个规则的前面加上行号,与该规则在链中的位置相对应。

MATCH EXTENSIONS
对应的扩展
iptables能够使用一些与模块匹配的扩展包。以下就是含于基本包内的扩展包,而且他们大多数都可以通过在前面加上!来表示相反的意思。

tcp
当 –protocol tcp 被指定,且其他匹配的扩展未被指定时,这些扩展被装载。它提供以下选项:

–source-port [!] [port[:port]]
源端口或端口范围指定。这可以是服务名或端口号。使用格式端口:端口也可以指定包含的(端口)范围。如果首端口号被忽略,默认是”0″,如果末端口号被忽略,默认是”65535″,如果第二个端口号大于第一个,那么它们会被交换。这个选项可以使用 –sport的别名。

–destionation-port [!] [port:[port]]
目标端口或端口范围指定。这个选项可以使用 –dport别名来代替。

–tcp-flags [!] mask comp
匹配指定的TCP标记。第一个参数是我们要检查的标记,一个用逗号分开的列表,第二个参数是用逗号分开的标记表,是必须被设置的。标记如下:SYN ACK FIN RST URG PSH ALL NONE。因此这条命令:iptables -A FORWARD -p tcp –tcp-flags SYN, ACK, FIN, RST SYN只匹配那些SYN标记被设置而ACK、FIN和RST标记没有设置的包。

[!] –syn
只匹配那些设置了SYN位而清除了ACK和FIN位的TCP包。这些包用于TCP连接初始化时发出请求;例如,大量的这种包进入一个接口发生堵塞时会阻止进入的TCP连接,而出去的TCP连接不会受到影响。这等于 –tcp-flags SYN, RST, ACK SYN。如果”–syn”前面有”!”标记,表示相反的意思。

–tcp-option [!] number
匹配设置了TCP选项的。

udp
当protocol udp 被指定,且其他匹配的扩展未被指定时,这些扩展被装载,它提供以下选项:

–source-port [!] [port:[port]]
源端口或端口范围指定。详见 TCP扩展的–source-port选项说明。

–destination-port [!] [port:[port]]
目标端口或端口范围指定。详见 TCP扩展的–destination-port选项说明。

icmp
当protocol icmp被指定,且其他匹配的扩展未被指定时,该扩展被装载。它提供以下选项:
–icmp-type [!] typename
这个选项允许指定ICMP类型,可以是一个数值型的ICMP类型,或者是某个由命令iptables -p icmp -h所显示的ICMP类型名。

mac
–mac-source [!] address
匹配物理地址。必须是XX:XX:XX:XX:XX这样的格式。注意它只对来自以太设备并进入PREROUTING、FORWORD和INPUT链的包有效。

limit
这个模块匹配标志用一个标记桶过滤器一一定速度进行匹配,它和LOG目标结合使用来给出有限的登陆数.当达到这个极限值时,使用这个扩展包的规则将进行匹配.(除非使用了”!”标记)

–limit rate
最大平均匹配速率:可赋的值有’/second’, ‘/minute’, ‘/hour’, or ‘/day’这样的单位,默认是3/hour。

–limit-burst number
待匹配包初始个数的最大值:若前面指定的极限还没达到这个数值,则概数字加1.默认值为5

multiport
这个模块匹配一组源端口或目标端口,最多可以指定15个端口。只能和-p tcp 或者 -p udp 连着使用。

–source-port [port[, port]]
如果源端口是其中一个给定端口则匹配

–destination-port [port[, port]]
如果目标端口是其中一个给定端口则匹配

–port [port[, port]]
若源端口和目的端口相等并与某个给定端口相等,则匹配。
mark
这个模块和与netfilter过滤器标记字段匹配(就可以在下面设置为使用MARK标记)。

–mark value [/mask]
匹配那些无符号标记值的包(如果指定mask,在比较之前会给掩码加上逻辑的标记)。

owner
此模块试为本地生成包匹配包创建者的不同特征。只能用于OUTPUT链,而且即使这样一些包(如ICMP ping应答)还可能没有所有者,因此永远不会匹配。

–uid-owner userid
如果给出有效的user id,那么匹配它的进程产生的包。

–gid-owner groupid
如果给出有效的group id,那么匹配它的进程产生的包。

–sid-owner seessionid
根据给出的会话组匹配该进程产生的包。

state
此模块,当与连接跟踪结合使用时,允许访问包的连接跟踪状态。

–state state
这里state是一个逗号分割的匹配连接状态列表。可能的状态是:INVALID表示包是未知连接,ESTABLISHED表示是双向传送的连接,NEW表示包为新的连接,否则是非双向传送的,而RELATED表示包由新连接开始,但是和一个已存在的连接在一起,如FTP数据传送,或者一个ICMP错误。

unclean
此模块没有可选项,不过它试着匹配那些奇怪的、不常见的包。处在实验中。

tos
此模块匹配IP包首部的8位tos(服务类型)字段(也就是说,包含在优先位中)。

–tos tos
这个参数可以是一个标准名称,(用iptables -m tos -h 察看该列表),或者数值。

TARGET EXTENSIONS
iptables可以使用扩展目标模块:以下都包含在标准版中。

LOG
为匹配的包开启内核记录。当在规则中设置了这一选项后,linux内核会通过printk()打印一些关于全部匹配包的信息(诸如IP包头字段等)。
–log-level level
记录级别(数字或参看 syslog.conf(5))。
–log-prefix prefix
在纪录信息前加上特定的前缀:最多14个字母长,用来和记录中其他信息区别。

–log-tcp-sequence
记录TCP序列号。如果记录能被用户读取那么这将存在安全隐患。

–log-tcp-options
记录来自TCP包头部的选项。
–log-ip-options
记录来自IP包头部的选项。

MARK
用来设置包的netfilter标记值。只适用于mangle表。

–set-mark mark

REJECT
作为对匹配的包的响应,返回一个错误的包:其他情况下和DROP相同。

此目标只适用于INPUT、FORWARD和OUTPUT链,和调用这些链的用户自定义链。这几个选项控制返回的错误包的特性:

–reject-with type
Type可以是icmp-net-unreachable、icmp-host-unreachable、icmp-port-nreachable、icmp-proto-unreachable、 icmp-net-prohibited 或者 icmp-host-prohibited,该类型会返回相应的ICMP错误信息(默认是port-unreachable)。选项 echo-reply也是允许的;它只能用于指定ICMP ping包的规则中,生成ping的回应。最后,选项tcp-reset可以用于在INPUT链中,或自INPUT链调用的规则,只匹配TCP协议:将回应一个TCP RST包。
TOS
用来设置IP包的首部八位tos。只能用于mangle表。

–set-tos tos
你可以使用一个数值型的TOS 值,或者用iptables -j TOS -h 来查看有效TOS名列表。
MIRROR
这是一个试验示范目标,可用于转换IP首部字段中的源地址和目标地址,再传送该包,并只适用于INPUT、FORWARD和OUTPUT链,以及只调用它们的用户自定义链。

SNAT
这个目标只适用于nat表的POSTROUTING链。它规定修改包的源地址(此连接以后所有的包都会被影响),停止对规则的检查,它包含选项:

–to-source [-][:port-port]
可以指定一个单一的新的IP地址,一个IP地址范围,也可以附加一个端口范围(只能在指定-p tcp 或者-p udp的规则里)。如果未指定端口范围,源端口中512以下的(端口)会被安置为其他的512以下的端口;512到1024之间的端口会被安置为1024以下的,其他端口会被安置为1024或以上。如果可能,端口不会被修改。

–to-destiontion [-][:port-port]
可以指定一个单一的新的IP地址,一个IP地址范围,也可以附加一个端口范围(只能在指定-p tcp 或者-p udp的规则里)。如果未指定端口范围,目标端口不会被修改。

MASQUERADE
只用于nat表的POSTROUTING链。只能用于动态获取IP(拨号)连接:如果你拥有静态IP地址,你要用SNAT。伪装相当于给包发出时所经过接口的IP地址设置一个映像,当接口关闭连接会终止。这是因为当下一次拨号时未必是相同的接口地址(以后所有建立的连接都将关闭)。它有一个选项:

–to-ports [-port>]
指定使用的源端口范围,覆盖默认的SNAT源地址选择(见上面)。这个选项只适用于指定了-p tcp或者-p udp的规则。

REDIRECT
只适用于nat表的PREROUTING和OUTPUT链,和只调用它们的用户自定义链。它修改包的目标IP地址来发送包到机器自身(本地生成的包被安置为地址127.0.0.1)。它包含一个选项:

–to-ports [ ]
指定使用的目的端口或端口范围:不指定的话,目标端口不会被修改。只能用于指定了-p tcp 或 -p udp的规则。

DIAGNOSTICS
诊断
不同的错误信息会打印成标准错误:退出代码0表示正确。类似于不对的或者滥用的命令行参数错误会返回错误代码2,其他错误返回代码为1。

BUGS
臭虫
Check is not implemented (yet).
检查还未完成。

COMPATIBILITY WITH IPCHAINS
与ipchains的兼容性
iptables和Rusty Russell的ipchains非常相似。主要区别是INPUT 链只用于进入本地主机的包,而OUTPUT只用于自本地主机生成的包。因此每个包只经过三个链的一个;以前转发的包会经过所有三个链。其他主要区别是 -i 引用进入接口;-o引用输出接口,两者都适用于进入FORWARD链的包。当和可选扩展模块一起使用默认过滤器表时,iptables是一个纯粹的包过滤器。这能大大减少以前对IP伪装和包过滤结合使用的混淆,所以以下选项作了不同的处理:
-j MASQ
-M -S
-M -L
在iptables中有几个不同的链。

分类: BSD/linux, 转载 标签: ,

磁盘分区挂载表

2011年7月12日 16hot 没有评论

FreeBSD系统下的分区挂载表。

% cat /etc/fstab
# Device        Mountpoint    FStype    Options        Dump    Pass#
/dev/ada0s1b        none        swap    sw        0    0
/dev/ada0s1a        /        ufs    rw        1    1
/dev/ada0s3e        /opt        ufs    rw        2    2
/dev/ada0s2e        /opt/data        ufs    rw        2    2
/dev/ada0s2d        /opt/vm1        ufs    rw        2    2
/dev/ada0s3d        /opt/vm2        ufs    rw        2    2
/dev/ada0s1d        /tmp        ufs    rw        2    2
/dev/ada0s1f        /usr        ufs    rw        2    2
/dev/ada0s1e        /var        ufs    rw        2    2
/dev/cd0        /cdrom        cd9660    ro,noauto    0    0
proc            /proc       procfs  rw 0 0
linprocfs /compat/linux/proc linprocfs rw 0 0

如何在linux中mount ufs2文件系统?

FreeBSD的默认文件系统是ufs2。 可以用:

mount -r -t ufs -o ufstype=ufs2 /dev/hda10 /mnt

这样的命令来挂载。

前提:Linux内核中必须启用ufs和bsd disk label支持. 即

CONFIG_BSD_DISKLABEL=y
CONFIG_UFS_FS=y
CONFIG_UFS_FS_WRITE=y
分类: BSD/linux 标签: , ,

chroot-symlinks

2010年5月31日 16hot 没有评论

A typical scenario is one where “DefaultRoot ~” is used to restrict users to their home directories, and where the administrator would like to have a shared upload directory, say /var/ftp/incoming, in each user’s home directory. Symbolic links would normally be used to provide an arrangement like this. As mentioned above, though, when chroot(2) is used (which is what the DefaultRoot directive does), symlinks that point outside the new root (the user’s home directory in this case) will not work. To get around this apparent limitation, it is possible on modern operating systems to mount directories at several locations in the filesystem.

To have an exact duplicate of the /var/ftp/incoming directory available in /home/bob/incoming and /home/dave/incoming, use one of these commands:

    * Linux (as of the 2.4.0 kernel):

mount --bind /var/ftp/incoming /home/bob/incoming
  mount --bind /var/ftp/incoming /home/dave/incoming

    * BSD (as of 4.4BSD):

mount_null /var/ftp/incoming /home/bob/incoming
  mount_null /var/ftp/incoming /home/dave/incoming

    * Solaris:

mount -F lofs /var/ftp/incoming /home/bob/incoming
  mount -F lofs /var/ftp/incoming /home/dave/incoming

The same technique can be used for <Anonymous> directories, which also operate in a chroot()ed environment.

As usual, more information can be found by consulting the man pages for the appropriate command for your platform. The commands for other flavors of Unix will be added as needed.

In order to have these tricks persist, to survive a system reboot, the /etc/fstab (or /etc/vfstab) file may need to have these mounts added. Consult your local fstab(5) (or vfstab(4) for Solaris) man pages for more information.

http://www.proftpd.org/localsite/Userguide/linked/chroot-symlinks.html

分类: BSD/linux 标签: , , ,

Enable core dump in Linux and FreeBSD(转)

2010年4月26日 16hot 没有评论

Just a note.

You can enable core dump by:

[bash] edit /etc/profile

ulimit -c unlimited

[csh/tcsh] edit /etc/csh.cshrc

limit coredumpsize unlimited

You can disable core dump by:

[bash] edit /etc/profile

ulimit -c 0

[csh/tcsh] edit /etc/csh.cshrc

limit coredumpsize 0

On FreeBSD, you also need to check the setting of kern.coredump:

# sysctl -a |grep kern.coredump
kern.coredump: 0
# sysctl kern.coredump=1
kern.coredump: 0 -> 1
# sysctl -a | grep kern.coredump
kern.coredump: 1

You can enforce this setting in /etc/sysctl.conf

[2008/01/01] Thanks for the complement from gslin, kern.sugid_coredump controls the core dump for setuid/setgid process in FreeBSD.

分类: BSD/linux, 转载 标签: , ,

Linux IPv6 HOWTO (4)

2008年9月13日 16hot 没有评论
14.1 Red Hat Linux and "clones"(小紅帽和它的弟兄娣妹)

   自從我開始寫 [33]IPv6 & Linux - HowTo.我打算設定一個持久的IPv6配置,包   含: host-only, router-only, dual-homed-host, router with second stub   network, normal tunnels, 6to4 tunnels 和其它.現在我寫了一   個configuration and script files 這個script有自己的HOWTO:

   [34]IPv6-HOWTO/scripts/current. 夠運的是, Red Hat Linux 從 7.1 開始就   包含了這個script.多虧了Pekka Savola的幫助.

14.2 Mandrake(曼德萊克)Linux

   從8.0後也包含了 IPv6-enabled initscript package但是有點小問   題("ifconfig" misses "inet6" before "add").

  支持IPv6的網路設定 scripts 測試

   script library應該存在:       ______________________________________________________________

                     /etc/sysconfig/network-scripts/network-functions-ipv6       ______________________________________________________________

   自動測試:       ______________________________________________________________

                     # test -f /etc/sysconfig/network-scripts/network-functions-ipv6 && echo "Main                     ? IPv6 script library exists"       ______________________________________________________________

   library的版本很重要, 更高的版本包含了更多的功能.您可以通過這個檢視它:       ______________________________________________________________

                     # source /etc/sysconfig/network-scripts/network-functions-ipv6 &&                     ? getversion_ipv6_functions                     20011124       ______________________________________________________________

  Short hint for enabling IPv6 on current RHL 7.1, 7.2, 7.3, ...(一些小提示)

     * 檢視IPv6模組是否已經掛進系統.       ______________________________________________________________

                    # modprobe -c | grep net-pf-10                    alias net-pf-10 off       ______________________________________________________________

     * 如果是"off" 在 /etc/sysconfig/network 中加入IPv6的支持.       ______________________________________________________________

                    NETWORKING_IPV6=yes       ______________________________________________________________

     * 重新初始網路:       ______________________________________________________________

                    # service network restart       ______________________________________________________________

     * IPv6模組應該掛進來了:       ______________________________________________________________

                    # modprobe -c | grep ipv6                    alias net-pf-10 ipv6       ______________________________________________________________

   如果您提供路由廣告autoconfiguration 會自動為您設定, 更多的資訊請看   /usr/share/doc/initscripts-$version/sysconfig.txt.

14.3 SuSE(蘇澤斯)Linux

   7.x 以上, 支持IPv6. 在/etc/rc.config 裡有更多的資訊. 因為不同的設定方   法和scripts結構, 所以不能將Red Hat Linux 當中的方法照搬過來.

  更詳盡的資訊請看:

   [35]How to setup 6to4 IPv6 with SuSE 7.3

14.4 Debian(迪比安)Linux

   參照: [36]IPv6 on Debian Linux

15. 防火牆

15.1 使用 netfilter6防火牆

   netfilter6防火牆只支持2.4以上的核心.早期的2.2核心您只能用41號協議過   濾IPv6-in-IPv4.

   警告: 按照例子那樣設定並不能真正地保護您的作業系統.

15.2 更多的資訊:

     * [37]Netfilter project     * [38]maillist archive of netfilter users     * [39]maillist archive of netfilter developers     * [40]Unofficial status informations

15.3 準備

   下載最新的核心:   [41]http://www.kernel.org/

   下載最新的iptables:

   tar:   [42]http://www.netfilter.org/

   Source RPM for rebuild of binary (for RedHat systems):   [43]ftp://ftp.redhat.com/redhat/linux/rawhide/SRPMS/SRPMS/

  解開源代碼

   解開源代碼與更名       ______________________________________________________________

        # tar z|jxf kernel-version.tar.gz|bz2        # mv linux linux-version-iptables-version+IPv6       ______________________________________________________________

   解開 iptables 源代碼       ______________________________________________________________

         # tar z|jxf iptables-version.tar.gz|bz2       ______________________________________________________________

   Apply pending patches       ______________________________________________________________

         # make pending-patches KERNEL_DIR=/path/to/src/linux-version-iptables-version/       ______________________________________________________________

   Apply additional IPv6 related patches (still not in the vanilla kernel   included)       ______________________________________________________________

         # make patch-o-matic KERNEL_DIR=/path/to/src/linux-version-iptables-version/       ______________________________________________________________

   在下面的選單中回答yes:     * ah-esp.patch     * masq-dynaddr.patch (only needed for systems with dynamic IP       assigned WAN connections like PPP or PPPoE)     * ipv6-agr.patch.ipv6     * ipv6-ports.patch.ipv6     * LOG.patch.ipv6     * REJECT.patch.ipv6

   檢視IPv6括展:       ______________________________________________________________

         # make print-extensions         Extensions found: IPv6:owner IPv6:limit IPv6:mac IPv6:multiport       ______________________________________________________________

  Configure, build and install new kernel(設定,編譯,安裝新的核心)

   進入代碼目錄:       ______________________________________________________________

        # cd /path/to/src/linux-version-iptables-version/       ______________________________________________________________

   改變Makefile       ______________________________________________________________

         - EXTRAVERSION =         + EXTRAVERSION = -iptables-version+IPv6-try       ______________________________________________________________

   運行相關的設定:Run configure, enable IPv6 related       ______________________________________________________________

         Code maturity level options                  Prompt for development and/or incomplete code/drivers : yes            Networking options                  Network packet filtering: yes                  The IPv6 protocol: module                       IPv6: Netfilter Configuration                             IP6 tables support: module                             All new options like following:                                   limit match support: module                                   MAC address match support: module                                   Multiple port match support: module                                   Owner match support: module                                   netfilter MARK match support: module                                   Aggregated address check: module                                   Packet filtering: module                                        REJECT target support: module                                        LOG target support: module                                   Packet mangling: module                                   MARK target support: module       ______________________________________________________________

   在系統的其它方面進行相應的修改.

  Rebuild and install binaries of iptables (打造一個新的iptables)

   確定您的核心源代碼存在於: /usr/src/linux/

   Rename older directory       ______________________________________________________________

         # mv /usr/src/linux /usr/src/linux.old       ______________________________________________________________

   Create a new softlink       ______________________________________________________________

         # ln /path/to/src/linux-version-iptables-version /usr/src/linux       ______________________________________________________________

   Rebuild SRPMS       ______________________________________________________________

         # rpm --rebuild /path/to/SRPMS/iptables-version-release.src.rpm       ______________________________________________________________

   Install new iptables packages (iptables + iptables-ipv6) 安裝新   的iptables     * On RH 7.1 systems, 通常已經有一個更早的版本, therefore use       "freshen"       ______________________________________________________________

         # rpm -Fhv /path/to/RPMS/cpu/iptables*-version-release.cpu.rpm       ______________________________________________________________

     * 如果沒有安裝,您就親自來吧:       ______________________________________________________________

         # rpm -ihv /path/to/RPMS/cpu/iptables*-version-release.cpu.rpm       ______________________________________________________________

     * 如果在RH6.2上安裝,要加上"--nodep":       ______________________________________________________________

         # rpm -ihv --nodep /path/to/RPMS/cpu/iptables*-version-release.cpu.rpm

       ______________________________________________________________

     * 可能要為iptables加上一個softlink:       ______________________________________________________________

          # ln -s /lib/iptables/ /usr/lib/iptables       ______________________________________________________________

15.4 使用方法

  檢視

   將模組掛進來:       ______________________________________________________________

         # modprobe ip6_tables       ______________________________________________________________

   檢視       ______________________________________________________________

         # [ ! -f /proc/net/ip6_tables_names ] && echo "Current kernel doesn'tsupport         ? 'ip6tables' firewalling (IPv6)!"       ______________________________________________________________

15.5 使用ip6tables

16.3.2.1. List all IPv6 netfilter entries

Short

# ip6tables -L

Extended

# ip6tables -n -v --line-numbers -L

List specified filter# ip6tables -n -v --line-numbers -L INPUT

 加入一個日誌:# ip6tables --table filter --append INPUT  -j LOG --log-prefix "INPUT:"? --log-level 7

加入一個入站丟棄的條件:# ip6tables --table filter --append INPUT  -j DROP

移除一個條件:# ip6tables --table filter --delete INPUT 1

允許 ICMPv6:Using older kernels (unpatched kernel 2.4.5 and iptables-1.2.2) no type can bespecified

允許入站 ICMPv6 經過 tunnels

# ip6tables -A INPUT -i sit+ -p icmpv6 -j ACCEPT

允許出站 ICMPv6 經過 tunnels# ip6tables -A OUTPUT -o sit+ -p icmpv6 -j ACCEPT

Newer kernels allow specifying of ICMPv6 types:

# ip6tables -A INPUT -p icmpv6 --icmpv6-type echo-request -j ACCEPT

限制Rate-limitingBecause it can happen (author already saw it to times) that an ICMPv6 storm will raise up, you should use available rate limiting for at least ICMPv6 ruleset. In addition logging rules should also get rate limiting to prevent DoS attacks against syslog and storage of log file partition. An example for a rate limited ICMPv6 looks like:

# ip6tables -A INPUT --protocol icmpv6 --icmpv6-type echo-request -j ACCEPT --match limit --limit 30/minute

 允許入站的 SSHHere an example is shown for a ruleset which allows incoming SSH connection from a specified IPv6 address

  允許來自 3ffe:ffff:100::1/128 的 SSH 入站

# ip6tables -A INPUT -i sit+ -p tcp -s 3ffe:ffff:100::1/128 --sport 512:65535? --dport 22 -j ACCEPT

允許回應包Allow response packets (此刻 IPv6 連結追蹤不在 mainstream netfilter6implemented 當中)

# ip6tables -A OUTPUT -o sit+ -p tcp -d 3ffe:ffff:100::1/128 --dport 512:65535? --sport 22 ! --syn j ACCEPT

充許 tunneled IPv6-in-IPv4Tto accept tunneled IPv6-in-IPv4 packets, 在IPv4 防火牆做相應的設定 firewall setup relating to such packets, for example

充許 interface ppp0 的 IPv6-in-IPv4 入站

# iptables -A INPUT -i ppp0 -p ipv6 -j ACCEPT

充許 interface ppp0 的 IPv6-in-IPv4 出站

# iptables -A OUTPUT -o ppp0 -p ipv6 -j ACCEPT

If you have only a static tunnel, you can specify the IPv4 addresses, too, like

充許來自 endpoint 1.2.3.4 的 IPv6-in-IPv4 通過 interface ppp0 入站

# iptables -A INPUT -i ppp0 -p ipv6 -s 1.2.3.4 -j ACCEPT

充許來自 endpoint 1.2.3.4 的 IPv6-in-IPv4 通過 interface ppp0 入站

# iptables -A OUTPUT -o ppp0 -p ipv6 -d 1.2.3.4 -j ACCEPT

16.3.2.10. Protection against incoming TCP connection requests極力推薦! 出於安全考慮 您應當加入一個阻止TCP 連結請求入站的條件 . Adapt "-i" option, if other interface names are in use!

阻止入站的 TCP 連結請求

# ip6tables -I INPUT -i sit+ -p tcp --syn -j DROP

在路由器後面 阻止入站的 TCP 連結請求

# ip6tables -I FORWARD -i sit+ -p tcp --syn -j DROP

可能這些條件以經存在其它地方,但這是您想當然的想法.最好建一個包含很多條件的 script 然後執行.

16.3.2.11.阻止入站的 UDP 連結請求

極力推薦! 提起過我的防火牆資訊可以控制出站 UDP/TCP 會話的端口. 所以如果您的本地IPv6系統使用本地端口 比如:從 32768 至 60999 您也可以像這樣過濾UDP連結 (直到連結跟蹤正常工作) like:

阻止入站的 UDP 數據包 , 斬斷請求出站的回應數據包

# ip6tables -I INPUT -i sit+ -p udp ! --dport 32768:60999 -j DROP

在路由器上面阻止入站的 UDP 數據包轉寄到路由器後面的主機

ip6tables -I FORWARD -i sit+ -p udp ! --dport 32768:60999 -j DROP

  實例:

   下面這個實例是一個經典, 由 Happy netfilter6 ruleset 生成:       ______________________________________________________________

# ip6tables -n -v -LChain INPUT (policy DROP 0 packets, 0 bytes) pkts bytes target     prot opt in     out     source               destination    0     0 extIN      all      sit+   *       ::/0                 ::/0    4   384 intIN      all      eth0   *       ::/0                 ::/0    0     0 ACCEPT     all      *      *       ::1/128              ::1/128    0     0 ACCEPT     all      lo     *       ::/0                 ::/0    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `INPUT-default:'    0     0 DROP       all      *      *       ::/0                 ::/0

Chain FORWARD (policy DROP 0 packets, 0 bytes) pkts bytes target     prot opt in     out     source               destination?    0     0 int2ext    all      eth0   sit+    ::/0                 ::/0    0     0 ext2int    all      sit+   eth0    ::/0                 ::/0    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `FORWARD-default:'    0     0 DROP       all      *      *       ::/0                 ::/0

Chain OUTPUT (policy DROP 0 packets, 0 bytes) pkts bytes target     prot opt in     out     source               destination?    0     0 extOUT     all      *      sit+    ::/0                 ::/0    4   384 intOUT     all      *      eth0    ::/0                 ::/0    0     0 ACCEPT     all      *      *       ::1/128              ::1/128    0     0 ACCEPT     all      *      lo      ::/0                 ::/0    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `OUTPUT-default:'    0     0 DROP       all      *      *       ::/0                 ::/0

Chain ext2int (1 references) pkts bytes target     prot opt in     out     source               destination?    0     0 ACCEPT     icmpv6    *      *       ::/0                 ::/0    0     0 ACCEPT     tcp      *      *       ::/0                 ::/0?        tcp spts:1:65535 dpts:1024:65535 flags:!0x16/0x02    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `ext2int-default:'    0     0 DROP       tcp      *      *       ::/0                 ::/0    0     0 DROP       udp      *      *       ::/0                 ::/0    0     0 DROP       all      *      *       ::/0                 ::/0

Chain extIN (1 references) pkts bytes target     prot opt in     out     source               destination?    0     0 ACCEPT     tcp      *      *       3ffe:400:100::1/128  ::/0?        tcp spts:512:65535 dpt:22    0     0 ACCEPT     tcp      *      *       3ffe:400:100::2/128  ::/0?        tcp spts:512:65535 dpt:22    0     0 ACCEPT     icmpv6    *      *       ::/0                 ::/0    0     0 ACCEPT     tcp      *      *       ::/0                 ::/0?        tcp spts:1:65535 dpts:1024:65535 flags:!0x16/0x02    0     0 ACCEPT     udp      *      *       ::/0                 ::/0?        udp spts:1:65535 dpts:1024:65535    0     0 LOG        all      *      *       ::/0                 ::/0?        limit: avg 5/min burst 5 LOG flags 0 level 7 prefix `extIN-default:'    0     0 DROP       all      *      *       ::/0                 ::/0

Chain extOUT (1 references) pkts bytes target     prot opt in     out     source               destination?    0     0 ACCEPT     tcp      *      *       ::/0? 3ffe:ffff:100::1/128tcp spt:22 dpts:512:65535 flags:!0x16/0x02    0     0 ACCEPT     tcp      *      *       ::/0? 3ffe:ffff:100::2/128tcp spt:22 dpts:512:65535 flags:!0x16/0x02    0     0 ACCEPT     icmpv6    *      *       ::/0                 ::/0    0     0 ACCEPT     tcp      *      *       ::/0                 ::/0?        tcp spts:1024:65535 dpts:1:65535    0     0 ACCEPT     udp      *      *       ::/0                 ::/0?        udp spts:1024:65535 dpts:1:65535    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `extOUT-default:'    0     0 DROP       all      *      *       ::/0                 ::/0

Chain int2ext (1 references) pkts bytes target     prot opt in     out     source               destination?    0     0 ACCEPT     icmpv6    *      *       ::/0                 ::/0    0     0 ACCEPT     tcp      *      *       ::/0                 ::/0?        tcp spts:1024:65535 dpts:1:65535    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `int2ext:'    0     0 DROP       all      *      *       ::/0                 ::/0    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `int2ext-default:'    0     0 DROP       tcp      *      *       ::/0                 ::/0    0     0 DROP       udp      *      *       ::/0                 ::/0    0     0 DROP       all      *      *       ::/0                 ::/0

Chain intIN (1 references) pkts bytes target     prot opt in     out     source               destination?    0     0 ACCEPT     all      *      *       ::/0? fe80::/ffc0::    4   384 ACCEPT     all      *      *       ::/0                 ff02::/16

Chain intOUT (1 references) pkts bytes target     prot opt in     out     source               destination?    0     0 ACCEPT     all      *      *       ::/0? fe80::/ffc0::    4   384 ACCEPT     all      *      *       ::/0                 ff02::/16    0     0 LOG        all      *      *       ::/0                 ::/0?        LOG flags 0 level 7 prefix `intOUT-default:'    0     0 DROP       all      *      *       ::/0                 ::/0       ______________________________________________________________

16. 安全

16.1 Access limitations

   有許多服務使用 tcp_wrapper library 控制訪問.Below is described the use   of tcp_wrapper

   內容有待增加...

16.2 IPv6安全審核

   目前沒有什麼較好的商業工具來進行

  Legal issues

   警告:您只能掃瞄自己的系統,不然,可能會觸及法律.開始之前,請檢察您要掃瞄   的IPv6目標地址兩次!.

16.3 Security auditing using IPv6-enabled netcat(使用適應IPv6的netcat)

   關於IPv6-enabled netcat的詳細資訊請參照: [44]   IPv6?status-apps/security-auditing

   例子:       ______________________________________________________________

         # nc6 ::1 daytime         13 JUL 2002 11:22:22 CEST       ______________________________________________________________

16.4 Security auditing using IPv6-enabled nmap

   全世界最為優秀的掃瞄程式之一.它的首頁: [45]   http://www.insecure.org/nmap/ 從 3.10ALPHA1 的版本開始支持IPv6. 例子:       ______________________________________________________________

         # nmap -6 -sT ::1         Starting nmap V. 3.10ALPHA3 ( www.insecure.org/nmap/ )         Interesting ports on localhost6 (::1):         (The 1600 ports scanned but not shown below are in state: closed)         Port       State       Service         22/tcp     open        ssh         53/tcp     open        domain         515/tcp    open        printer         2401/tcp   open        cvspserver         Nmap run completed -- 1 IP address (1 host up) scanned in 0.525 seconds       ______________________________________________________________

16.5 Security auditing using IPv6-enabled strobe

   Strobe 同 NMap相比更不具靈活性,但已經有 IPv6-enabling patch (see   IPv6?status-apps/security-auditing for more). Usage example:       ______________________________________________________________

         # ./strobe ::1 strobe 1.05 (c) 1995-1999 Julian Assange <proff@iq.org>.         ::1 2401 unassigned unknown         ::1 22 ssh Secure Shell - RSA encrypted rsh         ::1 515 printer spooler (lpd)         ::1 6010 unassigned unknown         ::1 53 domain Domain Name Server       ______________________________________________________________

16.6 審核結果

   如果審核結果同您的IPv6安全策略有出入, 請堵上檢測出的漏洞.

17. Encryption and Authentication(加密和認證)

   Support in kernel

   Currently missing in 2.4, perhaps in 2.5 (see below). There is an   issue about keeping the Linux kernel source free of   export/import-control-laws regarding encryption code. This is also one   case why [46]FreeS/WAN project (IPv4 only IPsec) isn't still contained   in vanilla source.

   Support in USAGI kernel

   The USAGI project has taken over in July 2001 the IPv6 enabled   FreeS/WAN code from the [47]IABG / IPv6 Project and included in their   kernel extensions, but still work in progress, means that not all IABG   features are already working in USAGI extension.

17.1 用法

   參照: [48]FreeS/WAN / Online documentation

18. 線上測試工具

   內容有待增加... 歡迎提建議!     * finger, nslookup, ping, traceroute, whois: [49]UK IPv6 Resource       Centre / The test page     * ping, traceroute, tracepath, 6bone registry, DNS: [50]JOIN /       Testtools (German language only, but should be no problem for non       German speakers)     * traceroute6, whois: [51]IPng.nl

19. 其它資訊

19.1 線上資訊

   加入IPv6 backbone骨幹網路   IPv6 test backbone: [52]6bone, [53]How to join 6bone

  主要的註冊區域

     * America: [54]ARIN [55]Ripe     * Asia/Pacific: [56]APNIC     * Latin America and Caribbea: [57]LACNIC

   Also a list of major (prefix length 35) allocations per local registry   is available here:   [58]Ripe NCC / IPv6 allocations

  Tunnel brokers

     * [59]Freenet6 Canada     * [60]Hurricane Electric US backbone     * [61]Centro Studi e Laboratory Telecomunicazioni Italy     * [62]Wanadoo Belgium     * [63]CERTNET-Nokia China     * [64]Tunnelbroker Leipzig Germany - DialupUsers with dynamic IP's       can get a fix IPv6 IP...     * [65]Internet Initiative Japan Japan - with IPv6 native line       service and IPv6 tunneling Service     * [66]XS26 - Access to SixNetherland - with POPs in Slovak Republic,       Czech Republic, Netherlands, Germany and Hungary.     * [67]IPng Netherland Netherland - Intouch, SurfNet, AMS-IX, UUNet,       Cistron, RIPE NCC and AT& T are connected at the AMS-IX. It is       possible (there are requirements...) to get an static tunnel.     * [68]UNINETT Norway - Pilot IPv6 Service (for Customers):       tunnelbroker & address allocation     * [69]NTT Europe [70]NTT Euroope United Kingdom - IPv6 Trial. IPv4       Tunnel and native IPv6 leased Line connections. POPs are located       in London, UK Dusseldorf, Germany New Jersey, USA (East Coast)       Cupertino, USA (West Coast) Tokyo, Japan     * [71]ESnet USA - Energy Sciences Network: Tunnel Registry & Address       Delegation for directly connected ESnet sites and ESnet       collaborators.     * [72]6REN USA - The 6ren initiative is being coordinated by the       Energy Sciences Network (ESnet), the network for the Energy       Research program of the US Dept. of Energy, located at the       University of California's Lawrence Berkeley National Laboratory

   更多的IPv6資訊: [73]ipv6-net.org

  6to4

     * [74]NSayer's 6to4 information     * [75]RFC 3068 / An Anycast Prefix for 6to4 Relay Routers

  Latest news

     * [76]http://hs247.com/ name="hs247 / IPv6 news and information">       also homepage for #ipv6 channel on EFnet     * [77]bofh.st / latest IPv6 news but currently Jan 2002 outdated...,       also homepage for IPv6 channel on IRCnet     * [78]ipv6-net.org German forum

  有關協議的參考

     * [79]HS247 / IPv6 RFC list Publishing the list of IPv6-related RFCs       is beyond the scope of this document, but given URLs will lead you       to such lists:     * [80]IPng Standardization Status a little bit out-of-sync at the       moment     * [81]IPv6 Related Specifications on IPv6.org

  目前與IPv6有關的草案:

     * [82]IP Version 6 ipv6     * [83]Next Generation Transitition      * [84]Dynamic Host Configuration      * [85]Domain Name System Extension      * [86]Mobile IP mobileip

  其它

     * [87]Network Sorcery / IPv6, Internet Protocol version 6 IPv6       protocol header     * [88]SWITCH IPv6 Pilot / References big list of IPv6 references       maintained by Simon Leinen     * [89]Advanced Network Management Laboratory / IPv6 Address Oracle       shows you IPv6 addresses in detail

  統計

     * [90]IPv6 routing table history created by Gert Ding

19.2 更多的資訊

   期待加入更多的內容,歡迎提建議!

  Linux related

     * [91]IPv6-HowTo for Linux by Peter Bieringer - Germany, and his     * [92]Bieringer / IPv6 - software archive     * [93]Linux+IPv6 status by Peter Bieringer Germany     * [94]USAGI project Japan, and their     * [95]USAGI project - software archive     * [96]Gav's Linux IPv6 Page     * [97]Project6 - IPv6 Networking For Linux Italy, and their     * [98]Project6 - software archive

19.3 通信論壇

+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             ||    Focus            Request e-mail address       What to subscribe Maillist e-mail address                Language                Access throughWWW                                                          |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|  Linux kernel        majordomo (at)                oss.sgi.com netdev netdev (at) oss.sgi.com          English               http://oss.sgi.com/projects/netdev/archive/                                         ||  networking

                                                             ||  including

                                                             ||  IPv6

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|  Linux and          majordomo (at)                  linux-ipv6 linux-ipv6 (at) list.f00f.org    English                                                             ||                       list.f00f.org

                                                             || IPv6 in (moderated)                                                             || general (1)

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+| Mobile IP           majordomo (at) mipl (at) list.mipl.             English               http://www.mipl.mediapoli.com/mailinglist.html                                      || (v6) for            list.mipl.mediapoli.com            mipl mediapoli.com                                          http://www.mipl.mediapoli.com/mail-archive/                                         ||  Linux

                                                             ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|Linux IPv6          usagi-users-ctl usagi-users                      English               http://www.mipl.mediapoli.com/mailinglist.html                                      ||users using         (at) linux-ipv6.org (at) linux-ipv6.org                                    http://www.mipl.mediapoli.com/mail-archive/                                         ||USAGI

                                                             ||extension

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             ||IPv6 on Debian debian-ipv6 (at)                 English               http://lists.debian.org/debian-ipv6/                                                ||Linux               Web-based, see URL lists.debian.org                                                             ||Web-based

                                                             ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             ||IPv6/6bone in        majordomo (at) ipv6 (at)                        German/English        http://www.join.uni-muenster.de/JOIN/ipv6/texte-englisch/mailingliste.html          || Germany             atlan.uni-muenster.de           ipv6 uni-muenster.de                                        http://www.join.uni-muenster.de/local/majordomo/ipv6/                               ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             || 6bone                  majordomo (at)               6bone 6bone (at)                       English               http://www.6bone.net/6bone_email.html                                               ||                       isi.edu isi.edu                                                http://ryouko.dgim.crc.ca/ipv6/                                                     ||                                                        http://www.wcug.wwu.edu/lists/6bone/                                                ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             ||IPv6                    majordomo (at)               ipng ipng (at)                        English               http://playground.sun.com/pub/ipng/html/instructions.html                           ||discussions             sunroof.eng.sun.com sunroof.eng.sun.com                                    ftp://playground.sun.com/pub/ipng/mail-archive/                                     ||                                                        http://www.wcug.wwu.edu/lists/ipng/                                                 |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             || IPv6 users              majordomo (at)              users users (at) ipv6.org              English               http://www.ipv6.org/mailing-lists.html                                              || in general                 ipv6.org

                                                             ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             || Bugtracking of         bugtraq-subscribe (at) bugtraq (at)                     English               http://online.securityfocus.com/popups/forums/bugtraq/intro.shtml                   || Internet               securityfocus.com securityfocus.com (moderated)                          http://online.securityfocus.com/archive/1                                           || applications (2)

                                                             ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+|

                                                             || IPv6 in general          Web-based, see URL ipv6 (at) ipng.nl                English              http://mailman.ipng.nl/mailman/listinfo/ipv6/                                        ||                                                       http://mailman.ipng.nl/pipermail/ipv6/                                               ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

|

                                                             |

|

                                                             ||

                                                             ||

                                                             || majordomo (at)             majordomo (at)            ipv6 ipv6 (at) mfa.eti.br             Portuguese           http://www.mfa.eti.br/listas.html                                                    ||  mfa.eti.br                mfa.eti.br

                                                             ||

                                                             |+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

 (1) recommended for common Linux & IPv6 issues.

 (2) very recommended if you provide server applications.

 是不是有什麼遺漏? 歡迎你的建議!

 這裡還有另一份清單:        http://www.join.uni-muenster.de/JOIN/ipv6/texte-englisch/ipv6.infoquellen.html

  有關的發行版

     * [99]Polish(ed) Linux Distribution ("market leader" in containing       IPv6 enabled packages)     * [100]Red Hat Linux     * [101]Pekka Savola's IPv6 packages Germany     * [102]Debian Linux     * [103]Craig Small's IPv6 information and status     * [104]SuSE Linux     * [105]Linux Mandrake

20. 歷史

   x.y版本 發佈在Internet上.   x.y.z 表示正在進行的版本and only published as LyX file on CVS.

 Releases 0.x

0.312002-09-29/PB: Extend information in proc-filesystem entries

0.302002-09-27/PB: Add some maillists

0.292002-09-18/PB: Update statement about nmap (triggered by Fyodor)

0.28.12002-09-16/PB: Add note about ping6 to multicast addresses, add some labels

0.282002-08-17/PB: Fix broken LDP/CVS links, add info about Polish translation, add URL of the IPv6 Address Oracle

0.272002-08-10/PB: Some minor updates

0.26.22002-07-15/PB: Add information neighbor discovery, split of firewalling (got some updates) and security into extra chapters

0.26.12002-07-13/PB: Update nmap/IPv6 information

0.262002-07-13/PB: Fill /proc-filesystem chapter, update DNS information about depricated A6/DNAME, change P-t-P tunnel setup to use of "ip" only

0.25.22002-07-11/PB: Minor spelling fixes

0.25.12002-06-23/PB: Minor spelling and other fixes

0.252002-05-16/PB: Cosmetic fix for 2^{ }128, thanks to Jos□ Ab□lio Oliveira Matos for help with LyX

0.242002-05-02/PB: Add entries in URL list, minor spelling fixes

0.232002-03-27/PB: Add entries in URL list and at maillists, add a label and minorinformation about IPv6 on RHL

0.222002-03-04/PB: Add info about 6to4 support in kernel series 2.2.x and add an entry in URL list and at maillists

0.212002-02-26/PB: Migrate next grammar checks submitted by John Ronan

0.20.42002-02-21/PB: Migrate more grammar checks submitted by John Ronan, add some additional hints at DNS section

0.20.32002-02-12/PB: Migrate a minor grammar check patch submitted by John Ronan

0.20.22002-02-05/PB: Add mipl to maillist table

0.20.12002-01-31/PB: Add a hint how to generate 6to4 addresses

0.202002-01-30/PB: Add a hint about default route problem, some minor updates

0.19.22002-01-29/PB: Add many new URLs

0.19.12002-01-27/PB: Add some forgotten URLs

0.192002-01-25/PB: Add two German books, fix quote entinities in exported SGML code

0.18.22002-01-23/PB: Add a FAQ on the program chapter

0.18.12002-01-23/PB: Move "the end" to the end, add USAGI to maillists

0.182002-01-22/PB: Fix bugs in explanation of multicast address types

0.17.22002-01-22/PB: Cosmetic fix double existing text in history (at 0.16), move all credits to the end of the document

0.17.12002-01-20/PB: Add a reference, fix URL text in online-test-tools

0.172002-01-19/PB: Add some forgotten information and URLs about global IPv6 addresses

0.162002-01-19/PB: Minor fixes, remove "bold" and "emphasize" formats on code lines, fix "too long unwrapped code lines" using selfmade utility, extend list of URLs.

0.152002-01-15/PB: Fix bug in addresstype/anycast, move content related credits toend of document

0.142002-01-14/PB: Minor review at all, new chapter "debugging", review "addresses", spell checking, grammar checking (from beginning to 3.4.1) by Martin Krafft,add tcpdump examples, copy firewalling/netfilter6 from IPv6+Linux-HowTo, minorenhancements

0.132002-01-05/PB: Add example BIND9/host, move revision history to end of document, minor extensions

0.122002-01-03/PB: Merge review of David Ranch

0.112002-01-02/PB: Spell checking and merge review of Pekka Savola

0.102002-01-02/PB: First public release of chapter 1

References

   1. http://www.bieringer.de/pb/   2. http://www.linuxports.com/howto/intro_to_networking/   3. http://rfc.net/rfc1884.html   4. http://rfc.net/rfc3056.html/   5. http://rfc.net/rfc2893.html   6. http://rfc.net/rfc2373.html   7. http://standards.ieee.org/regauth/oui/tutorials/EUI64.html   8. http://rfc.net/rfc3041.html   9. ftp://ftp.ietf.org/internet-drafts/  10. http://rfc.net/rfc1519.html  11. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-distributions.html  12. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-distributions.html  13. http://www.linuxdoc.org/HOWTO/Kernel-HOWTO.html  14. ftp://ftp.bieringer.de/pub/linux/IPv6/kernel  15. http://www.linux-ipv6.org/faq.html  16. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-kernel.html#transport  17. http://rfc.net/rfc1055.html  18. ftp://ftp.inr.ac.ru/ip-routing/  19. http://rpmfind.net/linux/rpm2html/search.php?query=iproute  20. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-distributions.html  21. file://localhost/tmp/zh-sgmltools.21666/IPv6&Linux-CurrentStatus-Applications  22. http://www.bieringer.de/linux/IPv6/IPv6-HOWTO/IPv6-HOWTO-3.html  23. http://www.bieringer.de/linux/IPv6/IPv6-HOWTO/IPv6-HOWTO-4.html  24. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-apps.html#HTTP  25. http://[3ffe:400:100::1]/  26. http://www.kame.net/  27. http://rfc.net/rfc2893.html  28. http://rfc.net/rfc3056.html  29. http://rfc.net/rfc3056.html  30. http://www.kfu.com/~nsayer/6to4/  31. http://www.faqs.org/rfcs/rfc3068.html  32. http://rfc.net/rfc2473.html  33. http://www.bieringer.de/linux/IPv6/  34. http://www.bieringer.de/linux/IPv6/IPv6-HOWTO/scripts/current/  35. http://www.feyrer.de/IPv6/SuSE73-IPv6+6to4-setup.html  36. http://people.debian.org/~csmall/ipv6/  37. http://www.netfilter.org/  38. http://lists.samba.org/pipermail/netfilter/  39. http://lists.samba.org/pipermail/netfilter-devel/  40. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-kernel.html#netfilter6  41. http://www.kernel.org/  42. http://www.netfilter.org/  43. ftp://ftp.redhat.com/redhat/linux/rawhide/SRPMS/SRPMS/  44. http://www.bieringer.de/linux/IPv6/status/IPv6?status-apps.html#security-auditing  45. http://www.insecure.org/nmap/  46. http://www.freeswan.org/  47. http://www.ipv6.iabg.de/downloadframe/  48. http://www.freeswan.org/doc.html  49. file://localhost/tmp/zh-sgmltools.21666/Linux-IPv6-HOWTO.txt.html  50. http://www.join.uni-muenster.de/lab/testtools.html  51. http://www.ipng.nl/  52. http://www.6bone.net/6bone_hookup.html  53. http://www.6bone.net/6bone_hookup.html  54. http://www.arin.net/  55. http://www.ripe.net/  56. http://www.apnic.net/  57. http://lacnic.org/  58. http://www.ripe.net/ripencc/mem-services/registration/ipv6/ipv6allocs.html  59. http://www.freenet6.net/  60. http://ipv6tb.he.net/  61. https://carmen.cselt.it/ipv6tb/  62. http://tunnel.be.wanadoo.com/  63. http://tb.6test.edu.cn/  64. http://joshua.informatik.uni-leipzig.de/  65. http://www.iij.ad.jp/IPv6/index-e.html  66. http://www.xs26.net/  67. http://www.ipng.nl/  68. http://www.uninett.no/testnett/index.en.html  69. http://www.uk.v6.ntt.net/  70. http://www.nttv6.net/  71. http://www.es.net/hypertext/welcome/pr/ipv6.html  72. http://www.6ren.net/  73. http://www.ipv6-net.de/  74. http://www.kfu.com/~nsayer/6to4/  75. http://www.faqs.org/rfcs/rfc3068.html  76. http://hs247.com/  77. http://bofh.st/ipv6/  78. http://www.ipv6-net.de/  79. http://www.hs247.com/ipv6rfc.html  80. http://playground.sun.com/pub/ipng/html/specs/standards.html  81. http://www.ipv6.org/specs.html  82. http://www.ietf.org/ids.by.wg/ipv6.html  83. http://www.ietf.org/ids.by.wg/ngtrans.html  84. http://www.ietf.org/ids.by.wg/dhc.html  85. http://www.ietf.org/ids.by.wg/dnsext.html  86. http://www.ietf.org/ids.by.wg/mobileip.html  87. http://www.networksorcery.com/enp/protocol/ipv6.htm  88. http://www.switch.ch/lan/ipv6/references.html  89. http://steinbeck.ucs.indiana.edu:47401/  90. http://www.space.net/~gert/RIPE/  91. http://www.bieringer.de/linux/IPv6/  92. ftp://ftp.bieringer.de/pub/linux/IPv6/  93. http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status.html  94. http://www.linux-ipv6.org/  95. ftp://ftp.linux-ipv6.org/pub/  96. http://www.bugfactory.org/~gav/ipv6/  97. http://project6.ferrara.linux.it/  98. ftp://ftp.ferrara.linux.it/pub/project6/  99. http://www.pld.org.pl/ 100. http://www.redhat.com/ 101. http://www.netcore.fi/pekkas/linux/ipv6/ 102. http://www.debian.org/ 103. http://people.debian.org/~csmall/ipv6/ 104. http://www.suse.com/ 105. http://www.linux-mandrake.com/
分类: BSD/linux 标签: ,

Linux IPv6 HOWTO (3)

2008年9月13日 16hot 没有评论
  conf/default/*

   Change the interface-specific default settings

  conf/all/*

   改變所有 interface-specific 設定.

   除了: "conf/all/forwarding" 它有不同的含義.

  conf/all/forwarding

     * Type: BOOLEAN

   在兩個界面之間進行global IPv6 forwarding (數據包轉寄.)

   IPv6 當中您不能單獨控制一個設備的 forwarding (數據包轉寄). forwarding   的控制由IPv6-netfilter 完成. 當值為"0"時 數據包轉寄的能力被關閉,數據包   不會離開各自的界面(包括物理/虛擬)比如 tunnel. 當值為"1"時 數據包轉寄的   能力被開啟.

  conf/interface/*

   改變單個界面的設定. 依據local forwarding 是 enabled 或 not.

  accept_ra

     * Type: BOOLEAN     * 默認值: enabled if local forwarding is disabled. disabled if local       forwarding is enabled.

   接受IPv6路由廣告.並且根據得到的信息自動設定.

  accept_redirectsc

     * Type: BOOLEAN     * Functional default: enabled if local forwarding is disabled.       disabled if local forwarding is enabled.

   接受IPv6路由器的重定向.

  autoconf

     * Type: BOOLEAN     * Default: TRUE

   設定本地連結地址使用L2硬體地址. 它依據界面的L2-MAC address自動產生一個   地址如:"fe80::201:23ff:fe45:6789"

  dad_transmits

     * Type: INTEGER     * Default: 1

   發送重複地址嗅探的總數.

  forwarding

     * Type: BOOLEAN     * Default: FALSE if global forwarding is disabled (default),       otherwise TRUE

   設定主機/路由的interface-specific動作.

   注意:推薦所有interface(界面)使用相同的設定.混合路由器/主機的想法真是難   得.     * Value FALSE: By default, Host behaviour is assumed. This means:          + IsRouter 標緻沒有在Neighbour Advertisements當中.          + 當需要的時候就發送路由請求.          + 如果accept_ra是TRUE (default), 接受路由廣告.          + 如果accept_redirects 是 TRUE (default), 接受重定向.     * Value TRUE: 如果具備本地forwarding(轉寄),路由器動作為假定.這和上面       的情況相反:          + IsRouter 標緻存在於Neighbour Advertisements當中.          + 不發送路由請求.          + 忽略路由廣告.          + 忽略重定向.

  hop_limit

     * Type: INTEGER     * Default: 64

   缺省hop限制.

  mtu

     * Type: INTEGER     * Default: 1280 (IPv6 要求的最小值)

   缺省最大傳輸單元.

  router_solicitation_delay

     * Type: INTEGER     * Default: 1

   在發送路由請求之前界面的等待時間(秒).

  router_solicitation_interval

     * Type: INTEGER     * Default: 4

   在每個路由請求之間的等待時間(秒).

  router_solicitations

     * Type: INTEGER     * Default: 3

   假定沒有路由的情況下發送的請求個數.

  neigh/default/*

   Change default settings for neighbor detection and some special global   interval and threshold values:

  gc_thresh1

     * Type: INTEGER     * Default: 128

   More to be filled.

  gc_thresh2

     * Type: INTEGER     * Default: 512

   More to be filled.

  gc_thresh3

     * Type: INTEGER     * Default: 1024

   芳鄰列印表大小的調節項.

   如果您有許多界面,或路由表現反常 試著增大數值. Or if a running Zebra   (routing daemon) reports:       ______________________________________________________________

ZEBRA: netlink-listen error: No buffer space available, type=RTM_NEWROUTE(24),seq=426, pid=0       ______________________________________________________________

  gc_interval

     * Type: INTEGER     * Default: 30

   More to be filled.

  neigh/interface/*

   Change special settings per interface for neighbor detection.

  anycast_delay

     * Type: INTEGER     * Default: 100

   More to be filled.

  gc_stale_time

     * Type: INTEGER     * Default: 60

   More to be filled.

  proxy_qlen

     * Type: INTEGER     * Default: 64

   More to be filled.

  unres_qlen

     * Type: INTEGER     * Default: 3

   More to be filled.

  app_solicit

     * Type: INTEGER     * Default: 0

   More to be filled.

  locktime

     * Type: INTEGER     * Default: 0

   More to be filled.

  retrans_time

     * Type: INTEGER     * Default: 100

   More to be filled.

  base_reachable_time

     * Type: INTEGER     * Default: 30

   More to be filled.

  mcast_solicit

     * Type: INTEGER     * Default: 3

   More to be filled.

  ucast_solicit

     * Type: INTEGER     * Default: 3

   More to be filled.

  delay_first_probe_time

     * Type: INTEGER     * Default: 5

   More to be filled.

  proxy_delay

     * Type: INTEGER     * Default: 80

   More to be filled.

  route/*

   設定global(全局)路由

  flush

   Removed in newer kernel releases - more to be filled.

  gc_interval

     * Type: INTEGER     * Default: 30

   More to be filled.

  gc_thresh

     * Type: INTEGER     * Default: 1024

   More to be filled.

  mtu_expires

     * Type: INTEGER     * Default: 600

   More to be filled.

  gc_elasticity

     * Type: INTEGER     * Default: 0

   More to be filled.

  gc_min_interval

     * Type: INTEGER     * Default: 5

   More to be filled.

  gc_timeout

     * Type: INTEGER     * Default: 60

   More to be filled.

  min_adv_mss

     * Type: INTEGER     * Default: 12

   More to be filled.

  max_size

     * Type: INTEGER     * Default: 4096

   More to be filled.

11.4 IPv6-related entries in /proc/sys/net/ipv4/

   目前(直到IPv4全部成為核心模組),一些開關也可以為IPv6所使用.

  ip_*

  ip_local_port_range

   也可以為IPv6使用.

  tcp_*

   也可以為IPv6使用.

  ICMP_*

   不能為IPv6使用. 激活 ICMPv6 比率限制 rate limting (極力推薦,因為它有抵   禦 ICMPv6 網路風暴的能力) netfilter-v6 rules must be used.

  其它

   不知道, 不能為IPv6使用吧.

11.5 IPv6-related entries in /proc/net/

   這個地方是只讀的, 您不能通過 "sysctl" 得到資訊,可以使用 "cat"

  if_inet6

   每一行地址包含多個值.

   這裡IPv6地址是用特殊的格式列印的,例子只列印環繞interface(界面)含義在下   面       ______________________________________________________________

# cat /proc/net/if_inet600000000000000000000000000000001 01 80 10 80 lo+------------------------------+ ++ ++ ++ ++ ++|                                |  |  |  |  |1                                2  3  4  5  6       ______________________________________________________________

   1. 地址用32個不包含":"的十六進制列印.

   2. 連結的設備數值(interface index)使用十六進制列印.

   3. 前綴的長度使用十六進制列印.

   4. Scope value (see kernel source " include/net/ipv6.h" and   "net/ipv6/addrconf.c" for more)

   5. Interface flags (see "include/linux/rtnetlink.h" and   "net/ipv6/addrconf.c" for more)

   6. 設備名.

  ipv6_route

   每一行地址包含多個值.

   這裡IPv6地址是用特殊的格式列印的,例子只列印環繞interface(界面)含義在下   面       ______________________________________________________________

# cat /proc/net/ipv6_route00000000000000000000000000000000 00 00000000000000000000000000000000 00+------------------------------+ ++ +------------------------------+ ++|                                |  |                                |1                                2  3                                4? 00000000000000000000000000000000 ffffffff 00000001 00000001 00200200 lo? +------------------------------+ +------+ +------+ +------+ +------+ ++? |                                |        |        |        |        |? 5                                6        7        8        9        10       ______________________________________________________________

   1. IPv6目標網路用32個不包含":"的十六進制列印.

   2. IPv6prefix(前綴)的長度使用十六進制列印.

   3. IPv6來源網路用32個不包含":"的十六進制列印.

   4. IPv6來源prefix(前綴)的長度使用十六進制列印.

   5. IPv6下一個hop(躍點)用32個不包含":"的十六進制列印.

   6. Metric in hexadecimal

   7. Reference counter

   8. Use counter

   9. Flags(標緻)

   10.Device name

  sockstat6

   每一行地址包含多個值.

   IPv6 sockets統計:       ______________________________________________________________

# cat /proc/net/sockstat6TCP6: inuse 7UDP6: inuse 2RAW6: inuse 1FRAG6: inuse 0 memory 0       ______________________________________________________________

 tcp6To be filled.

 udp6To be filled.

 igmp6To be filled.

 raw6To be filled.

 ip6_flowlabelTo be filled.

 rt6_statsTo be filled.

 snmp6

Type: One line per SNMP description and value

SNMP statistics, can be retrieved via SNMP server and related MIB table by network management software.

 ip6_tables_namesAvailable netfilter6 tables

12. Netlink-Interface to kernel

   內容有待增加... 這方面我沒什麼經驗...

13. 網路 debugging

13.1 Server socket binding(綁定)

13.2 Using "netstat" for server socket binding check

   使用 "netstat" 是得到這些信息的捷徑.

   使用選項: -nlptu

   例子:       ______________________________________________________________

# netstat -nlptuActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         State? PID/Program nametcp        0      0 0.0.0.0:32768           0.0.0.0:*               LISTEN? 1258/rpc.statdtcp        0      0 0.0.0.0:32769           0.0.0.0:*               LISTEN? 1502/rpc.mountdtcp        0      0 0.0.0.0:515             0.0.0.0:*               LISTEN? 22433/lpd Waitingtcp        0      0 1.2.3.1:139             0.0.0.0:*               LISTEN? 1746/smbdtcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN? 1230/portmaptcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN? 3551/Xtcp        0      0 1.2.3.1:8081            0.0.0.0:*               LISTEN? 18735/junkbustertcp        0      0 1.2.3.1:3128            0.0.0.0:*               LISTEN? 18822/(squid)tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN? 30734/namedtcp        0      0 ::ffff:1.2.3.1:993      :::*                    LISTEN? 6742/xinetd-ipv6tcp        0      0 :::13                   :::*                    LISTEN? 6742/xinetd-ipv6tcp        0      0 ::ffff:1.2.3.1:143      :::*                    LISTEN? 6742/xinetd-ipv6tcp        0      0 :::53                   :::*                    LISTEN? 30734/namedtcp        0      0 :::22                   :::*                    LISTEN? 1410/sshdtcp        0      0 :::6010                 :::*                    LISTEN? 13237/sshdudp        0      0 0.0.0.0:32768           0.0.0.0:*? 1258/rpc.statdudp        0      0 0.0.0.0:2049            0.0.0.0:*? -udp        0      0 0.0.0.0:32770           0.0.0.0:*? 1502/rpc.mountdudp        0      0 0.0.0.0:32771           0.0.0.0:*? -udp        0      0 1.2.3.1:137             0.0.0.0:*? 1751/nmbdudp        0      0 0.0.0.0:137             0.0.0.0:*? 1751/nmbdudp        0      0 1.2.3.1:138             0.0.0.0:*? 1751/nmbdudp        0      0 0.0.0.0:138             0.0.0.0:*? 1751/nmbdudp        0      0 0.0.0.0:33044           0.0.0.0:*? 30734/namedudp        0      0 1.2.3.1:53              0.0.0.0:*? 30734/namedudp        0      0 127.0.0.1:53            0.0.0.0:*? 30734/namedudp        0      0 0.0.0.0:67              0.0.0.0:*? 1530/dhcpdudp        0      0 0.0.0.0:67              0.0.0.0:*? 1530/dhcpdudp        0      0 0.0.0.0:32858           0.0.0.0:*? 18822/(squid)udp        0      0 0.0.0.0:4827            0.0.0.0:*? 18822/(squid)udp        0      0 0.0.0.0:111             0.0.0.0:*? 1230/portmapudp        0      0 :::53                   :::*? 30734/named       ______________________________________________________________

13.3 Examples for tcpdump packet dumps

   下面是一些被捕獲的數據包 ...下一次我會多弄一點來...:

  Router discovery(路由發現)

   Router advertisement       ______________________________________________________________

15:43:49.484751 fe80::212:34ff:fe12:3450 > ff02::1: icmp6: router? advertisement(chlim=64, router_ltime=30, reachable_time=0,? retrans_time=0)(prefix info: AR valid_ltime=30, preffered_ltime=20,? prefix=2002:0102:0304:1::/64)(prefix info: LAR valid_ltime=2592000,? preffered_ltime=604800, prefix=3ffe:ffff:0:1::/64)(src lladdr:? 0:12:34:12:34:50) (len 88, hlim 255)       ______________________________________________________________

   路由器使用link-local 地址 "fe80::212:34ff:fe12:3450" 發送廣告至   all-node-on-link multicast address "ff02::1"   在它自己的 layer 2 MAC 地址 "0:12:34:12:34:50"中,   包含兩個前綴2002:0102:0304:1::/64" (lifetime 30 s) 和   "3ffe:ffff:0:1::/64" (lifetime 2592000 s)

  Router solicitation(路由請求)       ______________________________________________________________

15:44:21.152646 fe80::212:34ff:fe12:3456 > ff02::2: icmp6: router solicitation? (src lladdr: 0:12:34:12:34:56) (len 16, hlim 255)       ______________________________________________________________

   擁有link-local地址 "fe80::212:34ff:fe12:3456" 和 layer 2 MAC 地址   "0:12:34:12:34:56"的節點尋找在線的 路由器. 所以發送一個路由請求到所有   在線的路由器地址multicast address "ff02::2"

  Neighbor discovery(發現芳鄰)

  Neighbor discovery solicitation for duplicate address detection(對網路芳鄰當  中 "重複的地址" 進行檢查)

   隨著數據包從layer 2 MAC 地址 "0:12:34:12:34:56" 發送出去的同時檢查是否   有節點用相同的地址發送數據包. Following packets are sent by a node   with layer 2 MAC address "0:12:34:12:34:56" during autoconfiguration   to check whether a potential address is already used by another node   on the link sending this to the solicited-node link-local multicast   address

     * 當節點將使用地址"fe80::212:34ff:fe12:3456"作為本地連結時檢查重複的       地址.       ______________________________________________________________

                       15:44:17.712338 :: > ff02::1:ff12:3456: icmp6: neighborsol: who has                       ? fe80::212:34ff:fe12:3456(src lladdr: 0:12:34:12:34:56) (len 32, hlim 255)       ______________________________________________________________

     * 當節點將使用地址"2002:0102:0304:1:212:34ff:fe12:3456"作為global(全       局)連結時檢查重複的地址(得到上面的廣告之後).       ______________________________________________________________

                      15:44:21.905596 :: > ff02::1:ff12:3456: icmp6: neighbor sol: who has                      ? 2002:0102:0304:1:212:34ff:fe12:3456(src lladdr: 0:12:34:12:34:56) (len 32,                      ? hlim 255)       ______________________________________________________________

     * 當節點將使用地址"3ffe:ffff:0:1:212:34ff:fe12:3456" 作為global(全       局)連結時檢查重複的地址(得到上面的廣告之後).       ______________________________________________________________

                      15:44:22.304028 :: > ff02::1:ff12:3456: icmp6: neighbor sol: who has                      ? 3ffe:ffff:0:1:212:34ff:fe12:3456(src lladdr: 0:12:34:12:34:56) (len 32, hlim                      ? 255)       ______________________________________________________________

  Neighbor discovery solicitation for looking for host or gateway(查找一台主機  或閘道)

     * 節點想要發送數據包至"3ffe:ffff:0:1::10",但是沒有layer 2 MAC 的發送       地址,於是發送請求.       ______________________________________________________________

                      13:07:47.664538 2002:0102:0304:1:2e0:18ff:fe90:9205 > ff02::1:ff00:10: icmp6:                      ? neighbor sol: who has 3ffe:ffff:0:1::10(src lladdr: 0:e0:18:90:92:5) (len 32,                      ? hlim 255)       ______________________________________________________________

     * 節點現在查找"fe80::10"       ______________________________________________________________

                       13:11:20.870070 fe80::2e0:18ff:fe90:9205 > ff02::1:ff00:10: icmp6: neighbor                       ? sol: who has fe80::10(src lladdr: 0:e0:18:90:92:5) (len 32, hlim 255)       ______________________________________________________________

14. Support for persistent IPv6 configuration in Linux distributions(在不同的發行版中設定IPv6)
分类: BSD/linux 标签: ,

Linux IPv6 HOWTO (2)

2008年9月13日 16hot 1 条评论
# /sbin/route -A inet6       ______________________________________________________________

   例子:在同一個界面上不同的IPv6路由.       ______________________________________________________________

# /sbin/ip -6 route show dev eth0# /sbin/route -A inet6 |grep -w "eth0"3ffe:ffff:0:f101 ::/64 :: UA  256 0 0 eth0 <- Interface route for global? addressfe80::/10        ::       UA  256 0 0 eth0 <- Interface route for link-local? addressff00::/8         ::       UA  256 0 0 eth0 <- Interface route for all multicast? addresses::/0             ::       UDA 256 0 0 eth0 <- Automatic default route       ______________________________________________________________

7.2 設定IPv6路由通過閘道

  使用"ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 route add <ipv6network>/<prefixlength> via <ipv6address>? [dev <device>]       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 route add 2000::/3 via 3ffe:ffff:0:f101::1       ______________________________________________________________

  使用 "route"

   使用方法:       ______________________________________________________________

# /sbin/route -A inet6 add <ipv6network>/<prefixlength> gw? <ipv6address> [dev <device>]       ______________________________________________________________

   例子:為當前所有的(全局地址global addresses 2000::/3)址通過閘   道3ffe:ffff:0:f101::1       ______________________________________________________________

# /sbin/route -A inet6 add 2000::/3 gw 3ffe:ffff:0:f101::1       ______________________________________________________________

7.3 移除 IPv6路由通過閘道

  使用"ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 route del <ipv6network>/<prefixlength> via <ipv6address>? [dev <device>]       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 route del 2000::/3 via 3ffe:ffff:0:f101::1       ______________________________________________________________

  使用 "route"

   使用方法:       ______________________________________________________________

# /sbin/route -A inet6 del <network>/<prefixlength> [dev <device>]       ______________________________________________________________

   例子:移除前所有的(全局地址global addresses 2000::/3)址通過閘   道3ffe:ffff:0:f101::1       ______________________________________________________________

# /sbin/route -A inet6 del 2000::/3 gw 3ffe:ffff:0:f101::1       ______________________________________________________________

7.4 增加IPv6路由至interface(界面)

  使用 "ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 route add <ipv6network>/<prefixlength> dev <device>? metric 1       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 route add 2000::/3 dev eth0 metric 1       ______________________________________________________________

  使用 "route"

   使用方法:       ______________________________________________________________

# /sbin/route -A inet6 add <network>/<prefixlength> dev <device>       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/route -A inet6 add 2000::/3 dev eth0       ______________________________________________________________

7.5 從interface(界面)移除IPv6路由

  使用 "ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 route del <ipv6network>/<prefixlength> dev <device>? metric 1       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 route del 2000::/3 dev eth0       ______________________________________________________________

  使用 "route"

   使用方法:       ______________________________________________________________

# /sbin/route -A inet6 del <network>/<prefixlength> dev <device>       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/route -A inet6 del 2000::/3 dev eth0       ______________________________________________________________

7.6 FAQ for IPv6 routes(IPv6 路由的經常問答)

  Support of an IPv6 default route

   IPv6的一個方法是hierachical routing(分級路由).因此,分級當中最少需要一   個路由.

   在目前的核心中有一些問題:

  Clients (not routing any packet!)沒有任何數據包被路由.

   Clinets 可以設定一個缺省的prefix "::/0"(前綴為 ::/0 的路由).       ______________________________________________________________

# ip -6 route show | grep ^defaultdefault via fe80::212:34ff:fe12:3450 dev eth0 proto kernel metric 1024 expires? 29sec mtu 1500 advmss 1440       ______________________________________________________________

  Routers on packet forwarding (路由包轉寄)

   目前主流的Linux核心(最少是 <=2.4.17) 不支持缺省路由. 您可以設定它們,但   在發送數據包時環繞會失敗. 所以,目前的缺省路由可以被設定成 前綴   為"2000::/3"的 global (全局地址). USAGI 對這個有著良好的支持.

   注意: 注意沒有地址篩選的邊緣路由器的缺省路由, 不然會有多餘的multicast   或 site-local 傳輸從邊緣溢出.

8. Neighbor Discovery(發現芳鄰)

   IPv6 的 Neighbor Discovery繼承了IPv4 的 ARP (Address Resolution   Protocol地址解析協議). 您可以重新得到芳鄰的資訊. 並且可以編輯/刪除它.

   Neighbor detection(對芳鄰進行探測)

   核心負責對探測成功的芳鄰進行追蹤. 您可以用 "ip" 來挖掘其中的信息.

8.1 Displaying neighbors using "ip" (用"ip"命令列印芳鄰)

   使用以下的命令,您可以知道芳鄰的設定.       ______________________________________________________________

# ip -6 neigh show [dev <device>]       ______________________________________________________________

   下面的例子當中列印了一個芳鄰,它是一個可到達的路由器.       ______________________________________________________________

# ip -6 neigh showfe80::201:23ff:fe45:6789 dev eth0 lladdr 00:01:23:45:67:89 router nud reachable       ______________________________________________________________

8.2 用 "ip" 對芳鄰的列印表進行處理

  用以下的命令可以加入一個entry(列印項)       ______________________________________________________________

# ip -6 neigh add <IPv6 address> lladdr <link-layer address> dev <device>       ______________________________________________________________

   例子:       ______________________________________________________________

# ip -6 neigh add fec0::1 lladdr 02:01:02:03:04:05 dev eth0       ______________________________________________________________

  用以下的命令可以移除一個entry(列印項)       ______________________________________________________________

# ip -6 neigh del <IPv6 address> lladdr <link-layer address> dev <device>       ______________________________________________________________

   例子:       ______________________________________________________________

# ip -6 neigh del fec0::1 lladdr 02:01:02:03:04:05 dev eth0       ______________________________________________________________

  更高階的設定

   "ip"工具非常強大, 但沒有足夠的幫助資訊.       ______________________________________________________________

# ip -6 neigh helpUsage: ip neigh { add | del | change | replace } { ADDR [ lladdr LLADDR ]          [ nud { permanent | noarp | stale | reachable } ]          | proxy ADDR } [ dev DEV ]       ip neigh {show|flush} [ to PREFIX ] [ dev DEV ] [ nud STATE ]       ______________________________________________________________

   有點像IPv4的列印, 如果您知道它的詳細用法,請幫我 send 一份過來.

9. Configuring IPv6-in-IPv4 tunnels(設定遂道)

9.1 遂道的類型

   將IPv6數據包傳輸到IPv4連結不只有一種可能.

  Static point-to-point tunneling: 6bone (以點對點方式構建的遂道)

   IPv6和IPv4的遂道定義在 [27]RFC 2893 / Transition Mechanisms for IPv6   Hosts and Routers

   必備條件:     * 遂道另一端的IPv4地址必需是static(靜態的).global unique and       reachable from the foreign tunnel endpoint     * 您以經擁有的一個global IPv6 prefix(前綴),參照 6bone registry.     * 有一個可以將您的IPv6 prefix 路由到本地端的外界tunnel端(通常需要進       行遠端操作)

  Automatically tunneling(遂道操作自動化)

   當一個節點直接同另一個節點進行連結,在得到節點IPv4地址之前,節點就會執行   遂道操作自動化.

  6to4-Tunneling(遂道操作)

   它使用一個簡單的機制實行Tunneling(遂道操作) [28]RFC 3056 / Connection   of IPv6 Domains via IPv4 Clouds. 每個節點的global unique IPv4 (唯一全   局地址)可以成為 6to4 tunnel 的終點(如果沒有IPv4防火牆限制通訊).   6to4-Tunneling(遂道操作)不是專用於一對一的遂道, 這個案例可以分開針   對upstream and downstream (上級和下級)的遂道操作. 同樣,一個特別的IPv6   地址會指出這個節點使用6to4-Tunnel同全世界的 IPv6 網路進行連結.

  Generation of 6to4 prefix(產生6to4的前綴).

   6to4 的地址像下面這樣定義:(源自 [29]RFC 3056 / Connection of IPv6   Domains via IPv4 Clouds)       ______________________________________________________________

__________________________________________________________________|   3+13   |    32     |    16  |            64 bits             |+---+------+-----------+--------+--------------------------------+|  FP+TLA  |  V4ADDR   | SLA ID |           Interface ID         ||  0x2002  |           |        |                                |+---+------+-----------+--------+--------------------------------+       ______________________________________________________________

   FP是global addresses(全局地址)的前綴. TLA是top level aggregator(最高層   集) V4ADDR是IPv4全局唯一地址((in hexadecimal notation). SLA是子網路標   緻(65536 local subnets possible). 這些前綴產生時的SLA 為"0000" 後綴是   "::1" 並分配到6to4 tunnel interface(界面).

  6to4 upstream tunneling(上級遂道操作)

   節點知道向哪裡發送含有IPv6數據包的IPv4數據包. 早期的6to4遂道,必需設定   一個專用的上級路由器接受這種操作. 參照 [30]NSayer's 6to4 information    裡的路由列印. 現在 6to4上級路由器可以使用anycast address 192.88.99.1   它由後台的路由協議控制. 參照 [31]RFC 3068 / An Anycast Prefix for 6to4   Relay Routers

  6to4 downstream tunneling(下級遂道操作)

   The downstream (6bone -> your 6to4 enabled node) is not really fix and   can vary from foreign host which originated packets were send to.   There exist two possibilities: 它還沒有正式修正對數據包來源的確定, 存   在以下兩種可能:     * 外部主機直接使用6to4把IPv6數據包發回給您.     * 外部主機通過全球IPv6網路, 依靠動態路建立一個automatic tunnel 由       將IPv6數據包發回給您.

  Possible 6to4 traffic(6to4的幾種通訊方法)

     * 從 6to4 到 6to4: 通常在兩個 6to4 enabled 主機之間直接進行遂道操作       tunneled between the     * 從 6to4 到 non-6to4: 通過上級遂道操作發送數據包.     * 從 non-6to4 到 6to4: 通過下級遂道操作發送數據包.

9.2 列印現存的tunnels(遂道)

  使用 "ip"

   用法:       ______________________________________________________________

# /sbin/ip -6 tunnel show [<device>]       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 tunnel showsit0: ipv6/ip remote any local any ttl 64 nopmtudiscsit1: ipv6/ip remote 195.226.187.50 local any ttl 64       ______________________________________________________________

  使用 "route"

   用法:       ______________________________________________________________

# /sbin/route -A inet6       ______________________________________________________________

   例子:只列印從sit0界面通過的遂道.       ______________________________________________________________

# /sbin/route -A inet6 | grep "Wsit0W*$"::/96      ::               U   256  2  0  sit02002::/16  ::               UA  256  0  0  sit02000::/3   ::193.113.58.75  UG    1  0  0  sit0fe80::/10  ::               UA  256  0  0  sit0ff00::/8   ::               UA  256  0  0  sit0       ______________________________________________________________

9.3 Setup of point-to-point tunnel(設定點對點的遂道)

   有3種方法可以加入/移除point-to-point tunnel

  Add point-to-point tunnels (加入)

  使用 "ip"

   目前針對少量tunnels的方法

   設定tunnel device (它不會立既啟用.TTL必需指定, 因為初始值是0)       ______________________________________________________________

# /sbin/ip tunnel add < device > mode sit ttl < ttldefault > remote? < ipv4addressofforeigntunnel > local < ipv4addresslocal >       ______________________________________________________________

   用法(這個例子中有三個遂道)       ______________________________________________________________

# /sbin/ip tunnel add sit1 mode sit ttl <ttldefault> remote? <ipv4addressofforeigntunnel1> local <ipv4addresslocal># /sbin/ip set dev sit1 up# /sbin/ip -6 route add <prefixtoroute1> dev sit1 metric 1# /sbin/ip tunnel add sit2 mode sit ttl <ttldefault>? <ipv4addressofforeigntunnel2> local <ipv4addresslocal># /sbin/ip set dev sit2 up# /sbin/ip -6 route add <prefixtoroute2> dev sit2 metric 1# /sbin/ip tunnel add sit3 mode sit ttl <ttldefault>? <ipv4addressofforeigntunnel3> local <ipv4addresslocal># /sbin/ip set dev sit3 up# /sbin/ip -6 route add <prefixtoroute3> dev sit3 metric 1       ______________________________________________________________

  使用 "ifconfig" and "route" (deprecated)

   不推薦一次就 Non Broadcast Multiple Access (NBMA)這麼多,因為您如果只想   關閉第一個但又要讓其它的繼續運行,有點難啊.只加一個是沒有問題的.       ______________________________________________________________

# /sbin/ifconfig sit0 up# /sbin/ifconfig sit0 tunnel <ipv4addressofforeigntunnel1># /sbin/ifconfig sit1 up# /sbin/route -A inet6 add <prefixtoroute1> dev sit1# /sbin/ifconfig sit0 tunnel <ipv4addressofforeigntunnel2># /sbin/ifconfig sit2 up# /sbin/route -A inet6 add <prefixtoroute2> dev sit2# /sbin/ifconfig sit0 tunnel <ipv4addressofforeigntunnel3># /sbin/ifconfig sit3 up# /sbin/route -A inet6 add <prefixtoroute3> dev sit3       ______________________________________________________________

   警告:這樣做有很大的風險, 因為任何人可以從Internet的任何地點使   用"automatic tunneling"同您進行連結.我不推薦您這樣做.

  使用 "route" only

   當然可以設定tunnel使用 Non Broadcast Multiple Access (NBMA)非多地址廣   播的方式 這種方法可以一次就加入很多tunnel. 使用方法 (三個tunnel的基本   例子):       ______________________________________________________________

# /sbin/ifconfig sit0 up# /sbin/route -A inet6 add <prefixtoroute1> gw? ::<ipv4addressofforeigntunnel1> dev sit0# /sbin/route -A inet6 add <prefixtoroute2> gw? ::<ipv4addressofforeigntunnel2> dev sit0# /sbin/route -A inet6 add <prefixtoroute3> gw? ::<ipv4addressofforeigntunnel3> dev sit0       ______________________________________________________________

   警告:這樣做有很大的風險, 因為任何人可以從Internet的任何地點使   用"automatic tunneling"同您進行連結.我不推薦您這樣做.

  Removing point-to-point tunnels(移除遂道)

   手工方式不經常使用,可以用scripts移除/重新設定IPv6tunnels

  使用 "ip"

   移除遂道設備的用法:       ______________________________________________________________

# /sbin/ip tunnel del <device>       ______________________________________________________________

   Usage (三個tunnel的基本例子):       ______________________________________________________________

# /sbin/ip -6 route del <prefixtoroute1> dev sit1# /sbin/ip set sit1 down# /sbin/ip tunnel del sit1# /sbin/ip -6 route del <prefixtoroute2> dev sit2# /sbin/ip set sit2 down# /sbin/ip tunnel del sit2# /sbin/ip -6 route del <prefixtoroute3> dev sit3# /sbin/ip set sit3 down# /sbin/ip tunnel del sit3       ______________________________________________________________

  使用 "ifconfig" and "route" (因為不怎麼有趣所以不贊成這麼做)

   Usage (三個tunnel的基本例子):您必需反向移除它們, 也就是先建立的必需先   移除.       ______________________________________________________________

# /sbin/route -A inet6 del <prefixtoroute3> dev sit3# /sbin/ifconfig sit3 down# /sbin/route -A inet6 del <prefixtoroute2> dev sit2# /sbin/ifconfig sit2 down# /sbin/route -A inet6 add <prefixtoroute1> dev sit1# /sbin/ifconfig sit1 down# /sbin/ifconfig sit0 down       ______________________________________________________________

  使用 "route"

   移除IPv6路由. 使用方法 (三個tunnel的基本例子):       ______________________________________________________________

# /sbin/route -A inet6 del <prefixtoroute1> gw? ::<ipv4addressofforeigntunnel1> dev sit0# /sbin/route -A inet6 del <prefixtoroute2> gw? ::<ipv4addressofforeigntunnel2> dev sit0# /sbin/route -A inet6 del <prefixtoroute3> gw? ::<ipv4addressofforeigntunnel3> dev sit0# /sbin/ifconfig sit0 down       ______________________________________________________________

  Numbered point-to-point tunnels(有限的點對點遂道)

   有時需要設定一個point-to-point 遂道 和IPv6地址, 但方法中只有第一   個(ifconfig+route - deprecated)和第三個(ip+route)可行. 在這些案例中您   可以加入一個IPv6地址到 tunnel interface(用於遂道操作的那個界面)

9.4 Setup of 6to4 tunnels (設定 IPv6至IPv4的遂道)

   注意:6to4 tunnels 目前缺乏vanilla 2.2.x系列核心的支持. 同樣要注意的   是6to4地址的前綴長度是16 所有的 6to4 主機都在相同的第二層.

  Add a 6to4 tunnel(增加一個 6to4 遂道)

   首先, 您必需用可路由的本地IPv4 global 地址來計算 6to4 的前綴. (如果您   的主機沒有可路由的本地IPv4 global 地址, 在閘道邊緣的NAT地址也行 in   special cases NAT on border gateways is possible):

   假定您的IPv4地址為:       ______________________________________________________________

1.2.3.4       ______________________________________________________________

   產生的6to4 prefix(前綴)為 :       ______________________________________________________________

2002:0102:0304::       ______________________________________________________________

   本地的 6to4 閘道需要手工設定後綴為"::1", 因此您的6to4地址就成為:       ______________________________________________________________

2002:0102:0304::1       ______________________________________________________________

   以下依據指定的IPv4地址產生6to4地址:       ______________________________________________________________

ipv4="1.2.3.4"; printf "2002:%02x%02x:%02x%02x::1" `echo $ipv4 | tr "." " "`       ______________________________________________________________

   目前有兩種方法可以設定6to4遂道

  使用 "ip" 和專用的遂道設備.

   這是被推薦的做法. 創建一個遂道設備.       ______________________________________________________________

# /sbin/ip tunnel add tun6to4 mode sit remote any local <localipv4address>       ______________________________________________________________

   Bring interface up(激活它)       ______________________________________________________________

# /sbin/ip link set dev tun6to4 up       ______________________________________________________________

   將本地6to4地址加入到界面.(注意:它的前綴長度必需是16)       ______________________________________________________________

# /sbin/ip -6 addr add <local6to4address>/16 dev tun6to4       ______________________________________________________________

   加入一個用all-6to4-routers IPv4 anycast 地址作為到達global IPv6 網路的   路由(缺省的路由)       ______________________________________________________________

# /sbin/ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4 metric 1       ______________________________________________________________

  使用 "ifconfig" and "route" and generic tunnel device "sit0" (不被推薦的做法)

   不被推薦是因為tunnel device sit0 不支持特別的過慮器應用在每個設備上.

   Bring generic tunnel interface sit0 up(將界面sit0激活)       ______________________________________________________________

# /sbin/ifconfig sit0 up       ______________________________________________________________

   Add local 6to4 address to interface(向界面添加本地 6to4 地址)       ______________________________________________________________

# /sbin/ifconfig sit0 add <local6to4address>/16       ______________________________________________________________

   加入一個用all-6to4-relays IPv4 anycast地址作為到達global IPv6 網路的路   由(缺省的路由)       ______________________________________________________________

# /sbin/route -A inet6 add 2000::/3 gw ::192.88.99.1 dev sit0       ______________________________________________________________

  Remove a 6to4 tunnel(移除 6to4 遂道)

  使用 "ip" and a 專用遂道設備

   從dedicated tunnel device 移除所有路由       ______________________________________________________________

# /sbin/ip -6 route flush dev tun6to4       ______________________________________________________________

   Shut down interface(關閉界面)       ______________________________________________________________

# /sbin/ip link set dev tun6to4 down       ______________________________________________________________

   Remove created tunnel device(移除遂道設備)       ______________________________________________________________

# /sbin/ip tunnel del tun6to4       ______________________________________________________________

  使用 "ifconfig" and "route" and generic tunnel device "sit0" (不被推薦的做法)

   移除 6to4 界面上遂道的路由       ______________________________________________________________

# /sbin/route -A inet6 del 2000::/3 gw ::192.88.99.1 dev sit0       ______________________________________________________________

   Remove local 6to4 address to interface(從界面移除本地 6to4 地址)       ______________________________________________________________

# /sbin/ifconfig sit0 del <local6to4address>/16       ______________________________________________________________

   並閉 generic tunnel device (當心, 可能它還在使用當中)       ______________________________________________________________

# /sbin/ifconfig sit0 down       ______________________________________________________________

10. 設定 IPv4-in-IPv6 遂道

   這裡的內容會在將來添加,目前這種遂道處在試驗階段.參照: [32]RFC 2473 /   Generic Packet Tunneling in IPv6 Specification

11. 核心設定 in /proc-filesystem

11.1 怎樣進入 /proc-filesystem

  使用 "cat"和 "echo"

   使用 "cat"和 "echo" 是進入 /proc-filesystem的最簡單方法. 但必需具備下   面幾個條件:

     * 在核心中打開 /proc-filesystem 支持, 在編譯的時候可以通過       CONFIG_PROC_FS=y 做到.     * /proc-filesystem 已經掛進系統,可以用以下的方法測試:       ______________________________________________________________

# mount | grep "type proc"none on /proc type proc (rw)       ______________________________________________________________

     * 您必需知道對/proc-filesystem 的各種操作.

   通常/proc/sys/* 都是可寫的, 其它的都是只讀或只提供相關資訊.

  得到一個值

   可以使用 "cat" 得到一個值.       ______________________________________________________________

# cat /proc/sys/net/ipv6/conf/all/forwarding0       ______________________________________________________________

  設定一個值

   可以使用 "echo" 設定一個值.       ______________________________________________________________

# echo "1" >/proc/sys/net/ipv6/conf/all/forwarding       ______________________________________________________________

  使用 "sysctl"

   使用 "sysctl" 設定核心是當前流行的方法, 您也能用. 如果/proc-filesystem   沒有掛進來, 那麼您只可以訪問/proc/sys/*

   "sysctl"程式在"procps"安裝包中.(Red Hat Linux systems)

   sysctl-interface 需要在核心中進行激活, 在編譯的時候可以通過以下選項完   成:       ______________________________________________________________

CONFIG_SYSCTL=y       ______________________________________________________________

  設定一個值

   A new value can be set (if entry is writable):       ______________________________________________________________

# sysctl -w net.ipv6.conf.all.forwarding=1net.ipv6.conf.all.forwarding = 1       ______________________________________________________________

   在 "=" 兩邊不能出現spaces符號,也不能像下面那樣一次設定多個值:       ______________________________________________________________

# sysctl -w net.ipv4.ip_local_port_range="32768 61000"net.ipv4.ip_local_port_range = 32768 61000       ______________________________________________________________

  另外

   sysctl使用 "/" 代替 "." 詳細資訊請看sysctl的manpage

   提示:快速查找設定的資訊,可以聯合使用帶"-a"的grep.

11.2 /proc-filesystems 裡的數值類型.

     * BOOLEAN: simple a "0" (false) or a "1" (true)     * INTEGER: an integer value, can be unsigned, too     * more sophisticated lines with several values: sometimes a header       line is displayed also, if not, have a look into the kernel source       to retrieve information about the meaning of each value...

11.3 Entries in /proc/sys/net/ipv6/
分类: BSD/linux 标签: ,

Linux IPv6 HOWTO (1)

2008年9月13日 16hot 没有评论
Author:Peter Bieringer pb@bieringer.de譯者: 陳敏劍 expns@yahoo.com

   Revision Release 0.31 2002-09-29 Revised by: PB 翻譯日期: 2002-10-14 ,   2002-11-19 第二次修正     _________________________________________________________________

   Linux IPv6 HOWTO 的目地是回答在 Linux 作業系統上設定IPv6的基本/進階問   題.這份HOWTO為用戶在Linux作業系統上安裝,設定和使用IPv6提供足夠的資訊.     _________________________________________________________________

1. 概述

     * 1.1 版本     * 1.2 版權,許可與其它     * 1.3 關於作者     * 1.4 聯繫     * 1.5 類別     * 1.6 版本, 歷史和打算     * 1.7 歷史     * 1.8 全部歷史     * 1.9 打算     * 1.10 翻譯     * 1.11 德語     * 1.12 其它的語系     * 1.13 波蘭版     * 1.14 中譯版     * 1.15 技術方面     * 1.16 代碼封裝     * 1.17 產生SGML     * 1.18 2HTML版式的在線目錄(linking/anchors)     * 1.19 專用的頁面     * 1.20 有多少個關於 Linux和IPv6 HOWTO的變動版本?     * 1.21 Linux IPv6 FAQ/HOWTO (過時的)     * 1.22 IPv6 & Linux - HowTo (正在維護當中)     * 1.23 Linux IPv6 HOWTO (現在這份HOWTO)     * 1.24 Long code line wrapping signal char     * 1.25 Placeholders (佔位符)     * 1.26 Commands in the shell(shell 裡的命令)     * 1.27 使用這個HOWTO的必需條件

2. 什麼是IPv6?

     * 2.1 IPv6在Linux作業系統上的歷史     * 2.2 開始     * 2.3 其間     * 2.4 現在     * 2.5 將來     * 2.6 IPv6 的地址會是什麼樣 ?     * 2.7 FAQ(基礎)

3. 地址的類型

     * 3.1 沒有前綴的地址     * 3.2 網路部分,也叫做前綴     * 3.3 地址類型(主機)     * 3.4 路由的前綴長度

4. 準備IPv6的運行系統

     * 4.1 IPv6-ready kernel     * 4.2 IPv6-ready 網路設定工具     * 4.3 IPv6-ready 測試/調式 程式     * 4.4 IPv6-ready programs(能和IPv6協同工作的程式)     * 4.5 IPv6-ready 客戶端程式 (selection)     * 4.6 IPv6-ready server 程式

5. 設定interfaces(界面)

     * 5.1 不同的網路設備     * 5.2 Bringing interfaces up/down(設定界面的開/關)

6. 設定IPv6地址

     * 6.1 列印當前的IPv6地址     * 6.2 增加一個IPv6地址     * 6.3 移除IPv6地址

7. 設定IPv6路由

     * 7.1 列印現有的路由     * 7.2 設定IPv6路由通過閘道     * 7.3 移除 IPv6路由通過閘道     * 7.4 增加IPv6路由至interface(界面)     * 7.5 從interface(界面)移除IPv6路由     * 7.6 FAQ for IPv6 routes(IPv6 路由的經常問答)

8. Neighbor Discovery(發現芳鄰)

     * 8.1 Displaying neighbors using "ip" (用"ip"命令列印芳鄰)     * 8.2 用 "ip" 對芳鄰的列印表進行處理

9. Configuring IPv6-in-IPv4 tunnels(設定遂道)

     * 9.1 遂道的類型     * 9.2 列印現存的tunnels(遂道)     * 9.3 Setup of point-to-point tunnel(設定點對點的遂道)     * 9.4 Setup of 6to4 tunnels (設定 IPv6至IPv4的遂道)

10. 設定 IPv4-in-IPv6 遂道

11. 核心設定 in /proc-filesystem

     * 11.1 怎樣進入 /proc-filesystem     * 11.2 /proc-filesystems 裡的數值類型.     * 11.3 Entries in /proc/sys/net/ipv6/     * 11.4 IPv6-related entries in /proc/sys/net/ipv4/     * 11.5 IPv6-related entries in /proc/net/

12. Netlink-Interface to kernel

13. 網路 debugging

     * 13.1 Server socket binding(綁定)     * 13.2 Using "netstat" for server socket binding check     * 13.3 Examples for tcpdump packet dumps

14. Support for persistent IPv6 configuration in Linux distributions(在不同的發行版中設定IPv6)

     * 14.1 Red Hat Linux and "clones"(小紅帽和它的弟兄娣妹)     * 14.2 Mandrake(曼德萊克)Linux      * 14.3 SuSE(蘇澤斯)Linux      * 14.4 Debian(迪比安)Linux

15. 防火牆

     * 15.1 使用 netfilter6防火牆     * 15.2 更多的資訊:     * 15.3 準備     * 15.4 使用方法     * 15.5 使用ip6tables

16. 安全

     * 16.1 Access limitations     * 16.2 IPv6安全審核     * 16.3 Security auditing using IPv6-enabled netcat(使用適應IPv6       的netcat)     * 16.4 Security auditing using IPv6-enabled nmap     * 16.5 Security auditing using IPv6-enabled strobe     * 16.6 審核結果

17. Encryption and Authentication(加密和認證)

     * 17.1 用法

18. 線上測試工具

19. 其它資訊

     * 19.1 線上資訊     * 19.2 更多的資訊     * 19.3 通信論壇

20. 歷史     _________________________________________________________________

1. 概述

1.1 版本

Revision Release 0.31 2002-09-29 Revised by: PBSee revision history for moreRevision Release 0.30 2002-09-27 Revised by: PBSee revision history for moreRevision Release 0.29 2002-09-18 Revised by: PB

1.2 版權,許可與其它

  版權所有: Peter Bieringer

CopyrightWritten and Copyright (C) 2001-2002 by Peter Bieringer

1.1.2. LicenseThis Linux IPv6 HOWTO is published under GNU GPL version 2:

The Linux IPv6 HOWTO, a guide how to configure and use IPv6 on Linux systems.

Copyright (C) 2001-2002 Peter Bieringer

    This documentation is free software; you can redistribute it and/or modifyit  under the terms of the GNU General Public License as published by the Free  Software Foundation; either version 2 of the License, or (at your option)  any later version.

    This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along  with this program; if not, write to the Free Software Foundation, Inc.,  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

1.3 關於作者

作者接觸 Internet/IPv6 的歷史         1993: 由於使用e-mail和新聞組開始接觸Internet.         1996: 受邀於一個IPv6的課程. 包括了Linux有關的IPv6.         1997: 開始寫在Linux裡安裝,設定和使用IPv6的指南.         2001: 開始寫這個新的HOWTO.

1.4 聯繫

   可以通過e-mail pb@bieringer.de及首頁 [1]http://www.bieringer.de/pb/ 他   現在住在Munich [northern part of Schwabing] / Bavaria / Germany   (south) / Europe (middle) / Earth (surface/mainland).

1.5 類別

   在"Networking/Protocols"裡.

1.6 版本, 歷史和打算

   在最上頭提過了.

1.7 歷史

主要的歷史2001-11-30: 開始設定新的HOWTO2002-01-02: 完成了一點,發表了第一章節 (version 0.10).2002-01-14: 完成了更多,加了評論,發表了所有的內容(version 0.14).2002-08-16: 波蘭版的翻譯正在進行.2002-10-14: 中譯版翻譯剛開始.

1.8 全部歷史

   See revision history at the end of this document.

1.9 打算

   補缺漏.完成內容的檢視.

1.10 翻譯

   它們包含URL,版本號,原作的版權.

1.11 德語

   它的版本由我自己完成(德語是我的母語)在版本每月都有變化的時候是不會完成   的. 並且我還要有空閒的時間,如果您有時間,不妨試一試,大大方方地來接管吧.

1.12 其它的語系

   一般情況下,請等到一個月以上無變動的時候進行翻譯, version0.27 是最近的.

1.13 波蘭版

   自從 2002-08-16 Lukasz Jokiel Lukasz.Jokiel@klonex.com.pl開始,到現在.   他的起始版是 0.27

1.14 中譯版

   從 2002-10-14 起, 中譯版的翻譯完成了部份內容, 起始版是 0.31

1.15 技術方面

   HOWTO的原始形式是 在Linux Red Hat7.3里用 LyX version 1.2.0 寫的,格式   是SGML. http://cvsview.tldp.org/index.cgi/LDP/users/Peter-Bieringer/   裡可以取得.

1.16 代碼封裝

   代碼封裝是由自己寫的工具"lyxcodelinewrapper.pl" 來完成. 您可以   在http://cvsview.tldp.org/index.cgi/LDP/users/ 裡取得

1.17 產生SGML

   是用LyX的輸出功能實現. 也有一些是用固定的代碼.(參   照http://cvsview.tldp.org/index.cgi/LDP/users/Peter-Bieringer/) Export   of LyX table does not create proper "colspan" tags - tool for fixing:   "sgmllyxtabletagfix.pl" (fixed since LyX 1.2.0)

   LyX sometimes uses special left/right entities for quotes instead the   normal one, which will still exist in generated HTML. Some browsers   don't parse this very well (known: Opera 6 TP 2 or Konqueror) - tool   for fixing: "sgmllyxquotefix.pl"

1.18 2HTML版式的在線目錄(linking/anchors)

   主索引 一般來說,是被推薦的

1.19 專用的頁面

   因為HTML版式是由SGML生成, HTML的文件名是隨機的, 一些名稱被定死.這是有   用的,並在以後不會改變. 如果您認為我漏了tag, 請讓我知道,我會加進去的.

1.20 有多少個關於 Linux和IPv6 HOWTO的變動版本?

   加上這個, 有三個呢. 抱歉,是有點太多.

1.21 Linux IPv6 FAQ/HOWTO (過時的)

   第一個由 Eric Osborne 所寫. 叫做 Linux IPv6   FAQ/HOWTO(http://www.linuxhq.com/IPv6/). 有誰知道它的初始日期,請   來e-mail告訴我, 用來寫歷史的.

1.22 IPv6 & Linux - HowTo (正在維護當中)

   那裡有一個我(Peter Bieringer)寫的第二版, 叫做 IPv6 & Linux -   HowTo(http://www.bieringer.de/linux/IPv6/), 格式是純HTML, 1997年4月開   始, 並在同年7月發行了第一個英文版, 我會繼續維護它. 但它會被慢慢地容合   進現在您讀的這份HOWTO當中.

1.23 Linux IPv6 HOWTO (現在這份HOWTO)

   由於IPv6 & Linux - HowTo(http://www.bieringer.de/linux/IPv6/) 是用   純HTML寫的, 與 Linux 文檔計劃(www.linuxdoc.org)不兼容. 我(Peter   Bieringer)接到了一個將 IPv6 & Linux - HowTo 寫成SGML格式的請求. 因為將   要停止寫HOWTO(將來的IPv6 & Linux - HowTo), 並隨著IPv6越來越標準化, 我   決定寫一個新的在未來幾年占主要地位的比較更持久的版本, 包括了基本的和高   級的版本. 動態的資訊依然會在將來的日子裡添加到第二個HOWTO裡去(IPv6 &   Linux - HowTo).http://www.bieringer.de/linux/IPv6/

1.24 Long code line wrapping signal char

   "?"這個特殊的字符是讓編碼在PDF 和 PS 文件中顯得更好看.

1.25 Placeholders (佔位符)

   您可以常常在例子中看到如下的內容:

   < myipaddress >

   在您的系統命令行或scripts裡會被相應的內容所取代(當然是將 "< >" 去掉   啦), 結果變成這樣:

   1.2.3.4

1.26 Commands in the shell(shell 裡的命令)

   可執行的命令(非root用戶),由 "$" 開頭, 如:

   $ whoami

   可執行的命令(root用戶),由 "#" 開頭, 如:

   # whoami

1.27 使用這個HOWTO的必需條件

  個人所要必備的條件.

   您必需熟悉主要的UNIX工具,如grep, awk, find, ... , 和它們的一般用法.

  知道一些網路理論

   您要知道layers, protocls, addresses , cables ,plugs, 等. 如果您剛進入   這個領域, 這個連結有助於您: [2]   http://www.linuxports.com/howto/intro_to_networking/

  設定IPv4的經驗

   您必需有明確的IPv4的設定經驗.不然,您將不知道如何進行下去.

  Domain Name System (DNS 動態名稱侍服系統)的經驗

   您最少要知道如何使用tcpdump, 它告訴您的是什麼. 不然,對您來說然度相當   大.

  Linux 作業系統的兼容硬體

   您必需有實際的操作經驗, 並且不要在看HOWTO的時候到處打磕睡. :) 

2. 什麼是IPv6?

   IPv6是新的第三層傳輸協議(參   考http://www.linuxports.com/howto/intro_to_networking/c4412.htm#PAGE10   3HTML),它將用來取代IPv4(也叫做IP).

   IPv4是很早以前設計的,現在對IPv4提供更多的地址和性能方面有著更高的要求.   在IPv6中主要的變革是重新設計了報頭. 包括將地址位的大小從32 bits 增加到   128 bits. 因為第三層傳輸主要負責end-to-end(端對端)基於地址的數據包路   由. 它必需包含新的IPv6地址(來源和目標),這點就像IPv4一樣.

   下面這個連結提供了更多有關IPv6的資訊, 和RFC 的例表等等:

http://www.switch.ch/lan/ipv6/references.html

2.1 IPv6在Linux作業系統上的歷史

   將要做的: 更好的時間排列, 更多的內容...

2.2 開始

   第一次將與IPv6有關的代碼加入 Linux kernel 2.1.8 的工作是由Pedro Roque   在1996年11月完成的. 它基於BSD API:       ______________________________________________________________

diff -u --recursive --new-file v2.1.7/linux/include/linux/in6.h linux/include/linux/in6.h--- v2.1.7/linux/include/linux/in6.h Thu Jan 1 02:00:00 1970+++ linux/include/linux/in6.h Sun Nov 3 11:04:42 1996@@ -0,0 +1,99 @@+/*+ * Types and definitions for AF_INET6+ * Linux INET6 implementation+ * + * Authors:+ * Pedro Roque <******>+ *+ * Source:+ * IPv6 Program Interfaces for BSD Systems+ * <draft-ietf-ipngwg-bsd-api-05.txt>       ______________________________________________________________

   以上的代碼來自patch-2.1.8 (e-mail 地址在複製&貼上時漏掉了)

2.3 其間

   因為缺少人手, 在核心加入IPv6的計劃不能按照討論的或新的RFCs執行.

   在2000年的10月, 一個叫做USAGI(http://www.linux-ipv6.org/)的計劃在日本   正式啟動. 目標是執行所有不見了的, 擱淺的(IPv6 support in Linux)計劃.   計劃緊隨 KAME project (http://www.kame.net/) 的腳步. 依據 vanilla   Linux 核心源代碼進行遂步的改動.

2.4 現在

   不幸的是 USAGI 的 patch(補丁)很大, Linux networking 維護人員無法將它包   含進現在Linux 2.4.x 系列的源代碼當中去. 因此2.4.x 失去了一些(多數)括展   性, 並且不支持所有當前的設計和RFCs. 這導致了它和其它作業系統會產生一些   協同問題.

2.5 將來

   USAGI 現在正在將當前的括展加入到 Linux 2.5.x 核心當中.

   希望2.6.x 系列核心能有一個真正和最新的IPv6功能.

2.6 IPv6 的地址會是什麼樣 ?

   剛才提過, IPv6 的地址有128 bits 長. 這樣的 bits 可以產生39個十進字數   字:       ______________________________________________________________

2^128-1: 340282366920938463463374607431768211455       ______________________________________________________________

   這樣的地址很難記得住. IPv6的地址是逐位定位的(就像IPv4, 但這個觀點不是   公認的). 所以十六進制能更好地代表這些數字, 4 bits(也叫做"nibble")表現   為數字(0-9)或字符 a-f(10-15). 這種格式將IPv6的地址長度縮減到個32字符.       ______________________________________________________________

2^128-1: 0xffffffffffffffffffffffffffffffff       ______________________________________________________________

   這種表現形式仍然很不方便. (可能混淆或遺漏單個十六進制數字), 所以IPv6的   設計者將地址形式定為每16bit就用":"區分開來. 開頭的"0x"(在程式設計當中   用來表示十六進制數值)被移除了:       ______________________________________________________________

2^128-1: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff       ______________________________________________________________

   一個有效的地址(稍後請看地址類型)如下:       ______________________________________________________________

3ffe:ffff:0100:f101:0210:a4ff:fee3:9566       ______________________________________________________________

   為了簡化, 每個16bit開頭的0可以被省略:       ______________________________________________________________

3ffe:ffff:0100:f101:0210:a4ff:fee3:9566  -> 3ffe:ffff:100:f101:210:a4ff:fee3:9566       ______________________________________________________________

   連續的並且數值為0的16bit地址段可以用"::"表示. 但是一個IPv6地址當中只能   出現一次, 不然這種方法保持不了多久.       ______________________________________________________________

3ffe:ffff:100:f101:0:0:0:1  ->  3ffe:ffff:100:f101::1       ______________________________________________________________

   簡化得最短的IPv6 localhost地址:       ______________________________________________________________

0000:0000:0000:0000:0000:0000:0000:0001  ->  ::1       ______________________________________________________________

   這種方法也叫做 compact (base85 coded) representation defined RFC 1924   / A IPv6緊湊地址表示法(定於1996), 但沒有提起過, 例如:       ______________________________________________________________

# ipv6calc --addr_to_base85 3ffe:ffff:0100:f101:0210:a4ff:fee3:9566Itu&-ZQ82s>J%s99FJXT       ______________________________________________________________

   資訊: ipv6calc 是一個IPv6地址格式的計算和轉換的計劃, 您可以在這裡找到:   http://www.bieringer.de/linux/IPv6/ipv6calc/

2.7 FAQ(基礎)

  為什麼叫IPv6,而不能成為IPv4之後的IPv5 ?

   在任何IP頭, 前4bits 是為協議版本號所保留的. 所以理論上一個協議的版本號   在0和15之間是有效的:

     * 4 己經為IPv4所使用.     * 5 為 Stream 協議所保留(STP, RFC 1819 http://rfc.net/rfc1819.html       沒有公開過)

   IPv4之後可用的版本號是6, 因此 IPv6 就這樣旦生了!

  IPv6 地址: 為什麼會有這麼長的bits

   在設計IPv4的時候,人們認為32bit的長度足夠全世界使用. 看一看這些年,   32bit 就現在和未來幾年來說是足夠的. 然而, 32bits 不能在將來滿足全球各   種網路設備對IP地址的需求. 想一想將來要連結網路的移動電話, 汽車(包括電   子總控系統), 烤麵包機,冰箱, 照明開關...

   所以設計者採用了128bits, 是今天IPv4 大小(2^96)與長度的4倍.

   實際使用的大小可能比它看起來的還要小. 因為現在的定義地址設計, 64bits   用於interface identifiers(界面標識). 另外64bits用於路由. 寄於現在嚴格   的層數集合(/48, /35, ...), IPv6 所能提供的地址空間還是可能不夠, 希望這   種情況不要在往後的幾年裡發生.

  IPv6 地址: 為什麼在新的設計裡bits這麼小?

   雖然, (可能)有些人(在Internet裡)考慮IPv8和IPv6, 設計無論從接受和執行都   是那麼的遙遠. 在此其間128bit對於報頭和數據傳輸來說是最佳的選擇.

   考慮到在IPv4里和IPv6里的最大/最小傳輸單位(MTU,它們分別是576byte 和   1280 byte), IPv4 的報頭是20 byte(最小值,可以通過調節IPv4的選項增大   到60byte), IPv6 的報頭是48 byte(固定不變的), 報頭分別占它們MTU的3.4%   和3.8%, 這意昧著報頭佔了很大一部分開銷. 更大bits的地址需要更大的報頭,   因而佔據更大的開銷.

   同樣,顧及到MTU正常連結的最大值(像現在的以太網): 1500byte(除了特別的列   子:9k byte 應用在 Jumbo frames 當中). 最終,如果要傳輸在第三層數據包中   占10%或20%報頭, 這樣的IP地址在設計上也就沒有意義了.

3. 地址的類型

3.1 沒有前綴的地址

  Localhost 地址

   這是一個特別為loopback interface(回送界面或環繞)定義的地址, 就像IPv4的   "127.0.0.1" 對於IPv6 localhost address 是:       ______________________________________________________________

0000:0000:0000:0000:0000:0000:0000:0001       ______________________________________________________________

   或縮減成       ______________________________________________________________

::1       ______________________________________________________________

   這個地址的數據包將它當作host(主機)發送的來源和目標.

  未指明的地址

   這是一個在IPv4當中表示 "所有" 或"0.0.0.0". 對於IPv6為:       ______________________________________________________________

0000:0000:0000:0000:0000:0000:0000:0000       ______________________________________________________________

   或者是:       ______________________________________________________________

::       ______________________________________________________________

   這些地址大多 用在/顯示 socket 捆綁(到所有IPv6地址)或路由表當中.

   注意:未說明的地址不能當成目標地址來使用.

  植入了IPv4地址的IPv6地址

   它包含了兩個地址其中一個為IPv4地址.

  IPv4映射IPv6地址

   IPv4-only IPv6-compatible 是由IPv6後台產生的有時 用於或顯示 sockets .   它只捆綁IPv4地址.

   這些地址被定義為擁有長度為96的前綴特殊地址(a.b.c.d 是IPv4地址):       ______________________________________________________________

0:0:0:0:0:ffff:a.b.c.d/96       ______________________________________________________________

   或者使用縮寫形式       ______________________________________________________________

::ffff:a.b.c.d/96       ______________________________________________________________

   這些地址也用於自動遂道, 已經被6to4tunneling取代.

3.2 網路部分,也叫做前綴

   設計者定義並預留了一部份空間以便於將來遇到像現在這樣的需求. RFC 2373   [July 1998] / IP Version 6 Addressing Architecture   (http://rfc.net/rfc2373.html) 定義了現在的地址設計, 但已經有了新的草案   (ftp://ftp.ietf.org/internet-drafts/)draft-ietf-ipngwg-addr-arch-*.txt

   讓我們來看一下不同的前綴定義(和地址類型):

  連結本地地址的類型

   這些地址不對外界(Internet)連接有效. 以這些地址為目標的數據包不會通過路   由器. 這種連結用於以下情形:

     * 同其它任意一個也使用這個連結的人進行通訊.     * 同其它任意一個擁有特殊地址的連結進行通訊.(例如尋找路由)

   它們的地址由以下這些開頭("x"是任意的十六進制字符,一般是"0")       ______________________________________________________________

fe8x:  <- 目前只有這個在用.fe9x:feax:febx:       ______________________________________________________________

   一個開頭為以上這些前綴的地址, 由IPv6沒有在界面指定IP地址的時候創立.

   目前只有fe80在使用.

  本地站點的地址定義

   這些地址和IPv4相似(http://rfc.net/rfc1918.html RFC 1918 / Address   Allocation for Private Internets) 它的優勢: 只用16bits 就可以定義65536   個子網.同IPv4的10.0.0.0/8相似.

   另一個優勢:在IPv6的界面上可以定義多個IP地址, 在已有本地站點地址的基礎   上還可以加上一個global(全局)地址.

   它們的地址由以下這些開頭("x"是任意的十六進制字符,一般是"0")       ______________________________________________________________

fecx:  <- 大多數使用這個fedx:feex:fefx:       ______________________________________________________________

  Global(全局)地址類型 "(Aggregatable) global unicast"可聚合的全局唯一地址.

   今天,只有一個全局地址類型的定義(第一個設計,也是多年以來一直使用的叫做   "provider based," [3]RFC 1884 / IP Version 6 Addressing Architecture   [obsolete]) 您能在早期的核心源代碼中找到一些.

   它們的地址由以下這些開頭("x"是任意的十六進制字符,一般是"0")       ______________________________________________________________

2xxx:3xxx:       ______________________________________________________________

   注意: 前綴"aggregatable" 被當前的草案拋棄了. 下面有一些更有意義的子類   型定義:

  6bone test addresses

   這些是最初定義和使用的全局地址. 它們的開頭是       ______________________________________________________________

3ffe:       ______________________________________________________________

   例子       ______________________________________________________________

3ffe:ffff:100:f102::1       ______________________________________________________________

   一個無唯一全局化的特別6bone例子       ______________________________________________________________

3ffe:ffff:100:f102::1       ______________________________________________________________

   這些主要都是例子, 因為如果使用真實的地址,可能會有些人將它拷貝&貼上 到   他們自己的配置中去. 從而不注意地複製了全局唯一地址, 這樣會導致原來擁有   這個地址的主機產生一些問題(比如,請求的回應包不會被發送.) 您可以從這些   前綴當中申請一個, 看這裡: "如何加入6bone" 也有一些在 tunnel brokers 他   們發佈用於測試6bone 的地址前綴.

  6to4 地址

   這些地址是為特別tunneling機制設計的. [4][RFC 3056 / Connection of IPv6   Domains via IPv4 Clouds 和 [5]RFC 2893 / Transition Mechanisms for   IPv6 Hosts and Routers], 給IPv4地址和可能的子網編碼並以類似下面的形式   開頭:       ______________________________________________________________

2002:       ______________________________________________________________

   例子,重新對192.168.1.1/5編碼:       ______________________________________________________________

2002:c0a8:0101:5::1       ______________________________________________________________

   這個shell命令將幫助您用一個IPv4地址產生這樣的地址:       ______________________________________________________________

ipv4="1.2.3.4"; sla="5"; printf "2002:%02x%02x:%02x%02x:%04x::1" `echo $ipv4 |tr "." " "` $sla       ______________________________________________________________

   參照tunneling using 6to4 and information about 6to4 relay routers.

  從分級路由分配到的地址

   這些地址分配給Internet服務供商(ISP)並且有類似如下的開頭:       ______________________________________________________________

2001:       ______________________________________________________________

   主ISP(擁有骨幹網路)的前綴是由local registries分配的, 並且現在他們分配   的前綴長度為35.

   主ISPs通常分配給下級ISPs的前綴長度為48.

  Multicast addresses(多點傳送的地址)

   Multicast addresses 應用於服務當中.

   它們總是有同下面相類似的開頭(xx是範圍值)       ______________________________________________________________

ffxy:       ______________________________________________________________

   它們有著不同的範圍和類型:

  Multicast scopes(多點傳達送範圍)

   Multicast scope 是用來定義發送實體的multicast 數據包有效最遠傳輸值的參   數.

   通常,下面的範圍已經被定義:     * ffx1: 本地節點, 數據包不會離開節點.     * ffx2: 本地連結, 數據包不會被路由,所以它們不會離開這個特別的連結.     * ffx5: 本地站點, 數據包不會離開站點.     * ffx8: 本地組織, 數據包不會離開組織(執行起來不那麼容易,必須依靠路由       協議)     * ffxe: 全局範圍.     * 其它的都被保留

  Multicast(多點傳送)類型

   許多類型都已經定義/保留(細節請參照 [6]RFC 2373 / IP Version 6   Addressing Architecture). 這裡有一些例子:     * 所有節點地址: ID=1h, 所有本地節點主機的地址(ff01:0:0:0:0:0:0:1) 或       已連接好的地址(ff02:0:0:0:0:0:0:1).     * 所有路由地址:ID=2h,所有本地節點的路由地址(ff01:0:0:0:0:0:0:2), 已       連接的(ff02:0:0:0:0:0:0:2), 或本地站點(ff05:0:0:0:0:0:0:2).

  Solicited node link-local multicast address(本地多播請求的節點地址)

   在neighborhood discovery(多播發現)中當成目標地址使用的特別多播地址.   與IPv4不同,ARP(地址解析協議)將不在IPv6中使用.

   例子:       ______________________________________________________________

ff02::1:ff00:1234       ______________________________________________________________

   使用前綴表示它是一個本地多播地址, 後綴由目標地址產生. 這個例子當中將有   一個數據包發往"fe80::1234", 但是網路堆棧並不知道第二層的MAC(多媒體通   路). 它將上部份的104 bits 更改為 "ff02:0:0:0:0:1:ff00::/104" 下部分24   bits 不變. 現在這個地址以on-link(在線)的形式尋找相應的節點(這個節點應   當發送了包含有第二層 MAC 地址的回應包)

  Anycast addresses(隨播地址)

   Anycast addresses是一個特別的地址, 它用於鄰近的DNS或DHCP服務, 或用於相   似的dynamic groups(動態組群). 地址從 unicast address (單播地   址aggregatable global or site-local at the moment)空間中取得. 隨播地址   的機制(從客戶端的觀點來看)由動態路由協議控制.

   注意:隨播地址不能成為作為來源地址, 它必需以目標地址的身份出現.

  Subnet-router Anycast addresses(子網路隨播路由器)

   一個Subnet-router Anycast addresses的例子. 假設一個分配了如下IPv6地址   的節點:       ______________________________________________________________

3ffe:ffff:100:f101:210:a4ff:fee3:9566/64  <- 節點的地址       ______________________________________________________________

   Subnet-router將使用沒有後綴的地址 (least significant 64 bits):       ______________________________________________________________

3ffe:ffff:100:f101::/64  <- subnet-router anycast address       ______________________________________________________________

3.3 地址類型(主機)

   因為自動的配製/隨機分配,在當前的地址類型中主機使用更低的 64 bits地址.   因此每個subnet(子網)可以擁有大量的地址.

   主機的地址分配可以有如下幾種形式:

  自動分配(also known as stateless)

   在自動分配當中,主機的地址由界面的MAC地址決定. 使用EUI-64方法,指定一   個IPv6 地址. 如果沒有可用的MAC(如:虛擬設備), 就用其它的代替(如IPv4地址   或物理界面的MAC地址)

   再看一下前面的例子:       ______________________________________________________________

3ffe:ffff:100:f101:210:a4ff:fee3:9566       ______________________________________________________________

   這裡:       ______________________________________________________________

210:a4ff:fee3:9566       ______________________________________________________________

   主機地址由NIC的MAC地址決定:       ______________________________________________________________

00:10:A4:E3:95:66       ______________________________________________________________

   用 [7]IEEE-Tutorial EUI-64 作為EUI-48 的標識符.

  自動分配帶來的隱私問題

   因為自動分配的是唯一地址,客戶端在不通過任何代理的情況下容易被跟蹤. 這   是個公認的問題,它的解決方法是:privacy extension,定義於 [8]RFC 3041 /   Privacy Extensions for Stateless Address Autoconfiguration in IPv6 這   裡也有一個草案: [9]draft-ietf-ipngwg-temp-addresses-*.txt 使用不同的靜   態數值, 每次產生一個新的後綴. 注意: 只對client 的連接有效, 對於servers   沒有什麼用處.

  手動設定

   對於servers來說, 大概很容易記起簡單的地址. 同時也可以向它的界面添加一   個IPv6地址:       ______________________________________________________________

3ffe:ffff:100:f101::1       ______________________________________________________________

   手動設定的後綴為"::1",例子當中最重要的第6 bits設定為"0", 它為anycast   addresses(任意傳送地址)保留 (the universal/local bit of the   automatically generated identifier).

3.4 路由的前綴長度

   在早期設計階級,使用完全分離的路由分級來最大層度地縮小路由表. 論證的方   法是使用當前IPv4的核心路由數目(> 104 thousand in May 2001) 減少硬體記   憶體的需求來控制路由表和速度(較少的個數使查找速度加快).

  前綴長度(也叫做子網路遮罩)

   同IPv4相似, 網路產生可路由的路徑. 因為128 bits標準的netmasks 看起來不   怎麼樣. 設計者借鑒了IPv4的風格: Classless Inter Domain Routing (CIDR   [10]RFC 1519 / Classless Inter-Domain Routing) 它們是用於IP地址路由   的bits號碼. 也叫做"/"

   例子:       ______________________________________________________________

3ffe:ffff:100:1:2:3:4:5/48       ______________________________________________________________

   它們可以被擴展成:       ______________________________________________________________

網路:3ffe:ffff:0100:0000:0000:0000:0000:0000       ______________________________________________________________       ______________________________________________________________

子網路遮罩:ffff:ffff:ffff:0000:0000:0000:0000:0000       ______________________________________________________________

  Matching a route(路由匹配)

   在一般情況下(no QoS), 在路由表裡查找一個重要的地址數值意味著路由前綴的   長度必需先匹配.

   例子, 如果路由表像下面那樣(清單未完全例出):       ______________________________________________________________

3ffe:ffff:100::/48     ::            U  1 0 0 sit12000::/3               ::192.88.99.1 UG 1 0 0 tun6to4       ______________________________________________________________

   IPv6的目標地址將被下面的設備路由:       ______________________________________________________________

3ffe:ffff:100:1:2:3:4:5/48  ->  routed through device sit13ffe:ffff:200:1:2:3:4:5/48  ->  routed through device tun6to4       ______________________________________________________________

4. 準備IPv6的運行系統

4.1 IPv6-ready kernel

   現在的Linux發行版的核心都具備了運行IPv6的條件. IPv6功能被編譯成一個可   載入模組. 在一般情況下模組不會在開機的時候自動載入.

   參照更新的資訊: [11]IPv6+Linux-Status-Distribution

  檢察現在的系統是否支持IPv6

   注意您的/proc-file-system.必需有如下的結構:       ______________________________________________________________

/proc/net/if_inet6       ______________________________________________________________

   一個簡單的測試:       ______________________________________________________________

# test -f /proc/net/if_inet6 && echo "Running kernel is IPv6 ready"       ______________________________________________________________

   如果失敗, 表明模組沒有載入.

  試著載入模組

   執行載入模組的命令:       ______________________________________________________________

# modprobe ipv6       ______________________________________________________________

   如果成功, 模組會在列表中顯示,執行如下命令:       ______________________________________________________________

# lsmod |grep -w 'ipv6' && echo "IPv6 module successfully loaded"       ______________________________________________________________

  讓模組自動載入

   模組是可以自動載入的,只要在核心模組設定文件( /etc/modules.conf 或   /etc/conf.modules)中加入:       ______________________________________________________________

alias net-pf-10 ipv6  # automatically load IPv6 module on demand       ______________________________________________________________

   也可以關掉IPv6模組的自動載入:       ______________________________________________________________

alias net-pf-10 off   # disable automatically load of IPv6 module on demand       ______________________________________________________________

  編譯有 IPv6 功能的核心

   如果以上兩個結果都證實了核心不具有IPv6功能, 您可以有如下選擇:     * 升級成外包裝有IPv6支持說明的Linux發行版(推薦新手使用)再看一下這裡:       [12]IPv6+Linux-Status-Distribution     * 編譯一個新的vanilla核心(如果您知道該怎麼選擇,會比較簡單).     * 重新編譯您現在擁有的發行版核心(不太容易).     * 將核心同 USAGI 的擴展一起編譯.

   如果您決定編譯一個核心,您必需讀過 [13]Linux Kernel HOWTO. 以及這方面的   經驗.

   注意:您必需使用核心2.4.x系列或更高. 因為IPv6對2.2.x系列缺少相應的支持.   並且需要ICMPv6 和 6to4 支持的補丁.(補丁可以在 [14]kernel series 2.2.x   IPv6 patches找到).

  將核心同 USAGI 的擴展一起編譯.

   只推薦熟悉核心編譯和IPv6的用戶使用. 參照: [15]USAGI project / FAQ.

  IPv6-ready network devices

   不是所有的設備都有能力傳輸IPv6數據包, 這裡有一個現狀表: [16]   IPv6+Linux-status-kernel.html#transport.

  現階段不會支持IPv6的連結

     * Serial Line IP (SLIP, [17]RFC 1055), should be better called now       to SLIPv4, device named: slX     * Parallel Line IP (PLIP), same like SLIP, device names: plipX     * ISDN with encapsulation rawip, device names: isdnX

  在將來都不會支持IPv6的設備

     * ISDN with encapsulation syncppp, device names: ipppX (design issue       of the ipppd, will be merged into more general PPP layer in kernel       series 2.5.x)

4.2 IPv6-ready 網路設定工具

   別扯太遠了, 如果您有一個正在運行IPv6的核心,怎麼會沒有設定的工具呢? 安   裝包裡早就有幾個這樣的工具了.

  net-tools package

   net-tools package 包含一些工具如: ifconfig ,route. 這些可以令您在界面   上設定IPv6. 在命令行(shell) 用ifocnig -? 或 route -? 查看諸如IPv6 或   inet6.如果有,則說明具備IPv6設定能力.

   輸入以下命令進行檢查:       ______________________________________________________________

# /sbin/ifconfig -? 2>& 1|grep -qw 'inet6' && echo "utility 'ifconfig' is?IPv6-ready"       ______________________________________________________________

   也可以使用route:       ______________________________________________________________

# /sbin/route -? 2>& 1|grep -qw 'inet6' && echo "utility 'route' is IPv6-ready"       ______________________________________________________________

  iproute package

   Alexey N. Kuznetsov (Linux 網路代碼現階段的維護者) 寫了一個tool-set可   以通過netlink 設備來設定網路.它可以比net-tool提供更多的功能, 但沒有多   少文檔並且它不是為膽小的人設計的.       ______________________________________________________________

# /sbin/ip 2>&1 |grep -qw 'inet6' && echo "utility 'ip' is IPv6-ready"       ______________________________________________________________

   如果沒有找到 /sbin/ip 那麼我極力推薦您安裝iproute package.     * 可以在您的發行版中找到(如果有的話)     * 在 [18]Original FTP source下載並編譯它.     * 直接可以安裝的RPM包: [19]RPMfind/iproute (推薦編譯 SRPMS )

4.3 IPv6-ready 測試/調式 程式

   在為IPv6準備好了系統後,您可以用IPv6進行網路通訊. 首先您必需學習如何用   嗅探程式來檢查IPv6數據包. 強烈推薦這樣做,因為   在debugging/troubleshooting 中有利於快速診斷.

  IPv6 ping

   這個程式一般在iputils包裡, 用來測試簡單傳輸發送 ICMPv6 回應請求並等   待ICMPv6 回應包.

   用法:       ______________________________________________________________

# ping6 < hostwithipv6address ># ping6 < ipv6address ># ping6 [-I < device >] < link-local-ipv6address >       ______________________________________________________________

   例子:       ______________________________________________________________

# ping6 -c 1 ::1PING ::1(::1) from ::1 : 56 data bytes64 bytes from ::1: icmp_seq=0 hops=64 time=292 usec--- ::1 ping statistics ---1 packets transmitted, 1 packets received, 0% packet lossround-trip min/avg/max/mdev = 0.292/0.292/0.292/0.000 ms       ______________________________________________________________

   提示 ping6必需有適當的root權限才能使用, 如果不是root組用戶,使用時可能   產生問題:

   1.ping6 不在用戶的路徑當中 (probably, because ping6 is generally   stored in /usr/sbin -> add path (not really recommended)

   2.ping6 不能被正確執行, 通常沒有適當的權限 chmod u+s /usr/sbin/ping6

  為ping6指定界面

   用local-addresses 作為ping6 目標必需指定一個界面. 否則核心將不知道數據   包發往哪個設備. 在沒有指定的情況下會有這樣的輸出:       ______________________________________________________________

# ping6 fe80::212:34ff:fe12:3456connect: Invalid argument       ______________________________________________________________

   為ping6指定界面的結果:       ______________________________________________________________

# ping6 -I eth0 -c 1 fe80::2e0:18ff:fe90:9205PING fe80::212:23ff:fe12:3456(fe80::212:23ff:fe12:3456) from?fe80::212:34ff:fe12:3478 eth0: 56 data bytes64 bytes from fe80::212:23ff:fe12:3456: icmp_seq=0 hops=64 time=445 usec--- fe80::2e0:18ff:fe90:9205 ping statistics ---1 packets transmitted, 1 packets received, 0% packet loss round-trip?min/avg/max/mdev = 0.445/0.445/0.445/0.000 ms       ______________________________________________________________

  Ping6 to multicast addresses(多播地址)

   一個發現IPv6-active hosts 的比較有趣的機制:       ______________________________________________________________

# ping6 -I eth0 ff02::1 PING ff02::1(ff02::1) from fe80:::2ab:cdff:feef:0123 eth0: 56 data bytes64 bytes from ::1: icmp_seq=1 ttl=64 time=0.104 ms64 bytes from fe80::212:34ff:fe12:3450: icmp_seq=1 ttl=64 time=0.549 ms (DUP!)       ______________________________________________________________

   與IPv4不同的是, ping 的回應在廣播地址中是可以屏蔽的,目前只有IPv6防火牆   可以做到.

  IPv6 traceroute6

   這個程式一般在iputils包裡, 和IPv4的traceroute程式相似, 但與當前版本不   同的是IPv6不能正確地使用ICMP echo-request. 看下面這個例子:       ______________________________________________________________

# traceroute6 www.6bone.nettraceroute to 6bone.net (3ffe:b00:c18:1::10) from 3ffe:ffff:0000:f101::2, 30?hops max, 16 byte packets 1 localipv6gateway (3ffe:ffff:0000:f101::1) 1.354 ms 1.566 ms 0.407 ms 2 swi6T1-T0.ipv6.switch.ch (3ffe:2000:0:400::1) 90.431 ms 91.956 ms 92.377 ms 3 3ffe:2000:0:1::132 (3ffe:2000:0:1::132) 118.945 ms 107.982 ms 114.557 ms 4 3ffe:c00:8023:2b::2 (3ffe:c00:8023:2b::2) 968.468 ms 993.392 ms 973.441 ms 5 3ffe:2e00:e:c::3 (3ffe:2e00:e:c::3) 507.784 ms 505.549 ms 508.928 ms 6 www.6bone.net (3ffe:b00:c18:1::10) 1265.85 ms * 1304.74 ms       ______________________________________________________________

  IPv6 tracepath6

   這個程式一般在iputils包裡, 它用來追蹤MTU的路徑.看下面的例子:       ______________________________________________________________

# tracepath6 www.6bone.net 1?: [LOCALHOST] pmtu 1480 1: 3ffe:401::2c0:33ff:fe02:14 150.705ms 2: 3ffe:b00:c18::5 267.864ms 3: 3ffe:b00:c18::5 asymm 2 266.145ms pmtu 1280 3: 3ffe:3900:5::2 asymm 4 346.632ms 4: 3ffe:28ff:ffff:4::3 asymm 5 365.965ms 5: 3ffe:1cff:0:ee::2 asymm 4 534.704ms 6: 3ffe:3800::1:1 asymm 4 578.126ms !NResume: pmtu 1280       ______________________________________________________________

  IPv6 tcpdump

   在Linux作業系統中 tcpdump 是主要的數據包捕獲工具.IPv6支持 3.6 的版本.

   tcpdump用於降低數據包雜訊的參數:     * icmp6: 過濾本地ICMPv6通訊.     * ip6: 過濾本地IPv6通訊.(包括 ICMPv6)     * proto ipv6: filters tunneled IPv6-in-IPv4 traffic     * not port ssh: 在遠程SSH會話中禁止SSH數據包的顯示. to suppress       displaying SSH packets for running tcpdump in a remote SSH session

   使用命令行參數也可以從一個數據包中捕獲/列印資訊.     * "-s 512": 增加捕獲限定為512 bytes.     * "-vv": 詳細列印.     * "-n": 不將地址轉換成名稱,在名稱服務有問題時可以用到.

  IPv6 ping to 3ffe:ffff:100:f101::1 native over a local link       ______________________________________________________________

 # tcpdump -t -n -i eth0 -s 512 -vv ip6 or proto ipv6tcpdump: listening on eth03ffe:ffff:100:f101:2e0:18ff:fe90:9205 > 3ffe:ffff:100:f101::1: icmp6: echo?request (len 64, hlim 64)3ffe:ffff:100:f101::1 > 3ffe:ffff:100:f101:2e0:18ff:fe90:9205: icmp6: echo?reply (len 64, hlim 64)       ______________________________________________________________

  IPv6 ping to 3ffe:ffff:100::1 routed through an IPv6-in-IPv4-tunnel

   1.2.3.4和5.6.7.8是遂道的終點(這些都是例子).       ______________________________________________________________

# tcpdump -t -n -i ppp0 -s 512 -vv ip6 or proto ipv6tcpdump: listening on ppp01.2.3.4 > 5.6.7.8: 2002:ffff:f5f8::1 > 3ffe:ffff:100::1: icmp6: echo request?(len 64, hlim 64) (DF) (ttl 64, id 0, len 124)5.6.7.8 > 1.2.3.4: 3ffe:ffff:100::1 > 2002:ffff:f5f8::1: icmp6: echo reply (len?64, hlim 61) (ttl 23, id 29887, len 124)1.2.3.4 > 5.6.7.8: 2002:ffff:f5f8::1 > 3ffe:ffff:100::1: icmp6: echo request?(len 64, hlim 64) (DF) (ttl 64, id 0, len 124)5.6.7.8 > 1.2.3.4: 3ffe:ffff:100::1 > 2002:ffff:f5f8::1: icmp6: echo reply (len?64, hlim 61) (ttl 23, id 29919, len 124)       ______________________________________________________________

4.4 IPv6-ready programs(能和IPv6協同工作的程式)

   在當前的發行版中已經包含了能和IPv6協同工作的程式(服務端/客戶端)   參照: [20]IPv6+Linux-Status-Distribution.   或者檢查 [21]   http://www.bieringer.de/linux/IPv6/status/IPv6+Linux-status-apps.html   一些可用程式的線索: [22]IPv6 & Linux - HowTo - Part 3或 [23]IPv6 &   Linux - HowTo - Part 4.

4.5 IPv6-ready 客戶端程式 (selection)

   想要進行下面的測試, 您的作業系統必需擁有IPv6能力. 有些例子是真實地連結   了6bone的情況下做的.

  檢查DNS對IPv6地址的解析能力

   因為這幾年Domain Name System (DNS)安全的不斷升級, 它們中的大部份都具備   了對IPv6 地址類型AAAA的解析能力. (新的類型A6 只有BIND9和更高的版本支   持)檢查DNS對IPv6地址的解析能力:       ______________________________________________________________

# host -t AAAA www.join.uni-muenster.de       ______________________________________________________________

   將得到下面的結果:       ______________________________________________________________

www.join.uni-muenster.de. is an alias for ns.join.uni-muenster.de.ns.join.uni-muenster.de. has AAAA address 3ffe:400:10:100:201:2ff:feb5:3806       ______________________________________________________________

  IPv6-ready telnet clients

   IPv6-ready telnet 客戶端. 對它進行一個簡單的測試:       ______________________________________________________________

$ telnet 3ffe:400:100::1 80Trying 3ffe:400:100::1...Connected to 3ffe:400:100::1.Escape character is '^]'.HEAD / HTTP/1.0HTTP/1.1 200 OKDate: Sun, 16 Dec 2001 16:07:21GMT Server: Apache/2.0.28 (Unix)Last-Modified: Wed, 01 Aug 2001 21:34:42 GMTETag: "3f02-a4d-b1b3e080"Accept-Ranges: bytesContent-Length: 2637Connection: closeContent-Type: text/html; charset=ISO-8859-1Connection closed by foreign host.       ______________________________________________________________

   如果telnet只出現"cannot resolve hostname", 說明作業系統的IPv6還未激活.

  openssh

   openssh已經支持IPv6, 但必需對它用以下的參數進行編譯後才能使用:     * --without-ipv4-default: the client tries an IPv6 connect first       automatically and fall back to IPv4 if not working     * --with-ipv4-default: default connection is IPv4, IPv6 connection       must be force like following example shows:       ______________________________________________________________

$ ssh -6 ::1user@::1's password: ******[user@ipv6host user]$       ______________________________________________________________

   如果您的ssh不能對 -6 進行反應, 可能作業系統的IPv6還未激活,或ssh的版本   太低.

  ssh.com

   他們的客戶/服務端程式是免費的.

  IPv6-ready web 流覽器

   目前支持IPv6的web 流覽器列表: [24]IPv6+Linux-status-apps.html#HTTP.

   這些流覽器大部份都存在問題:     * 如果 proxy(代理)只支持IPv4, IPv6的請求將會失敗. 方法: 升級proxy     * Automatic proxy settings (*.pac) 不能對IPv6的不同請求進行適當的處       理 (written in Java-script and well hard coded in source like to       be seen in Maxilla source code).

   一些早期的版本不能對IPv6地址進行正確的操作, 如: [25]   http://[3ffe:400:100::1]/ 

   一個小測試,顯示在沒有代理的情況下的 URL 和 流覽器.

  URLs for testing

   測試IPv6最方便的方法是訪問: [26]http://www.kame.net/. 如果海龜是活動   的, 說明連接是通過IPv6進行的, 它不動的話, 說明連接是通過IPv4進行的.

4.6 IPv6-ready server 程式

   包括:sshd, httpd, telnetd,

5. 設定interfaces(界面)

5.1 不同的網路設備

   一個節點存在不同的網路設備, 可以對它們進行如下分類:     * Physically bounded, like eth0, tr0     * Virtually existing, like ppp0, tun0, tap0, sit0, isdn0, ippp0

  Physically bounded(物理綁定)

   包括 Ethernet 或者 Token-Ring 它們不需要特別的處理.

  Virtually bounded(虛擬綁定)

   需要特別的支持.

  IPv6-in-IPv4 tunnel interfaces

   這個interfaces(界面)也稱作sitx, sit 是"Simple Internet Transition" 的   縮寫. 它可以將IPv6的數據包塞進IPv4, 通過IPv4到達另一個地點.

   sit0 不能使用在專用的tunnels 上.

  5.1.2.2. PPP interfaces

   PPP interfaces 從IPv6 enabled PPP daemon 那裡獲得 IPv6 的能力.

  5.1.2.3. ISDN HDLC interfaces

   具有IP封裝的HDLC IPv6 能力以經包含在核心當中.

  5.1.2.4. ISDN PPP interfaces

   目前不支持 ISDN PPP interfaces (ippp) aren't IPv6 enabled by kernel.   Also there are also no plans to do that because in kernel 2.5.+ they   will be replaced by a more generic ppp interface layer.

  5.1.2.5. SLIP + PLIP

   目前不支持Like mentioned earlier, this interfaces don't support IPv6   transport (sending is OK, but dispatching on receiving don't work).

  5.1.2.6. Ether-tap device

   Ether-tap devices使用自動的設定.在使用之前先將 "ethertap" 模組掛進來.

  5.1.2.7. tun devices

   就連我都還沒試過呢! Currently not tested by me.

  5.1.2.8. ATM

   01/2002: vanilla的核心目前不支持, USAGI 的擴展支持ATM-IPv6

  5.1.2.9. 其它的

   我漏掉了什麼?

5.2 Bringing interfaces up/down(設定界面的開/關)

  使用 "ip"

   使用方法:       ______________________________________________________________

# ip link set dev <interface> up# ip link set dev <interface> down       ______________________________________________________________

   例子:       ______________________________________________________________

# ip link set dev eth0 up# ip link set dev eth0 down       ______________________________________________________________

  使用 "ifconfig"

   使用方法:       ______________________________________________________________

# /sbin/ifconfig <interface> up# /sbin/ifconfig <interface> down       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ifconfig eth0 up# /sbin/ifconfig eth0 down       ______________________________________________________________

6. 設定IPv6地址

6.1 列印當前的IPv6地址

  使用 "ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 addr show dev <interface>       ______________________________________________________________

   例子:一個靜態的主機地址       ______________________________________________________________

# /sbin/ip -6 addr show dev eth02: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_ fast qlen 100inet6 fe80::210:a4ff:fee3:9566/10 scope linkinet6 3ffe:ffff:0:f101::1/64 scope globalinet6 fec0:0:0:f101::1/64 scope site       ______________________________________________________________

   自動設定的地址和它的存活時間:       ______________________________________________________________

# /sbin/ip -6 addr show dev eth03: eth0: <BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc pfifo_fast qlen? 100inet6 2002:d950:f5f8:f101:2e0:18ff:fe90:9205/64 scope global dynamicvalid_lft 16sec preferred_lft 6secinet6 3ffe:400:100:f101:2e0:18ff:fe90:9205/64 scope global dynamicvalid_lft 2591997sec preferred_lft 604797sec inet6 fe80::2e0:18ff:fe90:9205/10? scope link       ______________________________________________________________

  使用 "ifconfig"

   使用方法:       ______________________________________________________________

# /sbin/ifconfig <interface>       ______________________________________________________________

   例子, 它只列印IPv6地址:       ______________________________________________________________

# /sbin/ifconfig eth0 |grep "inet6 addr:"inet6 addr: fe80::210:a4ff:fee3:9566/10 Scope:Linkinet6 addr: 3ffe:ffff:0:f101::1/64 Scope:Globalinet6 addr: fec0:0:0:f101::1/64 Scope:Site       ______________________________________________________________

6.2 增加一個IPv6地址

   其原理同IPv4的"IP ALIAS"(IP別名)相同

   使用 "ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 addr add <ipv6address>/<prefixlength> dev <interface>       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 addr add 3ffe:ffff:0:f101::1/64 dev eth0       ______________________________________________________________

  使用 "ifconfig"

   使用方法:       ______________________________________________________________

# /sbin/ifconfig <interface> inet6 add <ipv6address>/<prefixlength>       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ifconfig eth0 inet6 add 3ffe:ffff:0:f101::1/64       ______________________________________________________________

6.3 移除IPv6地址

   這個不常用, 不要用它移除不存在的地址, 一些早期的核心會因為受不了而掛   掉.

  使用 "ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 addr del <ipv6address>/<prefixlength> dev <interface>       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 addr del 3ffe:ffff:0:f101::1/64 dev eth0       ______________________________________________________________

  使用 "ifconfig"

   使用方法:       ______________________________________________________________

# /sbin/ifconfig <interface> inet6 del <ipv6address>/<prefixlength>       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ifconfig eth0 inet6 del 3ffe:ffff:0:f101::1/64       ______________________________________________________________

7. 設定IPv6路由

7.1 列印現有的路由

  使用"ip"

   使用方法:       ______________________________________________________________

# /sbin/ip -6 route show [dev <device>]       ______________________________________________________________

   例子:       ______________________________________________________________

# /sbin/ip -6 route show dev eth03ffe:ffff:0:f101::/64 proto kernel metric 256 mtu 1500 advmss 1440fe80::/10             proto kernel metric 256 mtu 1500 advmss 1440ff00::/8              proto kernel metric 256 mtu 1500 advmss 1440default               proto kernel metric 256 mtu 1500 advmss 1440       ______________________________________________________________

  使用 "route"

   使用方法:       ______________________________________________________________
分类: BSD/linux 标签: ,

调整ipfilter参数,减少网络堵塞

2007年11月16日 16hot 没有评论

当你用ipfilter和ipnat做NAT路由器及防火墙,而且路由器的客户端有BT在运行,在BT运 行了一段时间后容易造成浏览网页和下载其它东西的阻塞。其原因是BT会产生大量的连接和会话,超过了NAT表和状态表的容量。解决的方法就是增大NAT表 和状态表的容量和减少连接空闲的时间。

增大NAT表和状态表的容量:
ipf_nattable_sz=2047->30011(素数)
ipf_nattable_max=30000->300000
fr_statesize=5739->11471(素数)
fr_statemax=4013->8039(素数)#fr_statesize的70%

减少连接空闲的时间:
fr_tcptimeout=480->180
fr_tcpclosewait=480->60
fr_tcphalfclosed=14400->300
fr_tcpclosed=120->60
fr_tcplastack=480->120
fr_tcpidletimeout=864000->7200
fr_udptimeout=240->90
fr_icmptimeout=120->35

在命令行下修改参数:(假设已经在内核中加载了ipl.ko模块)
/sbin/ipf -D -T ipf_nattable_sz=30011,ipf_nattable_max=300000,
fr_tcptimeout=180,fr_tcpclosewait=60,fr_tcphalfclosed=300,
fr_tcpidletimeout=7200,fr_tcpclosed=60,fr_tcplastack=120,
fr_udptimeout=90,fr_icmptimeout=35,
fr_statemax=8039,fr_statesize=11471 -E

再看一下是否已经改好:
sysctl net.inet.ipf
net.inet.ipf.fr_minttl: 4
net.inet.ipf.fr_chksrc: 0
net.inet.ipf.fr_defaultauthage: 600
net.inet.ipf.fr_authused: 0
net.inet.ipf.fr_authsize: 32
net.inet.ipf.ipf_hostmap_sz: 2047
net.inet.ipf.ipf_rdrrules_sz: 127
net.inet.ipf.ipf_natrules_sz: 127
net.inet.ipf.ipf_nattable_sz: 30011*
net.inet.ipf.fr_statemax: 8039*
net.inet.ipf.fr_statesize: 11471*
net.inet.ipf.fr_running: 1
net.inet.ipf.fr_ipfrttl: 120
net.inet.ipf.fr_defnatage: 1200
net.inet.ipf.fr_icmptimeout: 35*
net.inet.ipf.fr_udpacktimeout: 24
net.inet.ipf.fr_udptimeout: 90*
net.inet.ipf.fr_tcpclosed: 60*
net.inet.ipf.fr_tcptimeout: 180*
net.inet.ipf.fr_tcplastack: 120*
net.inet.ipf.fr_tcpclosewait: 60*
net.inet.ipf.fr_tcphalfclosed: 300*
net.inet.ipf.fr_tcpidletimeout: 7200*
net.inet.ipf.fr_active: 0
net.inet.ipf.fr_pass: 134217730
net.inet.ipf.fr_flags: 0
打*号表示已经修改过了。

或者另一种方法看一下:
ipf -T list
fr_flags min 0 max 0xffffffff current 0
fr_active min 0 max 0 current 0
fr_control_forwarding min 0 max 0×1 current 0
fr_update_ipid min 0 max 0×1 current 0
fr_chksrc min 0 max 0×1 current 0
fr_minttl min 0 max 0×1 current 4
fr_icmpminfragmtu min 0 max 0×1 current 68
fr_pass min 0 max 0xffffffff current 134217730
fr_tcpidletimeout min 0×1 max 0x7fffffff current 7200*
fr_tcpclosewait min 0×1 max 0x7fffffff current 60*
fr_tcplastack min 0×1 max 0x7fffffff current 120*
fr_tcptimeout min 0×1 max 0x7fffffff current 180*
fr_tcpclosed min 0×1 max 0x7fffffff current 60*
fr_tcphalfclosed min 0×1 max 0x7fffffff current 300*
fr_udptimeout min 0×1 max 0x7fffffff current 90*
fr_udpacktimeout min 0×1 max 0x7fffffff current 24
fr_icmptimeout min 0×1 max 0x7fffffff current 35*
fr_icmpacktimeout min 0×1 max 0x7fffffff current 12
fr_iptimeout min 0×1 max 0x7fffffff current 120
fr_statemax min 0×1 max 0x7fffffff current 8039*
fr_statesize min 0×1 max 0x7fffffff current 11471*
fr_state_lock min 0 max 0×1 current 0
fr_state_maxbucket min 0×1 max 0x7fffffff current 28
fr_state_maxbucket_reset min 0 max 0×1 current 1
ipstate_logging min 0 max 0×1 current 1
fr_nat_lock min 0 max 0×1 current 0
ipf_nattable_sz min 0×1 max 0x7fffffff current 30011*
ipf_nattable_max min 0×1 max 0x7fffffff current 300000*
ipf_natrules_sz min 0×1 max 0x7fffffff current 127
ipf_rdrrules_sz min 0×1 max 0x7fffffff current 127
ipf_hostmap_sz min 0×1 max 0x7fffffff current 2047
fr_nat_maxbucket min 0×1 max 0x7fffffff current 30
fr_nat_maxbucket_reset min 0 max 0×1 current 1
nat_logging min 0 max 0×1 current 1
fr_defnatage min 0×1 max 0x7fffffff current 1200
fr_defnatipage min 0×1 max 0x7fffffff current 120
fr_defnaticmpage min 0×1 max 0x7fffffff current 6
ipfr_size min 0×1 max 0x7fffffff current 257
fr_ipfrttl min 0×1 max 0x7fffffff current 120
ipl_suppress min 0 max 0×1 current 1
ipl_buffer_sz min 0 max 0 current 0
ipl_logmax min 0 max 0x7fffffff current 7
ipl_logall min 0 max 0×1 current 0
ipl_logsize min 0 max 0×80000 current 8192
ippr_ftp_debug min 0 max 0xa current 0
打*号表示已经修改过了。

由于使用了ipf -D 的参数,ipf的过滤规则和NAT规则都已清除。所以需要重新加载:
ipf -f /etc/ipf.rules
ipnat -f /etc/ipnat.rules

修改后可以大大地减少网络堵塞的机会。
_________________

原文地址:

http://www.freebsdchina.org/forum/viewtopic.php?t=38611

分类: BSD/linux 标签: ,

缓存测试

2006年6月14日 16hot 2 条评论

终于,终于在今天弄好三台在一个交换机下的服务器来测试缓存了。

现在分别是FreeBSD 6.1,Redhat AS 4,Debian 3.1。

sqiud运行在FreeBSD上,Redhat作为polysvr,Debian作为polyclt。

从运行情况来看,最高并发连接1.8万。之后没有多久,mbuf满了,中断测试。

不过命中率似乎还不太理想,内存命中80%左右,5min命中,5%。

另外还是出现内存使用太大后,提示xcalloc错误,然后就自动重启squid。

2006/06/14 16:39:34| Ready to serve requests.
2006/06/14 16:39:34| Finished rebuilding storage from disk.
2006/06/14 16:39:34| 0 Entries scanned
2006/06/14 16:39:34| 0 Invalid entries.
2006/06/14 16:39:34| 0 With invalid flags.
2006/06/14 16:39:34| 0 Objects loaded.
2006/06/14 16:39:34| 0 Objects expired.
2006/06/14 16:39:34| 0 Objects cancelled.
2006/06/14 16:39:34| 0 Duplicate URLs purged.
2006/06/14 16:39:34| 0 Swapfile clashes avoided.
2006/06/14 16:39:34| Took 0.0 seconds ( 0.0 objects/sec).
2006/06/14 16:39:34| Beginning Validation Procedure
2006/06/14 16:39:34| Completed Validation Procedure
2006/06/14 16:39:34| Validated 0 Entries
2006/06/14 16:39:34| store_swap_size = 0k
2006/06/14 16:39:35| storeLateRelease: released 0 objects
FATAL: xcalloc: Unable to allocate 1 blocks of 4108 bytes!

Squid Cache (Version 2.5.STABLE14): Terminated abnormally.
CPU Usage: 214.289 seconds = 73.790 user + 140.499 sys
Maximum Resident Size: 1577032 KB
Page faults with physical i/o: 0

分类: BSD/linux 标签: , ,