可以使用 ifconfig 命令对IPv6 接口和隧道连接模块进行检测。ifconfig 使用一组经过扩展的 ioctl 来配置 IPv4 和 IPv6 网络接口。下面描述了可支持 IPv6 操作的 ifconfig 选项。有关涉及 ifconfig 命令的一系列 IPv4 和 IPv6 任务,请参见使用 ifconfig 命令监视接口配置。
设置接口索引。
设置隧道源或目标。
创建下一个可用的逻辑接口。
删除具有特定 IP 地址的逻辑接口。
设置接口的点对点目标地址。
为接口设置地址和/或网络掩码。
设置接口的子网地址。
启用或禁用在接口上传输包。
第 7 章介绍了 IPv6 配置过程。
以下形式的 ifconfig 命令可创建 hme0:3 逻辑接口:
# ifconfig hme0 inet6 addif up Created new logical interface hme0:3 |
以下形式的 ifconfig 可验证是否创建了新接口:
# ifconfig hme0:3 inet6 hme0:3: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2 inet6 inet6 fe80::203:baff:fe11:b321/10 |
以下形式的 ifconfig 命令可删除 hme0:3 逻辑接口:
# ifconfig hme0:3 inet6 down # ifconfig hme0 inet6 removeif 1234::5678 |
# ifconfig ip.tun0 inet6 plumb index 13 |
打开要与物理接口名称相关联的隧道。
# ifconfig ip.tun0 inet6 ip.tun0: flags=2200850<POINTOPOINT,RUNNING,MULTICAST,NONUD, #IPv6> mtu 1480 index 13 inet tunnel src 0.0.0.0 inet6 fe80::/10 --> :: |
配置 TCP/IP 使用隧道设备并报告设备状态所需要的流。
# ifconfig ip.tun0 inet6 tsrc 120.46.86.158 tdst 120.46.86.122 |
配置隧道的源地址和目标地址。
# ifconfig ip.tun0 inet6 ip.tun0: flags=2200850<POINTOPOINT,RUNNING,MULTICAST,NONUD, IPv6> mtu 1480 index 13 inet tunnel src 120.46.86.158 tunnel dst 120.46.86.122 inet6 fe80::8192:569e/10 --> fe80::8192:567a |
在配置之后报告设备的新状态。
以下示例显示在 6to4 伪接口配置中子网 ID 为 1,并以十六进制形式指定主机 ID。
# ifconfig ip.6to4tun0 inet6 plumb # ifconfig ip.6to4tun0 inet tsrc 129.146.86.187 \ 2002:8192:56bb:1::8192:56bb/64 up |
# ifconfig ip.6to4tun0 inet6 ip.6to4tun0: flags=2200041<UP,RUNNING,NONUD,IPv6>mtu 1480 index 11 inet tunnel src 129.146.86.187 tunnel hop limit 60 inet6 2002:8192:56bb:1::8192:56bb/64 |
以下示例显示了配置 6to4 隧道的短格式:
# ifconfig ip.6to4tun0 inet6 plumb # ifconfig ip.6to4tun0 inet tsrc 129.146.86.187 up |
# ifconfig ip.6to4tun0 inet6 ip.6to4tun0: flags=2200041<UP,RUNNING,NONUD,IPv6>mtu 1480 index 11 inet tunnel src 129.146.86.187 tunnel hop limit 60 inet6 2002:8192:56bb::1/64 |