-
Notifications
You must be signed in to change notification settings - Fork 0
iptool subnet split
The iptool subnet split command can be used to split a network of any size into smaller subnets.
Choose to create networks of a given size (ex, --bits 30) or the number of subnets to split the network into (ex, --networks 4)
Use the iptool subnet split to see the available options.
Usage:
iptool subnet split <subnet> [flags]
Flags:
-b, --bits int subnet size in bits for network division
-c, --csv output in CSV format
-h, --help help for split
-l, --limit int limit the number of subnets in the output
-n, --networks int number of subnets to divide the network into
-o, --output-file string write output to file
As an example we can split a network 10.192.16.0/24 into smaller /30 subnets using the --bits (or -b) argument.
Command
iptool subnet split 10.192.16.0/24 --bits 30
Output
This will print all 64 subnets in sequence. Note: the output is truncated
Prefix Network First Last Broadcast Hosts
-----------------------------------------------------------------------------------
10.192.16.0/30 10.192.16.0 10.192.16.1 10.192.16.2 10.192.16.3 2
10.192.16.4/30 10.192.16.4 10.192.16.5 10.192.16.6 10.192.16.7 2
10.192.16.8/30 10.192.16.8 10.192.16.9 10.192.16.10 10.192.16.11 2
...
10.192.16.244/30 10.192.16.244 10.192.16.245 10.192.16.246 10.192.16.247 2
10.192.16.248/30 10.192.16.248 10.192.16.249 10.192.16.250 10.192.16.251 2
10.192.16.252/30 10.192.16.252 10.192.16.253 10.192.16.254 10.192.16.255 2
Use the --limit (or -l) argument to limit the number of subnets output. This way we can display only the first number of subnets in case there are many.
Command
iptool subnet split 10.192.16.0/24 --bits 30 --limit 4
Output
Prefix Network First Last Broadcast Hosts
-----------------------------------------------------------------------------------
10.192.16.0/30 10.192.16.0 10.192.16.1 10.192.16.2 10.192.16.3 2
10.192.16.4/30 10.192.16.4 10.192.16.5 10.192.16.6 10.192.16.7 2
10.192.16.8/30 10.192.16.8 10.192.16.9 10.192.16.10 10.192.16.11 2
10.192.16.12/30 10.192.16.12 10.192.16.13 10.192.16.14 10.192.16.15 2
Use the --networks (or -n) argument to split the given network into a number of subnets.
Command
iptool subnet split 10.192.16.0/24 --networks 4
Output
Prefix Network First Last Broadcast Hosts
-----------------------------------------------------------------------------------
10.192.16.0/26 10.192.16.0 10.192.16.1 10.192.16.62 10.192.16.63 62
10.192.16.64/26 10.192.16.64 10.192.16.65 10.192.16.126 10.192.16.127 62
10.192.16.128/26 10.192.16.128 10.192.16.129 10.192.16.190 10.192.16.191 62
10.192.16.192/26 10.192.16.192 10.192.16.193 10.192.16.254 10.192.16.255 62
Use the --csv (or -c) flag to format the output in CSV format.
Command
iptool subnet split 10.192.16.0/24 --networks 4 --csv
Output
prefix,network,first,last,broadcast,hosts
10.192.16.0/26,10.192.16.0,10.192.16.1,10.192.16.62,10.192.16.63,62
10.192.16.64/26,10.192.16.64,10.192.16.65,10.192.16.126,10.192.16.127,62
10.192.16.128/26,10.192.16.128,10.192.16.129,10.192.16.190,10.192.16.191,62
10.192.16.192/26,10.192.16.192,10.192.16.193,10.192.16.254,10.192.16.255,62
Use the --output-file (or -o) argument to redirect the output to a file.
Command
iptool subnet split 10.192.16.0/24 --networks 4 --csv --output-file test.txt
Note: No output is displayed in the terminal when using this argument.