1. IntroductionThe solution is suitable for technology novices, while the blog website content publishing is aimed at the domestic group. Access from foreign IP addresses can be blocked through domain name resolution providers. For example: This website is mainly aimed at the domestic Chinese community to share relevant knowledge. Recently, we found a large number of attack visits from foreign IPs through the logs in nginx. It is cumbersome to use firewalls to intercept IPs. No matter what kind of manual protection is used, it is inevitable to be attacked. Finally, I summarized that there are also various automatic attacks in China, but more of them are visits from foreign IPs. So, I wonder if there is any way to ban it directly? Yes, and the method is relatively simple. 2. Alibaba Cloud DNS resolutionFirst, access the Cloud DNS function through the Alibaba Cloud Workbench. Then find the domain name you want to restrict and add the resolution configuration. Click the Add Record button in the image above. First, configure the record type: A, host record: * represents all sub-domains under the domain name, etc. The most important thing is to parse the two parameters of request source and record value. We choose: Overseas When all regions and countries outside mainland China access our domain name, they will be directly directed to the address of the record value filled in below. 2.1 Explanation Let me briefly explain the relationship between the request source and the record value. All domain name addresses are ultimately pointed to a specific IP address through a DNS server. The various parameters we configure here are to tell the DNS server what kind of IP address you should return if someone visits our domain name. The recorded value is the IP to be returned. For example, when configuring access to all overseas IP addresses, we assign the domain name to the IP address 127.0.0.1. This IP address is the local IP address of all computers. That is to say, all foreign visitors who visit our domain name will eventually access its local machine. PS1: You can also use this to allow visitors to access other servers. Adjust according to your actual needs. When we have finished the configuration, we save it. PS2: After the configuration is completed, according to actual experience, it is not the case that after 10 minutes, all the IP addresses accessed from abroad will point to the address we defined. Instead, there will be a gradual update process. After all, it takes time for the server to update and synchronize. Especially the refresh of the DNS configuration. So, wait a little longer. From my personal experience, after two days, nginx logs still show visits from foreign IP addresses, but the number has obviously decreased. 3. OthersAfter we configure the foreign IP to access the domain name, please note that if the other party directly accesses our server through the IP, it can still be used. At this time, we can filter through nginx and directly return 404 or 444 to all IP address accesses. For details, please refer to my article: Nginx configuration, prohibit direct access to Web services via IP addresses 3.1 Record Type To expand on this, we have many options when adding DNS record types: You just need to grasp one core point: no matter what kind of record it is, the goal is to guide users to a specific server for processing when they visit our domain name. Different record types affect the type of record value and parameter format.
|
<<: RabbitMQ communication model work model
DMIT.io opened a new data center in San Jose, USA...
Nowadays, SD-WAN (Software Defined Wide Area Netw...
This article takes stock of the smart city applic...
HTTP cache is very critical for front-end perform...
CentOS8 has been released for some time. I person...
ICT industry recovers According to statistics fro...
Everything has its two sides, and technology is n...
China Unicom will carry out 5G pilot projects in ...
1. Computer Network Architecture Layering Compute...
In 2019, we thought 5G was a distant thing, but i...
VPSMS is shared in the blog for the first time. I...
[51CTO.com original article] In the past, users o...
Tencent Cloud's lightweight application serve...
According to CCTV News Client, the first rehearsa...
Friendhosting has launched a promotion for "...