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.)
Related
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
I want to have a generic shell script which will check network connectivity between two hosts.
I wrote shell script with host and nslookup command to get the more details of target host, with these command I can't determine if current host can talk to target host.
Also I can't use(restricted) ping command , I was wondering if can use some other command to check network connectivity betweenn two hosts
Please suggest
Given a target host to determine if source host can communicate to target host
This is too vague to be useful. To solve this problem, you need to nail down what you mean by "communicate." A host may be able to send ICMP but not TCP. It may be able to send TCP but not ICMP. It may be able to send TCP to port 80, but not to 22. It may be able to send HTTP to port 80, but not SSH to port 80. Packets you send may return an error, or they may be silently dropped. The endpoint may receive your packets, but not process them. It may process them but not respond to you. There are many levels of "communicate."
So the best thing to test with is the thing you actually want to do. So if you want to communicate with HTTP over port 80, the best test is to do that. In fact, the best test is to just do the thing you wanted to do and not check beforehand. You're going to have to deal with errors no matter way. Just because you checked beforehand doesn't mean your actual attempt will be successful.
But sometimes you do just want to check "connectivity" (for some value of "connectivity") for monitoring purposes. In that case, again, do the thing you want. The easiest shell tool for checking HTTP connectivity is to fetch something with curl. If you need some other port, then a very nice generic solution is netcat (often called nc). I like:
nc -G 1 <host> <port> </dev/null
A return code of 0 means it connected; 1 means it failed.
For more esoteric issues, you can use nmap or even hping to craft about anything you want.
But most of the time, you shouldn't check at all. And if you do check, check with the thing you really want to do.
There are websites that provide proxy lists like
http://hidemyass.com/ or http://letushide.com/ and Im sure there are a lot more, so the question is from where they take that ip addresses ?
If I make a search by them it shows some company or website/domain, and I do not think that company/website would allow to use their ip address, Or I am getting it wrong ? so how it is done ?
The second question is: is that possible that someone can use my website's IP address as a proxy to make a query. And if the answer is positive, can I prevent that somehow? Im on a shared hosting.
Thanks
I'm using a REDIRECT iptables rule from my router(OpenWRT) to redirect certain UDP packets from the server A to the server B and I need to know how to get the original destination address(like a proxy).
I already found a lot of information on how to do this on Linux using TProxy and other methods but unfortunately I don't see how to use them on Windows, there is some alternative?
If you use the REDIRECT iptables target, the original destination IP address is overwritten. It is lost and cannot be recovered.
Also, iptables only runs on Linux, so your question about how to do this on Windows doesn't make sense.
HI. in node.js, if it is http request, I can get the remoteAddress at req.connection.remoteAddress,
so, how to get it if https request? I find there is req.socket.remoteAddress but I'm not sure. Please advice. thanks.
It appears something is strange/broken indeed.
As of node 0.4.7, it seems http has remoteAddress available on:
req.connection.remoteAddress
req.socket.remoteAddress
on https, both of these are undefined, but
req.connection.socket.remoteAddress
does work.
That one isn't available on http though, so you need to check carefully.
I cannot imagine this behavior is intentional.
Since googling "express js ip" directly points to here, this is somehow relevant.
Express 3.0.0 alpha now offers a new way of retrieving IP adresses for client requests.
Simply use req.ip. If you're doing some proxy jiggery-pokery you might be interested in app.set("trust proxy", true); and req.ips.
I recommend you to read the whole discussion in the Express Google Group.
var ip = req.headers['x-forwarded-for'] ||
req.connection.remoteAddress ||
req.socket.remoteAddress ||
req.connection.socket.remoteAddress;
Note that sometimes you can get more than one ip address in req.headers['x-forwarded-for'], specially when working with mobile phones accessing your server (wifi and carrier data).
As well req.headers['x-forwarded-for'] is easily manipulated so you need a properly configured proxy server.
Is better to check req.connection.remoteAddress against a list of known proxy servers before to go with req.headers['x-forwarded-for'].