gethostbyname returns "no address associated with this name" if behind a proxy
I'm sitting behind a firewall. I want to know how do I query addresses of websites outside the firewall like "www.yahoo.com" becuase it returns "No address associated with this name" but returns queries ffor internal websites alright.
I think that I'll have to ask my proxy to do that for me but I dont know how to do that. Please help me
Thanks and Regards
Your system's resolver must be configured correctly. You also need access to a forwarding nameserver, or a recursive nameserver and your firewall must allow DNS queries.
The file /etc/resolv.conf specific the nameserver to be used.
Thanks very much.
But I just want to tell that I have no control over these thigns and I dont want a control either. I just want to write a C program that can get me the ip address of a web address outside my domain. e.g. Firefox does this for me even when my /etc/resolv.conf lists only the internal addresses.
Does dig work correctly to query a hostname?
It seems that dig also doesnt answer my requests. Here is a sample output:
$ dig www.yahoo.com
; <<>> DiG 9.3.2 <<>> www.yahoo.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44141
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 0
;; QUESTION SECTION:
;www.yahoo.com. IN A
;; AUTHORITY SECTION:
. 518400 IN NS G.ROOT-SERVERS.NET.
. 518400 IN NS H.ROOT-SERVERS.NET.
. 518400 IN NS I.ROOT-SERVERS.NET.
. 518400 IN NS J.ROOT-SERVERS.NET.
. 518400 IN NS K.ROOT-SERVERS.NET.
. 518400 IN NS L.ROOT-SERVERS.NET.
. 518400 IN NS M.ROOT-SERVERS.NET.
. 518400 IN NS A.ROOT-SERVERS.NET.
. 518400 IN NS B.ROOT-SERVERS.NET.
. 518400 IN NS C.ROOT-SERVERS.NET.
. 518400 IN NS D.ROOT-SERVERS.NET.
. 518400 IN NS E.ROOT-SERVERS.NET.
. 518400 IN NS F.ROOT-SERVERS.NET.
;; Query time: 1 msec
;; SERVER: 172.27.16.1#53(172.27.16.1)
;; WHEN: Mon Aug 4 06:03:03 2008
;; MSG SIZE rcvd: 242
Your system is configured to use the DNS server at 172.27.16.1. If this server will not resolve domains for you, and you cannot configure your system to use another DNS server, then you are out of luck.
Your Firefox is configured to use a proxy server; the proxy server responds to the requests for you.
The gethostbyname() call relies on the system resolver, and hence working DNS to perform the translation. No working DNS means you are out of luck.
Hello, I'm really grateful that you're following my thread. Thanks for all the replies. Can you please tell me how does firefox ask the proxy server to resolve the dns address, I mean what requests does it send to the proxy server. If possible, please give me pointers to write a C-code for that.
When you configure your browser to use a proxy, the browser hands the entire URI to the proxy. The browser does not resolve the hostname into an IP address and then pass that to the proxy. The proxy itself then queries DNS as necessary to resolve the name and make the HTTP request.
The entire point of the proxy is that it does the work on behalf of the client, only returning the results. You are thinking of a proxy in an incorrect way. A proxy can only return what it is programmed and configured to return; you can't just decide you want it to give you data it isn't programmed to return.
Thank you very much for all the info. I'm really grateful to you.
BTW, dont you sleep :) ??
Let's hope proxychains doesn't get iamback fired or booted from his network.
Good one. (And kinda weird as well since that's usually my line ;-p)
@iamback: please contact your (network) administrators if you have any doubts about legitimacy of network usage that way.
Thanks for the info. I'll try proxychain and reply.
BTW, thanks for the answers.
Hey unspawn!, I just said that 'sleeping' thing jokingly because I saw a huge time difference in Mr. C's posts :)
|All times are GMT -5. The time now is 09:47 AM.|