netmask可以在 IP范围、子网掩码、cidr、cisco等格式中互相转换,并且提供了IP地址的点分十进制、16进制、8进制、2进制之间的互相转换!
netmaks -h
This is netmask, an address netmask generation utility
Usage: netmask spec [spec ...]
-h, --help Print a summary of the options
-v, --version Print the version number
-d, --debug Print status/progress information
-s, --standard Output address/netmask pairs(转换到标准的 ip地址/子网掩码)
-c, --cidr Output CIDR format address lists(转换到CIDR格式)
-i, --cisco Output Cisco style address lists(转换到Cisco反向子网掩码)
-r, --range Output ip address ranges(转换到IP地址范围)
-x, --hex Output address/netmask pairs in hex(转换到16进制)
-o, --octal Output address/netmask pairs in octal(转换到10进制)
-b, --binary Output address/netmask pairs in binary(转换到2进制)
-n, --nodns Disable DNS lookups for addresses
-f, --files Treat arguments as input files
Definitions:
a spec can be any of:
address 单独IP
address:address 开始IP:结束IP
address:+address 开始IP:+IP个数
address/mask IP/掩码
an address can be any of:
N decimal number
0N octal number
0xN hex number
N.N.N.N dotted quad
hostname dns domain name
a mask is the number of bits set to one from the left
使用情况如下:
ip范围转换到cidr格式
netmask -c 192.168.0.0:192.168.2.255
192.168.0.0/23
192.168.2.0/24
ip范围转换到标准的子网掩码格式
netmask -s 192.168.0.0:192.168.2.255
192.168.0.0/255.255.254.0
192.168.2.0/255.255.255.0
ip范围转换到cisco格式
netmask -i 192.168.0.0:192.168.2.255
192.168.0.0 0.0.1.255
192.168.2.0 0.0.0.255
cidr个数转换到ip范围格式
netmask -r 192.168.0.0/23
192.168.0.0-192.168.1.255 (512)
把点分10进制的ip转换到二进制
netmask -b 192.168.0.0
11000000 10101000 00000000 00000000 / 11111111 11111111 11111111 11111111