About the blacklist IP settings

Source: Internet
Author: User
Tags servervariables

Recently in a project, you need to do an automatic blacklist settings, that is, a day to repeat the error more than a certain number of mobile phone number, and IP to blacklist inside, the next time the request to determine whether in the blacklist.

This is the way to get the IP address

1  Private stringGetIP ()2         {3             stringIP =string. Empty;4             if(!string. IsNullOrEmpty (system.web.httpcontext.current.request.servervariables["Http_via"]))5ip = convert.tostring (system.web.httpcontext.current.request.servervariables["http_x_forwarded_for"]);6             if(string. IsNullOrEmpty (IP))7ip = convert.tostring (system.web.httpcontext.current.request.servervariables["REMOTE_ADDR"]);8             returnIP;9}
GetIP

At that time, I did not care, directly to the wrong IP and mobile phone to the corresponding record table, at that time I was to take their mobile phone with the wireless network and my workstation on the computer measured no problem, you can accurately obtain the IP, and then directly tell the customer no problem, so on the line, the problem is such existence. The customer suddenly told me that a lot of phone calls are IP restricted, I looked at a bit, found that an IP in the different mobile phone numbers are wrong. How about this situation, there can be so many people with an IP network AH. Later on the Internet, just understand the mobile phone data network such as: 2g,3g,4g These networks can not be a mobile phone number of an IP, is generally a region of the mobile phone number is an IP, so just out of my side of this error.

And then I thought of that at the time. Two solutions, one is to increase the number of IP.

Another solution is to separate the phone from the general request, so that when the phone request appears, regardless of the IP problem, only the request on the PC to consider the problem of IP.

This two plan actually has some flaw, but my this time is not considered to ask his method, hoped that the master can give more advice.

About the blacklist IP settings

Contact Us

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.