Opening
If you often mess with your home network, you must often encounter these problems:
- Why can’t I open the backend of the router even though the network cable is plugged in?
- Why does the NAS’s IP address often change?
- Why does the speed of opening web pages become slower when using expensive soft routing?
- Why can’t I play the bypass route even after following the boss’s video configuration?
The above problems are actually related to DHCP.
What is DHCP?
DHCP is the abbreviation of Dynamic Host Configuration Protocol, which means Dynamic Host Configuration Protocol. Its function is to automatically assign an IP address to each device connected to the LAN and automatically configure the default gateway and DNS server for these devices.
Glossary
It’s okay if you don’t understand what gateways and DNS mean. You can think of gateway as a transfer station. All devices in the LAN must communicate with the outside world through this transfer station. However, there is usually only one gateway for home networks, which is the router. DNS is a little more complicated. I will make a separate video to explain it later. Here you just need to understand it as a “phone book”.
How DHCP works
The DHCP protocol consists of a server and multiple clients. The server is generally your router, and the client is the device you use to access the Internet.
Discoer
Whenever a new device connects to a LAN for the first time, it broadcasts its MAC address to the entire network. The so-called MAC address is the hardware address of each device. It is written on the device’s network card and cannot be changed under normal circumstances. It is equivalent to the “ID card number” of the device. When a new device connects for the first time, it broadcasts its MAC address to the LAN, which is equivalent to the new employee’s self-introduction. This self-introduction has a very foreign name, called Discover.
Offer
When the router receives the broadcast of a new device, it will select a vacant address among the existing IP addresses that has not been occupied by other devices, and package this address and other configuration information (such as default gateway and DNS) and send it to the device, which is equivalent to the leader assigning a workstation to a new employee. This arrangement also has a very foreign name, called Offer.
Request
The next thing is very simple. When the device receives the configuration information sent by the router and decides to apply these configurations, it will reply to the router again, which is equivalent to accepting the arrangement of the leader. This reply also has a very foreign name, called Request.
One thing to note here is that if there are more than two routers in the LAN, and these routes have the DHCP service enabled, then after receiving the broadcast of the new device, they will send configuration information to the device at the same time. When the device receives multiple configuration information at the same time, it will reply to the one received first. Therefore, in order to avoid network chaos, even if you have multiple routers at home, it is best to only enable one DHCP service.
###ACKBack to the topic, when the router receives a positive reply from the device, it will reply to the device to indicate that the space occupation is successful. At this time, the device will automatically configure its own network based on the IP address, default gateway and DNS server issued by the router to achieve successful networking. This reply from the router is called ACK.
Answer question 1
Having said that, we have solved the first problem mentioned at the beginning of the video:
- Why can’t I open the backend of the router even though I have plugged in the network cable?
There are two possibilities here: 1. Your router does not have the DHCP service enabled, and your computer does not receive the IP address issued by the router. 2. Your router has the DHCP service enabled, but your computer has been previously set with a static IP address, and this static address and the address of the router are not in the same network segment.
To solve the problem of “cannot open the background”, the method is also very simple: 1. If it is the first case, then we need to manually configure a static IP address on the computer first, and this address must be in the same network segment as the router. For example, if the IP address of the router is 192.168.31.1, then the static address of the computer must be set to 192.168.31.x. The x here can be any number from 2 to 255, but be careful not to overlap with other devices. 2. If it is the second case, then we need to clear the static IP address of the computer and change the IP address acquisition method to “obtain an IP address automatically”. In this way, our computer will accept the assignment of DHCP service again.
NAK message
Back to the topic again, the entire process mentioned above is the process for a new device to connect to the LAN for the first time. If it is not a new device that is connected for the first time, but an old device that has been connected before. If you disconnect and reconnect, you will skip the first two steps and start directly from Request. This is equivalent to an old employee returning after leaving the company, directly omitting the polite process and asking the leader to give you a workstation.
At this time, the router will check the previous DHCP lease table. If the device’s previously corresponding IP address is still vacant, an ACK will be returned as usual. The lease continues to be valid and the device continues to use its previous IP address. If the device’s previous corresponding IP address has been occupied by another device, the device’s request can only be rejected. Then this action of rejection is called NAK.
Answer question 2
Speaking of which, we have solved the second problem mentioned at the beginning of the video:
- Why does the NAS’s IP address keep changing?
The reason is that when the NAS is shut down and offline, the IP address originally occupied becomes vacant and occupied by other devices. When the NAS is turned back on and online, the router can only reassign it a new IP address. At this time, we will not be able to find the backend of the NAS, and we need to use software such as Synology finder to search for the new address of the NAS again.
It is also very simple to solve this problem, that is, turn on the IP/MAC binding of the router, assign a fixed IP address to a specific MAC address, and achieve “one carrot and one pit”, so that there will be no confusion.
DHCP application
***Knowing how DHCP works, we can solve many problems during the Internet access process.
Answer question three
- Why does the speed of opening web pages become slower when using expensive soft routing?
If the speed of opening web pages is very slow, or if QQ can connect to the Internet, but the web pages cannot be opened, it is probably because there is a problem with the DNS server. The DNS server of our home network is usually obtained from the operator through the optical modem, and then delivered layer by layer through the DHCP service of the router. If we do not specify a DNS server in the router’s DHCP service, the router will default to the operator’s DNS. As we all know, the operator’s DNS is often hijacked and is neither safe nor stable to use.
Therefore, to solve the problem of “slow web browsing”, we can manually specify a stable DNS server address in the router’s DHCP service, so that all devices in the LAN can apply the DNS issued by the router’s DHCP. As for the useful public DNS servers, you can search a lot on the Internet. The more common ones include the famous Google 8.8.8.8 in foreign countries, and Alibaba 223.5.5.5 in China.
