# To learn RedHat network operations, you must read: basic knowledge of IP addresses.

Source: Internet
Author: User
Tags ip number
Article Title: learn RedHat network operations: IP address basics. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Binary and logical operations
Before we know the IP address, I think we need to know two concepts: Binary and logical operations. Although I also know that these two things are hard to understand, if I don't know how they work, then you will have to die when we discuss IP addresses and subnets. However, once you know how it works, you will not be lost in any IP network.
Binary)
Why are we going to learn binary? Oh, it's not a damn stupid computer. it only knows 0 and 1. so we have to be stupid when we want to communicate with the computer. When the computer is processing IP operations, it is finally carried out in binary form.
The most common arithmetic rule we humans use is decimal places, that is, when we return from 0 to 9 to zero for a circle. the bit and byte we discussed earlier are octal places, that is, 0 to 7. one circle returns to zero and one digit goes into another digit. There are also hexadecimal digits from 0 to 15. one circle returns to zero and one digit goes into one. However, using number 15 is easy to confuse with decimal places, so the hexadecimal digits are between 10 and 15. they are replaced by English letters A to F, so we usually see the hexadecimal order from 0 to F.
I understand the above calculation rules. I believe that it is not difficult to understand binary. The truth is that from 0 to 1, a circle is returned to 0. Then let's look at the comparison between the 17 consecutive ascending Decimal binary and hexadecimal digits.
0 0 0
1 1 1
2 10 2
3 11 3
4 100 4
5 101 5
6 110 6
7 111 7
8 1000 8
9 1001 9
10 1010
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
16 10000 10
If you want to convert binary and decimal places, it is the easiest way to find the corresponding number in the list, but as you have just seen, sixteen numbers already have such a long list. if you want finding hundreds of numbers is not easy. However, the decimal number we see on the IP address cannot exceed 255. We can first list the 0 to the 7th power of 2
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
When we want to replace decimal with binary, we only need to find the corresponding column of the number (the method is to find the columns of the two values and take them to the right) fill in 1 in the relative field, then use the remainder to search for the next field, and then fill in 1 until there is no remainder. Then, fill in 0 in all other fields.
For example, we want to convert the decimal digit 220 to the binary digit.
We can find that the field 128 is the most appropriate (because the left side of 128 is 256, and the right side of 220 is 128 ). Then we fill in 1 in the field 128.
Continue to the remainder 92. we can find the 64 column, which is the most suitable. then fill in 1 in the 64 column.
Continue to the remainder 28. we find 16, which is the most suitable. then fill in 1 in 16.
To continue with the remainder 12, we can find the 8 column, which is the most suitable. then we can fill in 1 in the 8 column.
Continue to the remainder 4. we can find the 4 column. this is the best case. Then fill in 1 in the column 4.
Because there is no remainder, and the rest is filled with 0.
The result is as follows: 128 64 32 16 8 4 2 1
1 1 0 1 1 1 0 0
If we want to convert binary numbers into decimal places and use the above columns to make it easier, as long as the binary numbers are filled in the column from the right to the left order, then all the numbers corresponding to 1 will be the sum is a decimal number.
Of course, this is a manual method. if you have a binary counter or use a Windows abacus for conversion, it is even easier. If you do not know how to use Windows, follow these steps:
"Start/set/affiliated application/Abacus"
Then, click the "View" menu to confirm that the "project" has been selected.
Then click "decimal place" to enter the value.
Click "binary" to obtain the converted value.
Logical operation
Logical operation is a required unit of the Microcomputer program. here we only need to know a few basic operations. one is AND, the other is OR, AND the other is NOT.
In the binary AND operation, the same result (0 or 1) is obtained only when both parties involved in the operation are the same) otherwise, it is 0, that is, the result is 1 only when the double value is 1. Otherwise, it is 0. In this case
0 AND 0 = 0
1 AND 1 = 1
0 AND 1 = 0
It is not difficult to see that the result of an AND operation involving 1 is the opposite party (whether 0 or 1), AND that of an AND operation involving 0 is the result of 0.
In the binary OR operation, the value is 0 only when both parties are 0. Otherwise, the value is 1. In this case
0 OR 0 = 0
1 OR 1 = 1
0 OR 1 = 1
The result of an OR operation involving 0 in the memory method is the other party, and the result of an OR operation involving 1 in the memory method is 1.
The NOT operation is simplest. only one party participates in the NOT operation and the result is the opposite.
NOT 0 = 1
NOT 1 = 0
Some other nand or nor operations only combine not and or.
After a round of brainwashing, we finally want to talk about IP addresses. If your machine is connected to the Internet and IP protocol is used (I think you should do this; otherwise, how can I read my article ).
I suppose you are using a Windows system. now, please press start and then run. Then, enter "winipcfg" on the keyboard and then click "OK ". At this time, you should see a window that runs out and displays the IP number currently used by your machine in the "IP address" column. It may be a group of numbers such as 139.175.152.254. But do you know what this group of numbers mean? if it is set properly, I can say this is the IP number of B class and it belongs to seed.net. network.
How can I know? haha, you can tell me more after reading the following articles?
IP Class and identifier
As you can see, there are four groups of decimal numbers separated by ".". We call each group of numbers in a "octet" format called "Dotted quad ". In fact, each group is an 8-bit binary number (the use of ten is entirely intended to accommodate human habits) in combination, the IP address is a 32-bit IP address, that is, the IP v4 (Version 4) Version address, now IP v6 (using the 128-bit IP address) it is also like developing.
If you remember the Internal and External addresses we mentioned when discussing IPX addresses in "Introduction to networks", you should know that the Internal address is used to identify the host, while the External address is used identifies a network. In fact, the IP address also has this function, except that the network identification code and host identification code are placed on a single IP address.
However, before distinguishing Net ID and Host ID, let's first understand the classification of IP addresses (Class ):
If we use binary numbers to represent all IP addresses, each octet is 8-bit. if it is not 8-bit, fill 0 on the left until it is filled up. Now, let's see what the leftmost number starts.
If the IP address starting with "0" is an IP address of A Class
If it starts with "10", this is the IP address of B Class.
If the IP address starting with "110" belongs to the IP address of C Class
I believe you know why. we will learn binary replacement at the beginning. if you don't know how to convert it, you can also remember that the IP address starting from 1 to 126 is an IP address starting from 128 to 191 in Class. is B Class, and then starts from 192 to 223 is C Class. Obviously, it's easier to identify IP Class using binary. don't you think?
Well, when we know the difference between the Class of the IP address, we can know the Net ID and Host ID of the IP address.
The IP address of Class A uses the first number as the Net ID and the other three sets as the Host ID.
B Class IP uses the first two sets of numbers for Net ID and the other two sets for Host ID
The IP address of C Class uses the first three sets of numbers as the Net ID and the remaining group as the Host ID.
From this, you can easily distinguish the above three different IP Class
Why do we need to classify IP addresses? this is for the original IP management needs.
If you want to build a single IP network, you have to allocate the same Net ID to all hosts, but the Host ID of each Host must be unique, that is, no two Host IDs will be the same.. If your network is connected to the internet or other networks, the Net ID you use must also be unique. Otherwise, it will cause a burst. For example, if your phone number is 1234567 (Host ID) other people will no longer use this number. However, you do not include the 1234567 number in other area codes, but if Taipei uses area code 02, Tainan cannot use it. In any case, the entire area code and telephone number must be unique. Similarly, the entire IP address (Net ID + Host ID) must be unique on the internet. A special Net ID 127 (binary 01111111) is reserved for local loop testing and cannot be applied to the actual network.
In addition, there is also a rule that we must observe when the specified Host ID is changed to binary, it cannot be all 0 or all 1. When all Host IDs are 0, the IP address is the IP address used to send broadcast packets.
Obviously, the Host ID that can be allocated in the Class network is more than twice as good as that in the C Class network. Let's calculate the number of Net IDs that can be divided and the number of Host IDs in each level.
Because the first bit of A Class must be 0, only 7 bits can be changed in the first eight bits of otect. So 27 = 128 minus 0 and 127, the Net ID cannot be used. In fact, we can only divide up to 126 A Class networks. The network of each A Class can be allocated with A 24 value of 2 (the number of bits of Host IDs that can be used) the power is 16,777,216 Host IDs, and because binary numbers cannot all be 0 or 1, the actual number of Host addresses that can be used is only 16,777,214.
Because C Class starts with 110 minus 3 bits, the Classless Inter-Class network is 21 (24-3) of 2) the power is 2,097,152 Net IDs, and then each Class C can be divided into 28 = 256-2 = 254 Host IDs.
Now, you can calculate the number of Net IDs that B Class can divide and the number of available Host IDs under each Net ID. (Tips do not forget that the IDs cannot all be 0 or 1 ). Then compare the following list
Grade opening first network number of hosts usage application field
A 0 126 16,777,214 1. x to 126. x. x National
B 10 16,384 16,382 128. x to 191. x multinational corporations
C 110 2,097,152 256 192. x to 223. x enterprise organization
D 1110--224.-to 239.-Special Purpose
E 1111--240.-to 255.-retain perimeter
At this point, I have to explain one thing to everyone. when we divide IP addresses, both IP addresses and Net masks must be used one by one. However, when we use classification
Related Keywords:
Related Article

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.