preface
Welcome to our GitHub repository Star: github.com/bin39232820… The best time to plant a tree was ten years ago, followed by now
Where t
Today our protagonist is IP, this guy is born beautiful and difficult to abandon, in the world of the network, he is a first-class citizen. Today we are going to talk about IP
- Relearn the Web series (The Past and Present of HTTP)
All forms are false; If see all phase is not phase, namely see tathagata.
How do you check the IP address of the current server
Ha ha, this problem is not very simple, not engaged in technology may know, there are the following ways
- On Windows it’s ipconfig
- On Linux, it’s ifconfig.
- The other one on Linux is IP addr
What is the difference between ifconfig and IP addr? Sometimes it’s hard to dig deep in interviews because many people don’t work the first time. Feel free to leave a comment below.
The IP address
A P address is the network address of a network card, the equivalent of our real world house number. Since it’s a house number, we can’t all be the same, or there will be conflicts. For example, if everyone calls unit 6 1001, the delivery will be lost. Therefore, sometimes our computer pop-up network address conflict, the emergence of the network, mostly IP address conflict.
For example, 10.100.122.2 is an IP address that is dotted into four parts with eight bits each, so the TOTAL IP address is 32 bits. The number of IP addresses this creates quickly becomes insufficient. Because at the time of IP address design, who knew there would be so many computers today! Because not enough use, so there will be a IPv6, namely inet6fe80: : f816:3 eff: fec7:7975/64. This one has 128 bits, which may be enough for now, but who knows what the future holds?
Address classification
IP is currently divided into five categories, but let’s just look at the three that we use the most
In network addresses, at least when they were designed, there were two main parts for classes A, B, and C, the first part being the network number and the second part being the host number. It makes sense. Everyone is unit 1001, unit 6. I am unit 1001, unit 6, unit A, and you are unit 1001, unit 6, unit B
Let’s see if we are familiar with it. I believe that the address of your company’s LAN basically starts with 10.0, while our VIRTUAL machine LAN using our own computer group must mostly start with 192.168
Public IP address and private IP address
In daily work, there is almost no need to classify A, B or C, so over time, many people forget this classification. One thing to be careful about, though, is public IP addresses and private IP addresses.
Let’s move on to the chart above. The rightmost column in the table shows the private IP address segment. The IP addresses of offices, homes and schools in data centers are usually private IP addresses. Because these addresses allow IT staff within the organization to manage themselves, assign themselves, and be repeatable. So, one of your school’s private IP addresses can be the same as mine.
The MAC address
Similar to FA :16:3e: C7:79:75 BRD FF :ff:ff:ff:ff:ff This is called a MAC address. It is the physical address of a network adapter in hexadecimal format with six bytes. A MAC address is a very “misunderstood” address. Because the MAC address is claimed to be globally unique, no two network cards have the same MAC address, and the network card carries the address since it is produced. A lot of people look at this and think, well, in this case, the whole Internet communication, all use THE MAC address, as long as you know the MAC address, you can send the message.
Of course not. In order for a network packet to travel from one place to another, it needs to have a location function as well as a definite address. The IP address with the attribute of the door number has the remote location function.
For example, you go to Hangzhou wangshang Road 599 B building 6 to find Liu Chao, you ask the way on the road, may be asked the person does not know which B building is, but can show you how to go to wangshang road. But if you ask a person, do you know where the person with this ID number is? Predictably, no one knew.
A MAC address is more like an ID card, a unique identifier. Its unique design is for networking, when different network cards are placed in the same network, you can not worry about conflicts. From a hardware perspective, ensure that different nics have different identifiers
Therefore, the communication range of MAC addresses is limited to a subnet. For example, you can access 192.168.0.3/24 from 192.168.0.2/24 using a MAC address. Once across the subnet, from 192.168.0.2/24 to 192.168.1.2/24, the MAC address is no longer available, and the IP address is required to work
Interview question how to set up their own computer IP
You can set the IP address in the following ways
- Sudoifconfigeth110.0.0.1/24 sudo ifconfig eth1 10.0.0.1/24 sudoifconfigeth110 0.0.1/24 sudo ifconfig eth1 up
- Sudoipaddradd10.0.0.1/24 deveth1 sudo IP addr add 10.0.0.1/24 dev eth1sudoipaddradd10. 0.0.1/24 deveth1 sudo IP link set up eth1
You may be asking yourself, is it too much freedom to configure myself, can I configure anything? What if you configure an address that doesn’t touch anyone? For example, if the machines next to me are 192.168.1.x and I have to configure a 16.158.23.6, what happens?
There will be no phenomenon, but the package can not be sent out.
why
You can try, you find that when you ping, the packet can not be sent out, the reason is the main point, a very important conclusion, important things to say three times
- As long as it is on the network to run the package, are complete, can have a lower layer without the upper layer, absolutely impossible to have the upper layer without the lower layer.
- As long as it is on the network to run the package, are complete, can have a lower layer without the upper layer, absolutely impossible to have the upper layer without the lower layer.
- As long as it is on the network to run the package, are complete, can have a lower layer without the upper layer, absolutely impossible to have the upper layer without the lower layer.
Since we want to send a packet, even if it is a switch, right? Their communication is in the network data link layer, we say the MAC layer, then you think, I am 16.158.23.6 my OWN MAC address, we must know, but I do not know the MAC address of 192.168.x.x. What am I going to do? I’m going to have to figure out how to get his MAC address, and there’s going to be a process of judgment, and if the address is on the same network segment as me, I’m going to send ARP, and I’m going to get it, like we’re in an office, and I’m just going to say, “Hey, Six-six, hand me your stuff.” When we send the packet to him, he will find that the MAC address does not match his own gateway address, so he will not receive the packet.
Dynamic Host Configuration Protocol (DHCP)
There are so many ways to configure IP. You may ask, after configuring the IP generally cannot change, configuring a server machine is ok, but what about the client machine? What if I walk around the office with a laptop in my arms, or during the day and at night, and have to configure an IP address for each use? There are personnel, administrative and other non-technical personnel, if all the company’s computers need IT personnel configuration, certainly busy ah.
Therefore, we need to have an automatic ConfigurationProtocol, known as the Dynamic Host ConfigurationProtocol, or DHCP.
If a network administrator has configured a DHCP Server on the network, he is the administrator of these IP addresses. He knew immediately that a “new man” had arrived. At this point, we can appreciate the unique importance of MAC addresses. When a machine joins a network with its MAC address, the MAC is its only identity, and if even this is repeated, it cannot be configured. Only the MAC is unique, the IP administrator can know that this is a new user and needs to rent it an IP address, a process we call DHCPOffer. At the same time, the DHCP Server reserves the IP address provided for this client and does not assign this IP address to other DHCP clients.
DHCP packets
DHCP messages are classified as follows:
- DHCP DISCOVER: indicates the packet sent by the client to start the DHCP process and is the start of DHCP
- DHCP OFFER: indicates the response made by the server after receiving the DHCP DISCOVER, which includes the IP address (YIADDR), MAC address, lease expiration time, server identifier, and other information
- DHCP REQUEST: indicates the response of the client to the DHCP OFFER sent by the server. It will also be used when renewing the lease.
- DHCP ACK: indicates a successful DHCP ACK packet sent by the server after receiving a DHCP REQUEST from the client. When establishing a connection, the client will confirm that the IP address and other information assigned to it are allowed to be used only after receiving this message.
- DHCP NAK: Indicates the reverse DHCP ACK message, indicating that the server rejects the client request.
- DHCP RELEASE: Usually occurs when the client is shut down or offline. This message causes the DHCP server to release the IP address of the client that sent the message
- DHCP INFORM: indicates a message sent by a client requesting information from the server
- DHCP DECLINE: The DHCP DECLINE message is sent by the client to notify the server that the IP address assigned by the server is unavailable (for example, when IP addresses conflict)
- Use this IP address.
DHCP workflow:
At the end
Today we learned about the basic element of the Internet, the IP Mac, which is the equivalent of having an ID card, which gives you a unique identity in the country, and also in the Internet world, and then we learned about DHCP. From tomorrow on we can go on adventures elsewhere.
reference
- IP details
- Working Principles of DHCP
Daily for praise
Ok, everybody, that’s all for this article, you can see people here, they are real fans.
Creation is not easy, your support and recognition, is the biggest motivation for my creation, we will see in the next article
Wechat search “six pulse Excalibur program life” reply 888 I find a lot of information to you