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