IP address management

1. IP related concepts

  • They uniquely identify every device in an IP network
  • Each host (computer, network device, peripheral) must have a unique address
  1. An IP address consists of two parts:      
                Network ID:
                        Identify the network
                        Each network segment is assigned a network ID
                Host ID:
                        Identify a single host
                        Assigned to each device by the organization

         2. IP address classification (IPv4 32-bit)

             Class A:
               0 000 0000 - 0 111 1111: 0-127 The first eight bits represent the Class A network ID, the first 0 is fixed, and the other seven are variable
               Number of networks: 128 where 0.0.0.0 represents the local address and 127.0.0.1 represents the local loopback address, so the 0.xxx and 127.xxx network segments cannot be assigned to other hosts, and the available network segments are 1-126
               The number of hosts in each network: 2^24-2 The x.0.0.0  address (representing the network segment number) and the x.255.255.255 address (representing the broadcast address of this network segment) in each network segment cannot be assigned
               Default subnet mask: 255.0.0.0
               Private network address: 10.0.0.0
            Class B:
              10 00 0000 - 10 11 1111: 128-191 The first sixteen bits represent the network ID, of which the first two bits are 10 fixed, and the other fourteen bits are variable
              Number of networks: 2^14
              Number of hosts in each network: 2^16-2
              Default subnet mask: 255.255.0.0
              Private network address: 172.16.0.0-172.31.0.0
           Class C:
              110 0 0000 - 110 1 1111: 192-223 The first 24 bits represent the network ID, of which the first three bits are 110 fixed, and the remaining 21 bits are variable
              Number of networks: 2^21
              Number of hosts in each network: 2^8-2
              Default subnet mask: 255.255.255.0
              Private network address: 192.168.0.0-192.168.255.0
           Class D: Multicast (cannot be used by the host)
              1110 0000 - 1110 1111: 224-239
           Class E: (reserved address)
              240-255
           Special address:
             0.0.0.0
                 0.0.0.0 is not really an IP address. It represents a set: all unknown hosts and destination networks.
             255.255.255.255
                 Restrict broadcast addresses. For this machine, this address refers to all hosts in this network segment (the same broadcast domain).
             127.0.0.1~127.255.255.254
                 The loopback address of the machine is mainly used for testing. A packet with a destination address of "127.0.0.1" should never appear on the transmission medium.
             224.0.0.0 to 239.255.255.255
                 Multicast address, 224.0.0.1 refers to all hosts, 224.0.0.2 refers to all routers. 224.0.0.5 refers to the OSPF router, the address is mostly used for some specific programs and multimedia programs
             169.254.x.x
               If the Windows host uses DHCP to automatically assign an IP address and cannot obtain an address from the DHCP server, the system will assign such an address to the host
 
       3. Classless network addresses (IP addresses are not classified by category, i.e. network ID, host ID is uncertain; breaking the limitations of classful addresses)
                
             CIDR: Classless Inter-Domain Routing Representation IP/Network ID bits
             netmask (subnet mask): 32-bit binary number, the number of network ID bits, the corresponding bit of netmask is 1, the number of host ID bits, and the corresponding bit of netmask is 0; that is, netmask can determine the number of bits of network ID, usually expressed in decimal
                        10000000:128 ;11000000:192;11100000:224;11110000:240;11111000:248;11111100:252;11111110:254;11111111:255
             Subnet division: A large network (with more host ID bits and fewer network ID bits) is divided into multiple small networks (with fewer host ID bits and more network ID bits), and the network ID bits borrow N bits from the host ID bits. , divided into 2^N small nets
             Merge supernet: multiple small networks are merged into a large network, the host ID bit is borrowed from the network ID bit (optimized routing table IP address management)
       
        4. Calculation formula
       
             1)网络(网段)数量=2^可变网络ID位数
             2)一个网络的主机数量=2^主机ID位数-2=2^(32-网络ID位数)-2
             3)网络ID=IP与子网掩码netmask (ip 和 子网掩码进行二进制与运算)
             4)  划分子网数=划分成2^N个(网络ID位向主机ID位借N位)

二. 例题

          1.  200.222.123.23/26
                  1)netmask? 255.255.255.192
                  2)主机数?2^(32-26)-2=62
          2. 求 A 172.20.222.123/20 和B 172.20.230.100/20 的netid(网络ID)
                  解题思路: 将A 和 B网络转化位二进制表示,并与11111111.11111111.11110000.00000000做与运算
                  结果: A:netid=172.20.208.0      B:netid=172.20.224.0
          3.  A 192.168.1.100/16 与 B 192.168.2.100/24 是否在同一网段?
               A-->B :A访问B时,并不知道B网络的子网掩码,默认按自己的子网掩码判断是否处于同一网段;结论:在同一网段
               B-->A: B访问A时,并不知道A网络的子网掩码,默认按自己的子网掩码判断是否处于同一网段;结论:不在同一网段
          4. 192.168.199.111/21
             1) 网络ID:192.168.192.0            
             2) netmask:255.255.248.0
             3) 主机数:2^11-2=2046
             4) min ip,max ip (主机ID全为0或全为1要排除)
                  192.168.11000 000.00000001 192.168.192.1/21
                  192.168.11000 111.11111110 192.168.199.254/21
          5.  222.111.188.123  netmask:255.255.255.192
             1)网络ID:222.111.188.64
             2)CIDR:222.111.188.123/26
             3)主机数:2^(32-26)-2=62
             4)Min IP,222.111.188.65 Max IP:222.111.188 126
                        222.111.188.01 000001 222.111.188.65
                        222.111.188.01 111110 222.111.188 126
          6. 10.0.0.0/8 划分32个子网给32个省公司使用
            1)新的子网netmask:255.248.0.0
                        32=2^N
                        N=5
                        新子网网络ID位数:8+5=13
                        255.248.0.0
            2) 新的子网:min netid,max netid
                 10.00000 000.0.0 10.0.0.0/13 min netid
                 10.11111 000.0.0 10.248.0.0/13 max netid
            3) 新的子网存放最多的主机数是多少?
                主机ID=32-13=19
                2^19-2=52万
            4)max netid IP:min ip ,max ip ?
               10.11111 000.0.1           minip:10.248.0.1
               10.11111 111.255.254   maxip:10.255.255.254
          7.  河南省10.248.0.0/13,划分17个子网给17个地市使用
            1)新的子网netmask:255.255.11000000.0    255.255.192.0
                    新子网网数位数:
                             2^N>=17,N=5
            2) 新的子网:min netid,max netid
                   10.11111 000.00 000000.0  10.248.0.0/18  1
                   10.11111 100.00 000000.0  10.252.0.0/18  17    第17个子网
                   10.11111 111.11 000000.0  10.255.192.0/18
            3) 新的子网存放最多的主机数是多少?
                  主机ID位=32-18=14
                  2^14-2=16000
            4)max netid IP:min ip ,max ip ?
                  10.252.0.0/18
                  10.11111 100.00 000000.1                minip:10.252.0.1/18
                  10.11111 100.00 111111.11111110  maxip:10.252.63.254/18
          8.  合并 192.168.000000 01.0/24 ;192.168.000000 10.0/24 子网
                   192.168.0.0/22

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325104149&siteId=291194637