各OSごとにIPv6のネットワーク設定に違いが大きく、プロトコルにIPv6を指定する場合、-inet6, ipv6 などいろいろとあり、複数のOSを扱っていると混乱するので、まとめる。
format
/sbin/ip -6 <OBJECT> /sbin/ip -f inet6 <OBJECT>
example
show routing table
$ /sbin/ip -6 route list fe80::/64 dev eth0.305 proto kernel metric 256 default via fe80::1 dev eth0.305 metric 1
$ /sbin/ip -f inet6 route list fe80::/64 dev eth0.305 proto kernel metric 256 default via fe80::1 dev eth0.305 metric 1
add static route
# /sbin/ip -6 a add 2001:db8::1/64 dev eth2 # ip -6 a l dev eth2 3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000 inet6 2001:db8::1/64 scope global valid_lft forever preferred_lft forever inet6 fe80::250:56ff:fe3d:d9b2/64 scope link valid_lft forever preferred_lft forever
format
/sbin/ifconfig <interface> inet6 [add|del] <ipv6address>/<prefixlength>
example
/sbin/ifconfig eth2 inet6 add 2001:db8::1/64 /sbin/ifconfig eth2 inet6 del 2001:db8::1/64
format
/sbin/route -A inet6 /sbin/route -A inet6 [add|del] <ipv6address>/<prefixlength> gw <ipv6gateway>
example
add static route
# /sbin/route -A inet6 add 2001:db8:100::/48 gw 2001:db8::2 # /sbin/route -A inet6 del 2001:db8:100::/48 # /sbin/route -A inet6 del 2001:db8:100::/48 gw 2001:db8::2
show routing table
$ /sbin/route -A inet6 Kernel IPv6 routing table Destination Next Hop Flags Metric Ref Use Iface 2001:db8::/64 * U 256 0 0 eth2 fe80::/64 * U 256 0 0 eth2 */0 fe80::1 UGDA 1024 0 0 eth2 localhost/128 * U 0 810 1 lo 2001:db8::1/128 * U 0 0 1 lo 2001:db8:100::/48 2001:db8::2 UG 1 0 0 eth2 fe80::20c:29ff:feb9:b7b4/128 * U 0 936348 1 lo fe80::250:56ff:fe3d:d9b2/128 * U 0 0 1 lo ff00::/8 * U 256 0 0 eth1
format
# ifconfig <interface> inet6 <ipv6address>/<prefixlength> or # ifconfig en0 inet6 <ipv6address> prefixlen <prefixlength> # ifconfig <interface> inet6 <ipv6address>/<prefixlength> delete or # ifconfig en0 inet6 <ipv6address> prefixlen <prefixlength> delete
IPv6 では、
# ifconfig <interface> inet6 <ipv6address>/<prefixlength> -alias
をつけても同じ挙動(aliasという概念がない)
example
# ifconfig en0 inet6 2001:db8::1/64 # ifconfig en0 inet6 2001:db8::3 prefixren 64 # ifconfig en0 inet6 2001:db8::1/64 delete # ifconfig en0 inet6 2001:db8::3 prefixren 64 delete
format
# route [add|delete] -inet6 <ipv6address>/<prefixlength> <ipv6gateway>
example
# route add -inet6 2001:db8:100::/48 2001:db8::1 # route delete -inet6 2001:db8:100::/48 2001:db8::1