目次

Top#ネットワークの基礎知識に戻る

IPアドレスの基礎知識



IPアドレス計算サイト

CMAN サブネットマスク計算(IPv4) IPアドレスとサブネットマスクを入力することで、ホストアドレスなどを計算してくれます。


プライベートIPアドレス

Class CIDR Start End Number of addresses Example
A 10.0.0.0/8 10.0.0.0 10.255.255.255 16,777,216 10.0.0.0/24
10.0.1.0/24
10.1.0.0/24
10.2.0.0/24
B 172.16.0.0/12 172.16.0.0 172.31.255.255 1,048,576 172.16.0.0/24
172.16.1.0/24
172.17.0.0/24
C 192.168.0.0/16 192.168.0.0 192.168.255.255 65,536 192.168.0.0/24
192.168.1.0/24
Class A = 10.0.0.0/8
Class B = 172.16.0.0/12
Class C = 192.168.0.0/16


IPv4 CIDR

CIDR Mask Hosts the number of available host
/32 255.255.255.255 1 -
/31 255.255.255.254 2 0
/30 255.255.255.252 4 2
/29 255.255.255.248 8 6
/28 255.255.255.240 16 14
/27 255.255.255.224 32 30
/26 255.255.255.192 64 62
/25 255.255.255.128 128 126
/24 255.255.255.0 256 254
/23 255.255.254.0 512 510
/22 255.255.252.0 1,024 1,022
/21 255.255.248.0 2,048 2,046
/20 255.255.240.0 4,096 4,094
/19 255.255.224.0 8,192 8,190
/18 255.255.192.0 16,384 16,382
/17 255.255.128.0 32,768 32,766
/16 255.255.0.0 131,072 131,070
/8 255.0.0.0 16,777,216 16,777,214
/23 /24 /25 /26 /27 /28 /29 /30
255.255.254.0 255.255.255.0 255.255.255.128 255.255.255.192 255.255.255.224 255.255.255.240 255.255.255.248 255.255.255.252
510 254 126 62 30 14 6 2
10.1.0.0 10.1.0.0 10.1.0.0 10.1.0.0 10.1.0.0
10.1.0.32
10.1.0.64 10.1.0.64
10.1.0.96
10.1.0.128 10.1.0.128 10.1.0.128
10.1.0.160
10.1.0.192 10.1.0.192
10.1.0.224
10.1.1.0 10.1.1.0 10.1.1.0 10.1.1.0
10.1.1.32
10.1.1.64 10.1.1.64
10.1.1.96
10.1.1.128 10.1.1.128 10.1.1.128
10.1.1.160
10.1.1.192 10.1.1.192
10.1.1.224
10.1.2.0 10.1.2.0
/30 /29 /28 /27
192.168.0.X 2 6 14 30
0 the network itself the network itself the network itself the network itself
1 host1 host1 host1 host1
2 host2 host2 host2 host2
3 broadcast address host3 host3 host3
4 the network itself host4 host4 host4
5 host1 host5 host5 host5
6 host2 host6 host6 host6
7 broadcast address the network itself host7 host7
8 the network itself the network itself host8 host8
9 host1 host1 host9 host9
10 host2 host2 host10 host10
11 broadcast address host3 host11 host11
12 the network itself host4 host12 host12
13 host1 host5 host13 host13
14 host2 host6 host14 host14
15 broadcast address broadcast address broadcast address host15
16 the network itself the network itself the network itself host16
17 host1 host1 host1 host17
18 host2 host2 host2 host18
19 broadcast address host3 host3 host19
20 the network itself host4 host4 host20
21 host1 host5 host5 host21
22 host2 host6 host6 host22
23 broadcast address broadcast address host7 host23
24 the network itself the network itself host8 host24
25 host1 host1 host9 host25
26 host2 host2 host10 host26
27 broadcast address host3 host11 host27
28 the network itself host4 host12 host28
29 host1 host5 host13 host29
30 host2 host6 host14 host30
31 broadcast address broadcast address broadcast address broadcast address
abbr abbr abbr abbr abbr
240 the network itself the network itself the network itself
241 host1 host1 host1
242 host2 host2 host2
243 broadcast address host3 host3
244 the network itself host4 host4
245 host1 host5 host5
246 host2 host6 host6
247 broadcast address broadcast address host7
248 the network itself the network itself host8
249 host1 host1 host9
250 host2 host2 host10
251 broadcast address host3 host11
252 the network itself host4 host12
253 host1 host5 host13
254 host2 host6 host14
255 broadcast address broadcast address broadcast address

IP Design

