. It is used to track the original Client IP address and the server address of the original client request. When we access index. JSP/is not actually the index on the server accessed by our browser. JSP file, but the index is first accessed by the proxy server. JSP, the proxy server returns the access results to our browser, because the proxy server accesses the
, you must convert the IP address to the Int type during filtering. This facilitates data range filtering, the following code defines the data type conversion method for IP addresses:
Privatelong IPToNumber (string ip) // defines the IP to Int method. The
the http://192.168.1.110:2046/ INDEX.JSP, the proxy server returns the results of the visit to our browser, Because it is the proxy server to access index.jsp, so index.jsp through the Request.getremoteaddr () method of IP is actually proxy server address, not the client's IP address.
Package com.rapido.utils;
/ INDEX.JSP, the proxy server will return the results of the access to our browser, because it is the proxy server to access index.jsp, so index.jsp through REQUEST.GETREMOTEADDR () method to obtain the IP is actually the proxy server address, not the client's IP address.
Then you can get the client real
() is actually the proxy server address, not the client IP address.
So we can obtain the real IP address of the client. Method 1:
CopyCode The Code is as follows: Public String getremortip (httpservletrequest request ){
If (requ
@ Echo off
Mode con Cols = 55 lines = 18
Rem setting public variables
Set net_interface = "Local Connection"
: Choice
Color
CLS
Echo ************** ******
Echo ---- [ipsettings] ------------- [system functions ]----------
Echo ----- 1. Modify IP-----------4 for local connection. Change to auto get -----
Echo ----- 2. Modify "local connection 1" ip ---------- R.
address), which is internal to the local organization and can only be seen on local lans. The same 10.xxx.xxx.xxx, from 172.16.xxx.xxx to 172.31.xxx.xxx are private addresses, but also belong to the organization internal access;
169.254.xxx.xxx belongs to the connection local address (link locally IP) and is available in a separate network segment
From 2
. Used to track the original client IP address and the server address of the original client request. When we visit http://www.jb51.net/index.jsp/, it is not that our browser actually accesses the index.jsp file on the server, but instead it is accessed by the proxy server first http://192.168.1.110:2046/ INDEX.JSP, the proxy server will return the results of the
the client. However, in the HTTP header message that forwards the request, the X-forwarded-for information is added. The server address used to track the original client IP address and the original client request. When we visit http://www.xxx.com/index.jsp/, actually not our browser actually accesses the index.jsp file on the server, but first by the proxy serve
://192.168.1.110:2046/INDEX.JSP, the proxy server will return the results of the access to our browser, because it is the proxy server to access index.jsp, so index.jsp through the request.getremoteaddr () is actually the address of the proxy server, not the IP address of the client. So we can get the real IP
-192.168.131.254.............192.168.139.1-192.168.139.254192.168.140.1-192.168.140.254192.168.141.1-192.168.141.254192.168.142.1-192.168.142.254192.168.143.1-192.168.143.254.............192.168.254.1-192.168.254.254192.168.255.1-192.168.255.254
8. The total number is (255-128 + 1) * (254-1 + 1) = 128*254 = 32512
Faint !!!! @#! @ We can't afford to buy so many machines after buying all our companies! · ¥! ·#
9. Check whether the result is correct.
(1)
In the actual network environment, depending on the size of the network, the number of hosts in the network is different, the IP address is divided into A,b,c 3 for different sizes of the network, and the IP address is a 32-bit dotted decimal notation, only the IP
-1, and then compress it into a big-endian encoded string r. Eturn pack ('N', intval (ip2long ($ ip )));} /*** return the read string ** @ access private * @ param string $ data * @ return string */function getstring ($ data = "") {$ char = fread ($ this-> fp, 1); while (ord ($ char)> 0) {// The string is saved in C format, end $ data with \ 0. = $ char; // connect the read characters to the given string $ char = fread ($ this-> fp, 1);} return $ data
in the JSP, the method to obtain the IP address of the client is: Request.getremoteaddr (), which is valid in most cases. However, after passing the reverse proxy software such as Apache,squid,nginx, due to the addition of the middle tier between the client and the service, So the IP that the Request.getremoteaddr () method obtains is actually the
server accesses HTTP/ 192.168.1.110:2046/INDEX.JSP, the proxy server will return the results of the access to our browser, because it is the proxy server to access the index.jsp, so index.jsp through The Request.getremoteaddr () method gets the IP address of the proxy server, which is actually the address of the client.So we can get the real
Make method one, use IP138 database to query domain name or IP address corresponding geographical location.
#-*-coding:gbk-*-
import urllib2
import re
try: While
True:
ipaddr = Raw_input ("Enter IP Or Domain Name: ")
if ipaddr = =" "" or ipaddr = = ' exit ': Break
else:
url = "http://www.ip138.com/ips138.asp?
proxy server to access the index.jsp, the IP index.jsp in the Request.getremoteaddr () method is actually the address of the proxy server, not the IP address of the client.So we can get the real IP address of the client method on
; using System. web; using System. xml; using System. IO; using System. net; using metadata; namespace NetOpen_System.Component {public sealed class WebsiteFilterHttpModule: IHttpModule {# region IHttpModule member public void Dispose () {} public void Init (HttpApplication context) {context. beginRequest + = new EventHandler (con Text_BeginRequest) ;}# endregion
(' 8.8.8.8 '). Iptype ()' Public '
Then write a script that returns various results based on the IP address entered:[[emailprotected] python]# cat ip_test.py #!/usr/bin/python#-*- coding:utf-8 -*-from IPy import IPip_input = raw_input("请输入一个ip地址或者地址段: ")ips = IP(ip_inp
In a project, if you want to obtain the IP address of the system, many people may think about how easy it is, but it is not as easy as it seems to be in multiple operating systems, the following shows how to obtain the IP address of the system.Java codePackage easyway. tbs. commons;Import java.net. InetAddress;Import j
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.