如果你不是很熟悉網(wǎng)絡(luò)掩碼計(jì)算,每次要從一個(gè)IP和掩碼中得到有效的IP地址總是很煩人,要推算好幾次。
一個(gè)小工具IPgen,可以根據(jù)掩碼生成有效IP地址。
項(xiàng)目地址:
https://github.com/royhills/ipgen
來自:
Man手冊
The IP networks can be specified in the following ways:
a) CIDR notation IPnetwork/bits (e.g. 192.168.1.0/24)
b) Network and mask notation IPnetwork:NetMask (e.g. 192.168.1.0:255.255.255.0)
c) Range notation IPstart-IPend (e.g. 192.168.1.3-192.168.1.27)
d) Single IP Host Address (e.g. 192.168.1.1)
The CIDR and Network:mask notations generate IP host addresses excluding the
network and broadcast addresses. So 10.0.0.0/29 would generate six IP addresses
from 10.0.0.1 to 10.0.0.6 inclusive. But see the description of the --network
(-n) and --broadcast (-b) options below.
The generated IP host addresses are written to standard output, with one IP
address per line.
The IP networks may be specified either on the command line, or read from the
file specified with the --file (-f) option.
Options:
--help or -h Display this usage message and exit.
--file=<f> or -f <f> Read IP networks from the specified file instead of
from the command line. One IP network specification per
line. Use "-" for standard input.
--version or -V Display program version and exit.
--network or -n Include the IP network address.
--broadcast or -b Include the IP broadcast address.
常用命令
我已經(jīng)有一個(gè)地址192.168.10.139,需要新的地址段,擴(kuò)大到8個(gè)地址,要在29位掩碼范圍內(nèi)。
ftpuser@hwcgback:~/ipgen$ ipgen 192.168.10.139/29 -b -n
WARNING: host part of 192.168.10.139/29 is non-zero
192.168.10.136
192.168.10.137
192.168.10.138
192.168.10.139
192.168.10.140
192.168.10.141
192.168.10.142
192.168.10.143
還可以用掩碼方式
ftpuser@hwcgback:~/ipgen$ ipgen 192.168.10.139:255.255.255.248 -b -n
WARNING: host part of 192.168.10.139:255.255.255.248 is non-zero
192.168.10.136
192.168.10.137
192.168.10.138
192.168.10.139
192.168.10.140
192.168.10.141
192.168.10.142
192.168.10.143