Example
Location Segment Hosts Start-End Example
Location1 10.1.0.0/16 131,072 network itself : 10.1.0.0
Host : 10.1.0.1 - 10.1.255.254
broadcast : 10.1.255.255
10.1.0.0/24 (Hosts 256)
10.1.1.0/24 (Hosts 256)
10.1.255.0/24 (Hosts 256)
Location2 10.2.0.0/16 131,072 network itself : 10.2.0.0
Host : 10.2.0.1 - 10.2.255.254
broadcast : 10.2.255.255
10.2.0.0/24 (Hosts 256)
10.2.1.0/24 (Hosts 256)
10.2.255.0/24 (Hosts 256)
Location3 10.3.0.0/16 131,072 network itself : 10.3.0.0
Host : 10.3.0.1 - 10.3.255.254
broadcast : 10.3.255.255
10.3.0.0/24 (Hosts 256)
10.3.1.0/24 (Hosts 256)
10.3.255.0/24 (Hosts 256)
Location Segment Hosts Start-End Example
Location1 192.168.0.0/21 2,048 network itself : 192.168.0.0
Host : 192.168.0.1 - 192.168.7.254
broadcast : 192.168.7.255
192.168.0.0/24 (Hosts 256)
192.168.7.0/24 (Hosts 256)
Location2 192.168.8.0/21 2,048 network itself : 192.168.8.0
Host : 192.168.8.1 - 192.168.15.254
broadcast : 192.168.15.255
192.168.8.0/24 (Hosts 256)
192.168.15.0/24 (Hosts 256)
Location3 192.168.16.0/21 2,048 network itself : 192.168.16.0
Host : 192.168.16.1 - 192.168.23.254
broadcast : 192.168.23.255
192.168.20.0/24 (Hosts 256)
192.168.23.0/24 (Hosts 256)
Location Segment Hosts Start-End Example
Location1 192.168.0.0/24 256 network itself : 192.168.0.0
Host : 192.168.0.1 - 192.168.0.254
broadcast : 192.168.0.255
192.168.0.0/24 (Hosts 256)
Location2 192.168.1.0/24 256 network itself : 192.168.1.0
Host : 192.168.1.1 - 192.168.1.254
broadcast : 192.168.1.255
192.168.1.0/25 (Hosts 128 : 192.168.1.0-128)
192.168.1.128/25 (Hosts 128 : 192.168.1.128-255)
Location3 192.168.2.0/24 256 network itself : 192.168.2.0
Host : 192.168.2.1 - 192.168.2.254
broadcast : 192.168.2.255
192.168.3.0/26 (Hosts 64 : 192.168.2.0-63)
192.168.3.64/26 (Hosts 64 : 192.168.2.64-127)
192.168.3.128/26 (Hosts 64 : 192.168.2.128-191)
192.168.3.192/26 (Hosts 64 : 192.168.2.192-255)


IP計算Linuxコマンド

ipcalcコマンド

$ ipcalc -h
ipcalc: ip address expected
Usage: ipcalc [OPTION...]
  -c, --check         Validate IP address for specified address family
  -4, --ipv4          IPv4 address family (default)
  -6, --ipv6          IPv6 address family
  -b, --broadcast     Display calculated broadcast address
  -h, --hostname      Show hostname determined via DNS
  -m, --netmask       Display default netmask for IP (class A, B, or C)
  -n, --network       Display network address
  -p, --prefix        Display network prefix
  -s, --silent        Don't ever display error messages

Help options:
  -?, --help          Show this help message
  --usage             Display brief usage message
$

$ ipcalc -mnb 192.168.0.0/21
NETMASK=255.255.248.0
BROADCAST=192.168.7.255
NETWORK=192.168.0.0
$

$ ipcalc -n 192.168.0.0 255.255.248.0
$

$  ipcalc -p 192.168.0.0 255.255.248.0
PREFIX=21
$


perl-Net-IP

インストール

# yum install perl-Net-IP

ipcountコマンド

$ ipcount 192.168.0.0/21
      192.168.0/21        192.168.0.0 - 192.168.7.255   [2048]

iptabコマンド

$  iptab
+----------------------------------------------+
| addrs   bits   pref   class  mask            |
+----------------------------------------------+
|     1      0    /32          255.255.255.255 |
|     2      1    /31          255.255.255.254 |
|     4      2    /30          255.255.255.252 |
|     8      3    /29          255.255.255.248 |
|    16      4    /28          255.255.255.240 |
|    32      5    /27          255.255.255.224 |
|    64      6    /26          255.255.255.192 |
|   128      7    /25          255.255.255.128 |
|   256      8    /24      1C  255.255.255.0   |
|   512      9    /23      2C  255.255.254.0   |
|    1K     10    /22      4C  255.255.252.0   |
|    2K     11    /21      8C  255.255.248.0   |
|    4K     12    /20     16C  255.255.240.0   |
|    8K     13    /19     32C  255.255.224.0   |
|   16K     14    /18     64C  255.255.192.0   |
|   32K     15    /17    128C  255.255.128.0   |
|   64K     16    /16      1B  255.255.0.0     |
|  128K     17    /15      2B  255.254.0.0     |
|  256K     18    /14      4B  255.252.0.0     |
|  512K     19    /13      8B  255.248.0.0     |
|    1M     20    /12     16B  255.240.0.0     |
|    2M     21    /11     32B  255.224.0.0     |
|    4M     22    /10     64B  255.192.0.0     |
|    8M     23     /9    128B  255.128.0.0     |
|   16M     24     /8      1A  255.0.0.0       |
|   32M     25     /7      2A  254.0.0.0       |
|   64M     26     /6      4A  252.0.0.0       |
|  128M     27     /5      8A  248.0.0.0       |
|  256M     28     /4     16A  240.0.0.0       |
|  512M     29     /3     32A  224.0.0.0       |
| 1024M     30     /2     64A  192.0.0.0       |
| 2048M     31     /1    128A  128.0.0.0       |
| 4096M     32     /0    256A  0.0.0.0         |
+----------------------------------------------+




knowledge