IPv6 subnetting in command line with sipcalc

I had to put my hands on my IPv6 network after lots of years… my memories are not so good…how to subnet a IPv6 network in command line?

What to do

I need to generate a pool of network /64, /60, /56 and /48 to assign to new customers from larger CIDR. Quickly and without painass.

Sipcalc

Sipcalc it’s an amazing tool for IPv4 and IPv6 calculations.

From the manpage I found a perfect option to do this:

* -S, --v6split=MASK (IPv6)
  Split the current network into subnets of MASK size. MASK must be given in
  CIDR form, either with or with the '/' character.

Problem

For example, I have a /48 network and I want to split into /56

> sipcalc -u 2a01:b600:4000::/48 -S 56 |head -n 50

-[ipv6 : 2a01:b600:4000::/48] - 0

[Split network - verbose]
-[ipv6 : 2a01:b600:4000::/48] - 0

[IPV6 INFO]
Expanded Address        - 2a01:b600:4000:0000:0000:0000:0000:0000
Compressed address      - 2a01:b600:4000::
Subnet prefix (masked)  - 2a01:b600:4000:0:0:0:0:0/56
Address ID (masked)     - 0:0:0:0:0:0:0:0/56
Prefix address          - ffff:ffff:ffff:ff00:0:0:0:0
Prefix length           - 56
Address type            - Aggregatable Global Unicast Addresses
Network range           - 2a01:b600:4000:0000:0000:0000:0000:0000 -
                          2a01:b600:4000:00ff:ffff:ffff:ffff:ffff

-
-[ipv6 : 2a01:b600:4000::/48] - 0

[IPV6 INFO]
Expanded Address        - 2a01:b600:4000:0100:0000:0000:0000:0000
Compressed address      - 2a01:b600:4000💯:
Subnet prefix (masked)  - 2a01:b600:4000💯0:0:0:0/56
Address ID (masked)     - 0:0:0:0:0:0:0:0/56
Prefix address          - ffff:ffff:ffff:ff00:0:0:0:0
Prefix length           - 56
Address type            - Aggregatable Global Unicast Addresses
Network range           - 2a01:b600:4000:0100:0000:0000:0000:0000 -
                          2a01:b600:4000:01ff:ffff:ffff:ffff:ffff

-
-[ipv6 : 2a01:b600:4000::/48] - 0

[IPV6 INFO]
Expanded Address        - 2a01:b600:4000:0200:0000:0000:0000:0000
Compressed address      - 2a01:b600:4000:200::
Subnet prefix (masked)  - 2a01:b600:4000:200:0:0:0:0/56
Address ID (masked)     - 0:0:0:0:0:0:0:0/56
Prefix address          - ffff:ffff:ffff:ff00:0:0:0:0
Prefix length           - 56
Address type            - Aggregatable Global Unicast Addresses
Network range           - 2a01:b600:4000:0200:0000:0000:0000:0000 -
                          2a01:b600:4000:02ff:ffff:ffff:ffff:ffff

As you can see the result are the /48 network splitted with lots of info that can be useful or not.

As i need only the IPv6 address generated with the CIDR this is a output more useful (in this example the first 10 nets):

> sipcalc -u 2a01:b600:4000::/48 -S 56|grep 'prefix'|head -n 10
Subnet prefix (masked)  - 2a01:b600:4000:0:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000💯0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:200:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:300:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:400:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:500:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:600:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:700:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:800:0:0:0:0/56
Subnet prefix (masked)  - 2a01:b600:4000:900:0:0:0:0/56

It’s done. You can generate all type of network split you want modifying the network size and split size.

Thanks for reading!

Matteo Sgalaberni
Matteo Sgalaberni
CTO Ehiweb.it / CEO Ovus.it

IT-Telco/System/Network Admin