Last active
May 11, 2023 08:32
-
-
Save netravnen/6630bf498bded2074b6bae28fd909aa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
### | |
# | |
# Example input 100.64/10 -> 100.64.0.0 255.192.0.0 | |
# | |
# Split into /24's -> cidr 255.255.0.0 | |
# Split into /16's -> cidr 255.255.255.0 | |
# | |
# Replace cidr with relavant value, if splitting on non-classful boundaries | |
# | |
# Note: | |
# Depending on if you experience the output does not output the fill list, it could | |
# be necessary to use a nested loop to get the relevant ranges. If the final item | |
# count is large enough. | |
# | |
### | |
for supernet in $( | |
ipcalc -b 100.64.0.0 255.192.0.0 255.255.0.0 | | |
grep -P '^Network' | | |
grep -P -o '(\d+\.){3}\d+\/\d+'; | |
); do | |
for subnet in $( | |
ipcalc -b ${supernet} 255.255.0.0 255.255.255.0 | | |
grep -P '^Network' | | |
grep -P -o '(\d+\.){3}\d+\/\d+'; | |
); do | |
echo $subnet; | |
done | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
### | |
# | |
# Example input 100.64/10 -> 100.64.0.0 255.192.0.0 | |
# | |
# Split into /24's -> cidr 255.255.0.0 | |
# Split into /16's -> cidr 255.255.255.0 | |
# | |
# Replace cidr with relavant value, if splitting on non-classful boundaries | |
# | |
### | |
for subnet in $( | |
ipcalc -b 100.64.0.0 255.192.0.0 255.255.0.0 | | |
grep -P '^Network' | | |
grep -P -o '(\d+\.){3}\d+\/\d+'; | |
); do | |
echo $subnet; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment