-
Notifications
You must be signed in to change notification settings - Fork 1
/
cidr2subnetmask
executable file
·39 lines (38 loc) · 1.19 KB
/
cidr2subnetmask
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /bin/bash
while read line
do
echo "$line" | \
sed 's/\/32/ 255.255.255.255/g' | \
sed 's/\/31/ 255.255.255.254/g' | \
sed 's/\/30/ 255.255.255.252/g' | \
sed 's/\/29/ 255.255.255.248/g' | \
sed 's/\/28/ 255.255.255.240/g' | \
sed 's/\/27/ 255.255.255.224/g' | \
sed 's/\/26/ 255.255.255.192/g' | \
sed 's/\/25/ 255.255.255.128/g' | \
sed 's/\/24/ 255.255.255.0/g' | \
sed 's/\/23/ 255.255.254.0/g' | \
sed 's/\/22/ 255.255.252.0/g' | \
sed 's/\/21/ 255.255.248.0/g' | \
sed 's/\/20/ 255.255.240.0/g' | \
sed 's/\/19/ 255.255.224.0/g' | \
sed 's/\/18/ 255.255.192.0/g' | \
sed 's/\/17/ 255.255.128.0/g' | \
sed 's/\/16/ 255.255.0.0/g' | \
sed 's/\/15/ 255.254.0.0/g' | \
sed 's/\/14/ 255.252.0.0/g' | \
sed 's/\/13/ 255.248.0.0/g' | \
sed 's/\/12/ 255.240.0.0/g' | \
sed 's/\/11/ 255.224.0.0/g' | \
sed 's/\/10/ 255.192.0.0/g' | \
sed 's/\/9/ 255.128.0.0/g' | \
sed 's/\/8/ 255.0.0.0/g' | \
sed 's/\/7/ 254.0.0.0/g' | \
sed 's/\/6/ 252.0.0.0/g' | \
sed 's/\/5/ 248.0.0.0/g' | \
sed 's/\/4/ 240.0.0.0/g' | \
sed 's/\/3/ 224.0.0.0/g' | \
sed 's/\/2/ 192.0.0.0/g' | \
sed 's/\/1/ 128.0.0.0/g' | \
sed 's/\/0/ 0.0.0.0/g'
done < "${1:-/dev/stdin}"