About subnet mask, ip address, network id, number of hosts

Today interviewed a game company, which has a pen questions in the test subject to a network, the network as a graduate student, did not answer this question it is good ashamed, so write down notes to understand and see the future and firmly. Topics are as follows:


A computer ip is 192.168.10.35, subnet mask of 255.255.255.240, the computer network id ask where is the number, the maximum number of hosts on your network is how much, how much is the broadcast address?


Let us not to answer the question head, take a look at the basic concepts.

A class of ip: 1.0.0.0 to 127.255.255.255
Class B ip of: 128.0.0.0 to 191.255.255.255
Class C ip of: 192.0.0.0 to 223.255.255.255

Class C, 192.168.144.60
192.168.144 network number is
60 is host number

To the same segment,
as long as the same network identification on it,
that you want to see how the network identifiers? First thing to do is to convert each piece of IP is binary. (Some people say, I will not convert yeah, okay, we use Windows built-in calculator on the line. Open the calculator, point to View> scientific type, enter a decimal number, then tap "binary" radio this point, you can switch to the binary)
to switch to a binary subnet mask, we find that all the subnet mask (a total of 4 segments 1 and consists of a string of continuous string of consecutive 0's, each section 8, a total of 32 digits).
255.0.0.0
11111111.00000000.00000000.00000000
255.255.0.0
11111111.11111111.00000000.00000000
255.255.255.0
11111111.11111111.11111111.00000000

This is the A / B / C three default subnet mask in binary form, in fact, there is a good variety subnet mask, as long as the string of continuous string of consecutive 0 and 1 on it (each piece is 8 bit). As 11111111.11111111.11111000.00000000, which also

It was a legitimate subnet mask. The subnet mask determines that the number of a sub-computer, the computer formula is m-th power of 2, where we can see the m 0 is the number of stars behind. As 255.255.255.0 converted to binary, that is 11111111.11111111.11111111.00000000, followed by 8 0, m is 8,255.255.255.0 the subnet mask that can accommodate 8 th power of 2 (station) computer, i.e. 256, but there are two IP can not be used, that is, the last paragraph can not be 0 and 255, minus these two is 254. Let's do a.


The subnet mask of 255.255.248.0 how many computers can accommodate up to?
  Calculation:
  to convert it to a four binary digits (8, if each segment, if it is 0, 8 0 can be written, that is, 00000000)
  11111111.1111111.11111000.00000000
  then followed with a few 0 count, there are a total of 11, 11 that is a power of 2, equal to 2048, the subnet mask, can accommodate up to 2048 computers.
  A subnet can accommodate up to how many computers you will forget it, let's take the question a reverse algorithm.
-------------------------------------------------- --------------------------
a company has 530 computers form a peer local area network, the number of subnet mask set up the most appropriate?
  First of all, no doubt, 530 computer using the most appropriate class B IP (A Class Needless to say, too, C class and not enough, certainly Class B), but the default class B subnet mask 255.255.0.0, can accommodate 60,000 computers, is clearly not appropriate, then set the subnet mask how much better? Let's take a column formulas.
  M = 560-th power of 2
  First, we must be greater than 2 determines the power of 8, because we know that the 8th power is 256, i.e. the maximum number of Class C IP receiving computer, from the 9 th a a test 2 512 9 th, 10 th 1024 is less than 560,2, opinion

2 of the 10 th most appropriate. A total of 32 bits subnet mask, it has been determined back 10 is 0, that is in front of the 22 1, the subnet mask is the most appropriate: 11111111.11111111.11111100.00000000, converted to decimal, that is

255.255.252.0。

  Distribution and calculate the subnet mask you will it, here we take a look at the IP address of the network segment.


  I believe a lot of people and even the same, think the same IP as long as the first three paragraphs, is in the same segment, in fact, not the case, also, I like the IP of each section is converted into a binary number, where Take IP: 192.168 .0.1, subnet mask 255.255.255.0 to experiment it.
  192.168.0.1
  11000000.10101000.00000000.00000001
  (explain here, and the same subnet mask, each 8, less than 8 bits, preceded by 0 padded.)
  IP 11000000.10101000.00000000.00000001
  subnet mask 11111111.11111111.11111111.00000000
  here to tell you how to say something in the end be considered the same network segment.
  To the same network segment, it is necessary to do the same network identity that identifies how the network count it? IP network to identify various types of algorithms are not the same. Class A, only count the first paragraph. Classes B, only the first count, Sec. Class C, a first count, second and third sections.
  Each algorithm as long as the number of AND IP and subnet mask on it.
  AND METHODS: 0 0 0 = 1 and 0 = 0 and 1 = 1 and 1
  , such as: And 192.168.0.1,255.255.255.0, is first converted to binary, and then every AND
  IP 11000000.10101000.00000000.00000001
  subnet mask 11111111.11111111.11111111.00000000
  The results obtained AND 11000000.10101000.00000000.00000000
  converted to decimal 192.168.0.0, which is the network identifier,
  Then take anti subnet mask, which is 00000000.00000000.00000000.11111111, and IP AND
  the outcome 00000000.00000000.00000000.00000001, converted to decimal, that is 0.0.0.1,
  which is the host 0.0.0.1 identity. To the same network segment, network identification required to do the same.
-------------------------------------------------- ---------------------------------
  we look at this change to the default subnet mask of class B IP
as IP: 188.188.0.111,188.188.5.222, subnet mask are set to 255.255.254.0, on the same network segment it?
  These first converted into binary
  188.188.0.111 10111100.10111100.00000000.01101111
  188.188.5.222 10111100.10111100.00000101.11011010
  255.255.254.0 11111111.11111111.11111110.00000000
  are AND, obtained
  10111100.10111100.00000000.00000000
  10111100.10111100.00000100.00000000
  network identity is not the same, i.e. not in the same network segment.
  Judge is not in the same network segment, you will be right, here we come actual point.


A company has 530 computers form a peer LAN, and IP subnet mask number set up the most appropriate?
  The subnet mask is not to say, in front of the 11111111.11111111.11111100.00000000 calculated results, that it is 255.255.252.0
  we now need to determine is how to allocate IP, first of all, choose a Class B IP segment, where we chose 188.188.xx it
  this way, IP first two paragraphs identified, the key is to determine the third paragraph, as long as the same network identification on it. We first determine the network number. (We put the subnet mask and IP in 1? To get up, 0 and correspondence, as follows :)
  255.255.252.0 11111111.11111111.11111100.00000000
  188.188.xx 10,111,100.10111100. ?????? .
*****
  network identification 10111100.10111100.??????00.00000000
  seen,? at just fill (filled with only 0 and 1, 0 and 1 are not necessarily all), we will use the full 0 to fill it, at random, so it our IP is
  10111100.10111100.000000 .
*****, a total of 530 computer, IP last paragraph 1 to 254 can be allocated to computer 254, 530/254 = 2.086, using a method into afford an integer of 3, in this way, we want to determine the IP of the third paragraph points

Into three different numbers, that is, to 000000 in the fill three figures, can only fill 1 and 0, and the numbers are not the same every time, as to fill what it will be with us, such as the 00000001,00000010, 00000011, converted into binary, namely 1,2,3, so that the third segment is also determined, so that it can be divided into IP 188.188.1.y, 188.188.2.y, 188.188.3.y, y at just fill in, as long as within the range of 1 to 254, and 530 which each and every computer IP is not the same as on it.
Some people might say, since the algorithm is too much trouble, simply use the Class A and Class A default IP subnet mask got, even to tell you that, due to the Class A and Class A default IP subnet mask is too large number of hosts, to do so is undoubtedly the needle in the haystack, if both
the LAN traffic is too frequently, too much, it will affect the efficiency, so it's best to set in line with their own IP and subnet mask ^ _ ^

       到现在为止今天的面试题你会了吧!

Guess you like

Origin www.cnblogs.com/knight-zhou/p/12066836.html