How to block network traffic in Linux based on country location
As a system administrator who maintains a Linux production server, you may encounter the following situations: You need to selectively block or allow network traffic to pass through
This approach is not very efficient, if used in the web, if used less can be used in this way, if used, or recommend the use of IP library
Copy Code code as follows:
#region # #得到真实IP以及所在地详细信息
Get real IP and location details
Implementation Method: capture IP addresses through regular expressions to display website data ....
Friendly reminder: This method is not highly efficient. If it is used in the Web, you can use this method if it is rarely used. If it is
This method is not efficient. If it is used in the WEB, you can use this method if it is rarely used. If it is commonly used, it is recommended to use the IP library.Copy codeThe Code is as follows:# Region # obtain the real IP address and location
DAT files, information files about IP-corresponding areas
Qqwry.dat file
Download yourself Online
class file, parsing the Qqwry.data file's
iplocation.php File
Copy Code code as follows:
Class Iplocation {
/**
* @var Resource pointer
IP geolocation Query class
/**
File name: IpLocation.class.php
* IP Geo-Location query class (Master file I'm uploading it.) I upload a test file, and there is a QQWry.Dat this can be downloaded to the pure IP
In Web applications, locating and logging related access logs based on IP addresses is also a common requirement, and in thinkphp you can easily implement IP address acquisition and positioning
You can download the IP Location Extension class
You can download the IP Location Extension class library at the http://www.thinkphp.cn/extend/223.html website, or download the extension package (http://www.thinkphp.cn/down/253.html) inside the extended class. If the Upload class library is
Server. ScriptTimeout = & he10' & H3CResponse. Buffer = ("S. F." = "S. F .")Dim IpSearch'Create an objectSet IpSearch = New clsIpSearch'Use the default connection to establish a connection to the SQL Server IP address library, but ensure that wry.
in Web applications, it is also a common requirement to locate and record related access logs based on IP addresses, and you can easily implement IP address acquisition and location in thinkphp You can download the IP Location Extension class
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.