Why IP of nslookup and ping is not the same - windows

I have a question I try to do a ping in the cmd like this: ping google.com, so it gives me an IP address A. But after, I want to do an nslookup to google.com It gives me an IP address B. Why ? My question is why the IP are not the same from the same website.

The answer is probably round-robin DNS. DNS allow you to specify multiple values for the same record, and the client library will determine with one to use (some use the first, some use the last, some use a random one, and some iterate through them).
Alternatively, the DNS server may be returning different values to the same query - either to do load balancing behind the scenes, or to send you to the geographically closest server.
I just resolved google.com from two separate computers and got two different answers:
host-a5$ dig +short google.com
216.58.204.14
host-b4$ dig +short google.com
172.217.23.14
This shows that the google DNS servers are returning different answers for the same query, most likely for load balancing and/or geo-centric reasons.

Here are 3 reasons:
ping might be getting an address from hosts file (nslookup doesn't)
ping might be getting a cached address (nslookup doesn't). Use ipconfig /flushdns to empty the cache.
the same host may have more than one addresses registered in the DNS

Related

How to retrieve Connection-Specific DNS Suffix for Interface in Go?

I am on a windows machine and programming in Go. When I do an ipconfig I am able to see my machine's interfaces.
Whenever I execute net.InterfaceAddrs() I get a bunch of IP addresses, and I know which one is the one I am looking for, but I want to be able to tell if those addresses belong to my domain. In the output of ipconfig I can tell this by reading the Connection-Specific DNS Suffix entry which has my "company.com" listed.
Any ideas?
See: similar question
try net.LookupAddr for each IP you get from net.InterfaceAddrs
assuming they reverse back correctly, they should end in your domain name.

Access a local machine form outside the LAN

Is there a way to access a machine from outside the LAN without port forwarding?
I have two scenarios in my current setup port forwarding is complicating:
I have two FTP servers on the same router I want to access from outside
I want to Remote Control/Access files on Windows computers on the network
Right now, the first option is possible, but it needs reconfiguring the router, while other one seems impossible outside the LAN.
Is there something like [global IP address]/[machine name] or [global IP address]/[Local IP address]?
We need more information. Are these addresses IPv4 RFC 1918 addresses, publicly routed addresses, or IPv6?
If they are in the RFC1918 (10.x.x.x, 172.16.x.x, 192.168.x.x) address space then, simply no. Those addresses are not publicly routed and therefore must be translated to a non-RFC 1918 address.
Otherwise, yes, you can.
If your servers should be available to the public - the answer will be "no".
If you plan to give a limited number of users (for example, only you) access to this servers then you have some options:
Use SSH tunnels with, for example, PuTTY and set up a Forwarding for each service you want to expose to your computer and access it over localhost:port.
localhost:21001 --> 192.168.1.3:21 (FTP1)
localhost:21002 --> 192.168.1.4:21 (FTP2)
Advantage: you can setup your "port-forwardings" at clinet-side
Disadvantage: you need a router or another computer running the SSH server
Use a VPN (for example, OpenVPN, PPTP, etc.) to get access to your LAN from outside. Then you can act like you are in your LAN.
Advantages:
easy to use if setup properly
you can use almost every protocol
Disadvantage: Need to setup VPN Service/Gateway

Node.js EADDRNOTAVAIL can't access via external IP

app = require('http').createServer()
app.listen(5000, '75.113.126.31')
Error: listen EADDRNOTAVAIL
People say this error means I'm trying to listen on an IP address that I don't own. But that is my external IP address according to google.
Also, if I omit my IP, it only works when I visit localhost:5000 and 127.0.0.1:5000, visiting 75.113.126.31:5000 doesn't work, even though people say node should listen there too when I don't give a 2nd argument to listen. I also tried listening on IP 0.0.0.0 with no luck accessing it through external IP.
What are the possible causes? I disabled Windows firewall but that didn't help.
Your external IP and your computer's network address often have almost nothing in common. In fact it would be very unusual if they did match.
Normally you bind to 0.0.0.0 if you want your service to be available remotely.
It's also worth noting that if you have some kind of router or firewall you'll need to configure port mapping to get port 5000 to route to your local IP correctly.
ipconfig should show you your actual IP address.
You should also be aware that some routers don't handle mapping internal traffic back to a local IP. Many do, so it's not always a problem, but if it doesn't work that might be the case.
The error message you are getting is correct. I'm going to assume you are on a computer behind a router. That ip address Google is reporting is the ip address assigned to your router not your computer, i.e your computer doesn't own it. You can prove this by running the command ipconfig in a cmd prompt, finding out your eth/wifi ip address, and using that in your app.listen (it'll probably start with 192 or 10), it should work. If you want to make your app public an easier way might be to just forward the port 5000 from your router the computer running the node app. Hope this helps!

GetHostEntry vs GetHostAddresses

I've been trying to find the correct situtation when to use GetHostAddresses or GetHostEntry. I understand by reading this article (http://msdn.microsoft.com/en-us/library/ms143998(v=vs.110).aspx) that GetHostEntry will do the reverse dns lookup and GetHostAddresses does not..
However under what exact scenario you need to use GetHostEntry rather than GetHostAddresses? also, what is the primary reason for GetHostEntry method to perform reverse DNS lookup?
GetHostEntry(hostNameOrAddress)
The GetHostEntry method queries a DNS server for the IP address that is associated with a host name or IP address.The method assumes that if an IP literal string is passed in the hostNameOrAddress parameter that the application wants an IPHostEntry instance returned with all of the properties set. These properties include the AddressList, Aliases, and HostName.
This method can be used if you want to find the hostname associated with an IP address.
Reverse DNS is mostly for such things as tracking where a web-site visitor came from, or where an e-mail message originated etc. It is typically not as critical in as forward DNS - visitors will still reach your web-site just fine without any reverse DNS for your web-server IP or the visitor's IP. Reverse DNS is important for one particular application.Many e-mail servers on the Internet are configured to reject incoming e-mails from any IP address which does not have reverse DNS.
GetHostAddresses(hostNameOrAddress)
But the GetHostAddresses method queries a DNS server for the IP addresses associated with a host name. If hostNameOrAddress is an IP address, this address is returned without querying the DNS server. This query will return all the IP addresses related to the hostname you provide.
The difference between GetHostEntry and GetHostAddresses is that whenever you give an IP address to GetHostEntry it will query the DNS server and try to get the hostname for that IP address and then get all the addresses associated with it.If the data for a successfull reverse resolve is not in your DNS server, this will fail.
One scenario where I see it useful as opposed to GetHostAddresses would be if you already know one IP address of a host and want to find the other IP Addresses. If an IP is specified as parameter, GetHostEntry would return all addresses while the GetHostAddresses will return only one (when IP is specified as parameter).

How can I ping many subsites ~/[0, 3].html in Bash?

Code:
for i in {0..3}; do ping http://www.pythonchallenge.com/pc/def/$i.html; done
A host should be found at www.pythonchallenge.com/pc/def/0.html.
I get this error for all pings:
ping: cannot resolve www.pythonchallenge.com/pc/def/0.html:
Unknown host
html pages != hosts. If you want to check if the three web pages actually exist, use wget. If you only want to check if the host is up, ping www.pythonchallenge.com.
You can't ping an address, you can only ping the domain aka www.pythonchallenge.com
If your trying to find the pages that actually contain content, you will need to use something like wget and combine that with grep to check the content.
You're confusing protocols here. HTTP has nothing to do with ICMP pings.
That said, you can ping www.pythonchallenge.com because it resolves to an IP. On the other hand, there's no DNS resolution for www.pythonchallenge.com/pc/def/0.html simply because that's an URL, not a host. Browsers first resolve www.pythonchallenge.com via DNS, then they make a HTTP request for the page itself.
I'm not sure what you're trying to accomplish here. You may want to simply ping www.pythonchallenge.com.
I think you're going about this problem the wrong way. Have you tried http://www.pythonchallenge.com/pc/def/1.html? Have you tried Googling that number?
(Assuming that your URL isn't just an example, of course.)

Resources