For example i send a request to https://www.w3schools.com/ which is showed Remote Address: 192.229.179.87:443 on Inspect tools, can i get that ip in js?
An IP address or Internet Protocol is used in hand with TCP(Transmission control protocol) to identify and share information between computers on the internet. Because it would be a very hard job for humans to keep IP's of various servers in the head, all IP addresses are saved on a DNS server together with their domain names. Hence, whenever you make a request to a site in your web browser, the web browser first visits a DNS server to fetch the IP address corresponding to your domain before making a direct request to the server. Hence there is no Javascript code or command to generate IP addresses from domain names. Hence to accomplish this, you'll have to use an API which will do all the hard work for you.
Check this question for some API's : API's for getting IP
Related
I am using a IP location Service. which return location of the Ip. But When some proxy user login My site return wrong address Because the IP is Proxy. How to find out the user using proxy IP and find server Ip From Proxy IP in Javascript
.
While the point of a proxy, as Ryan says, is to block this, in some browsers it is possible to use RTCPeerConnection to get the user's IP.
This is not a perfect solution, and can be blocked fairly easily. Firefox has a built in setting to turn it off, in Chrome uBlock Origin can be used to block it. To check if your browser is vulnerable you can use this page, or take a look at the GitHub Repo.
I am working on a rest api.
That api is used by my website and the website is used by various users. I want to restrict the api access only to my website ( no other website should be able to access that rest api ) so for that I want to whitelist my domain name on the basis of the ip of the domain name
My goal is to find the ip of domain name requesting my ip not the ip of the users accessing my domain.
How can I achieve it in nodejs?
See Getting HTTP headers with node.js
You should be able to use the referer data in the header to check where the request is coming from.
From your API's viewpoint the IP of the request won't really be different from a server vs. a client. Although, other than some HTTP header variables.
You could simply check all the IPs of incoming requests for your "secured" endpoint and check it against a whitelist of all your server IPs.
Personally, I'd probably use ssl between servers.
I have a webapp that uses a lot of images which are cached through CloudFront. Some users complain that the load time is excruciatingly slow, So I want to build a diagnostic page on the site that will do a speed test by loading a few images and reporting the time. I also want to report the users IP address (which I can easily get from php when they load the page), but I also want to show the IP address that they are getting for the cloudfront server.
I know that if I run:
dig subdomain.cloudfront.net
I get several IP addresses. If an app (browser, QT app, mobile app) is running simultaneous connections to subdomain.cloudfront.net, does it always use the first IP first and use the others only if it fails?
And is there any way from within the browser that I can get these IP addresses as they are from the client users system? It's my understanding that they will get a different list of IPs based on their IP address.
If this is not possible from within the browser, is there any type of request that I could send to the cloudfront server that would include it's IP address in the response?
does it always use the first IP first
Most modern DNS resolvers and authoritative servers will randomise the order of the IP addresses -- more precisely, the set of A records for a given domain name.
So, "first IP" really isn't deterministic at all.
and use the others only if it fails?
Obviously this is very browser-dependent. Most modern browsers do handle it by retrying the other IPs. I wouldn't count on it though.
is there any way from within the browser that I can get these IP addresses as they are from the client users system?
From Chrome devtools network panel, you can see the address that the browser connected to in the "Remote Address" field of a request. However, I'm not aware of any way to access that from Javascript on a page.
It's my understanding that they will get a different list of IPs based on their IP address.
Yes.
is there any type of request that I could send to the cloudfront server that would include it's IP address in the response?
Not that I know of. However, you might be able to reverse engineer the Via or X-Amz-Cf-Id response header? At a cursory glance, both are unintelligible to me after hex or base64 decoding.
That said, there is a trick that you might be able to use, i.e. that you could setup a URL prefix in your distribution that forwards the requests to your server running PHP. You then point your users to a URL that would result in a request that gets forwarded to your PHP script. In your PHP script, examine the X-Forwarded-For header, which should include a Cloudfront IP.
I'm writing a Firefox extension that uses nsIServerSocket to listen for socket connections. I'm looking for a way for the extension code to programmatically learn the local network address of the machine running the Firefox extension. This information gets communicated to a client on the local network out-of-band such that it can open a socket connection to the extension.
My research into this has so far only turned up individuals wishing to find the ip address of loaded websites by way of DNS resolution or using Java applets) which won't be appropriate for a FF extension. The Mozilla Developer pages on the Geolocation API mentions:
"data is exchanged including WiFi Access Point data, an access token (similar to a 2 week cookie), and the user's IP address"
but does not indicate an API to access the user's IP address directly.
My only idea at this point is to invoke a local process using nsIProcess and parse the IP from there. This seems awfully hackish and would have to be handled on a per-OS basis. I.e. do I run ifconfig, netcfg, ipconfig? With what args?
Is anyone aware of a better solution?
You use nsIDNSService interface here as well - it has a myHostName property that can be resolved:
var dns = Components.classes["#mozilla.org/network/dns-service;1"]
.getService(Components.interfaces.nsIDNSService);
var myName = dns.myHostName;
var record = dns.resolve(myName, 0);
while (record.hasMore())
alert(record.getNextAddrAsString());
You should expect it to produce multiple addresses and not all of them will be valid - even for the local network you will get at least two addresses (IPv6 and IPv4), in addition to that you might get a Teredo address, addresses from virtual adapters installed by VMWare & Co. and more.
I'd bet that the IP address mentioned in the Geolocation API is not the local computer's IP address. I mean, where in the world is 192.168.0.100, hmm? It's just not a useful piece of information, in general.
Since you're dealing with a local network, could you set up a small web page that just prints out the client's address? Then you could learn your IP by requesting that web page.
Can anybody let me know the logic they use to get the IP?
The server has to know your IP address to send you a response. That is how the internet works. Presumably they store the IP address for the last account activity in a database somewhere.
When your browser connects to their web site, their HTTP server determines the IP address from the connected socket. That IP address is supplied to Google's web application framework, which stores the IP address in some kind of data store, so that it can be retrieved later. I can't give you much more detail, since I don't work for Google (and even if I did, I probably wouldn'couldn't).
request.getRemoteHost();
this method in the request object will return the ip address of the client.