06 March 2010

Calculating IPv6 Addresses

Problem:

Calculating IPv4 addresses was enough fun, and now you have these gigantic IPv6 addresses to manage. Is there a tool like ipcalc to help you make sure you get your addressing right?

Solution:

Yes, there is—ipv6calc. It’s easy to use, as the following examples show. This command analyzes whatever address you give it, both IPv4 and IPv6:

$ ipv6calc --showinfo -m FC00:0:0:1::
No input type specified, try autodetection...found type: ipv6addr
No output type specified, try autodetection...found type: ipv6addr
IPV6=fc00:0000:0000:0001:0000:0000:0000:0000
TYPE=unicast,unique-local-unicast
SLA=0001
IPV6_REGISTRY=reserved
IID=0000:0000:0000:0000
EUI64_SCOPE=local

This example compresses an IPv6 address:

$ ipv6calc --addr_to_compressed fc00:0000:0000:0001:0000:0000:0000:0000
fc00:0:0:1::

This example partly uncompresses an IPv6 address:

$ ipv6calc --addr_to_uncompressed fc00:0:0:1::
fc00:0:0:1:0:0:0:0
This example spells it out completely:

$ ipv6calc --addr_to_fulluncompressed fc00:0:0:1::
fc00:0000:0000:0001:0000:0000:0000:0000

ipv6calc will figure out your DNS PTR records for you, so you can
copy-and-paste them into your BIND zone files:

$ ipv6calc --out revnibbles.arpa fc00:0:0:1::
No input type specified, try autodetection...found type: ipv6addr
0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.c.f.ip6.arpa.

You can convert IPv6 prefixes to IPv4, and the reverse:

$ ipv6calc -q --action conv6to4 --in ipv4 192.168.1.10 --out ipv6
2002:c0a8:10a::

$ ipv6calc -q --action conv6to4 --in ipv6 2002:c0a8:aeb:: --out ipv4
192.168.10.235

See Also
man 8 ipv6calc

[*] Linux Networking Cookbook


biOos

No comments: