jeudi 23 avril 2015

Bourne shell - convert IP range into set of subnets

I'm looking for a function in Bourne shell to convert a given range of IPs in the format "sIP-dIP" into a usable set of subnets that defines the very same range. What I'm looking for precisely it's the very same result of the IP Range function provided at this site: http://ift.tt/1uKLdKm

example:

Given:

10.0.0.6-10.10.1.34:

Result:

10.0.0.6/31
10.0.0.8/29
10.0.0.16/28
10.0.0.32/27
10.0.0.64/26
10.0.0.128/25
10.0.1.0/24
10.0.2.0/23
10.0.4.0/22
10.0.8.0/21
10.0.16.0/20
10.0.32.0/19
10.0.64.0/18
10.0.128.0/17
10.1.0.0/16
10.2.0.0/15
10.4.0.0/14
10.8.0.0/15
10.10.0.0/24
10.10.1.0/27
10.10.1.32/31
10.10.1.34/32 

I have seen many examples around but they are all for bash, C or phyton, but I'm on busybox with Bourne shell.

Can anybody please provide some inputs?

Many thanks!

Aucun commentaire:

Enregistrer un commentaire