LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 08-03-2008, 09:59 AM   #1
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 23

Rep: Reputation: 15
gethostbyname returns "no address associated with this name" if behind a proxy


Hi,
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
 
Old 08-03-2008, 12:42 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.

Last edited by Mr. C.; 08-03-2008 at 12:44 PM.
 
Old 08-03-2008, 12:52 PM   #3
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 23

Original Poster
Rep: Reputation: 15
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.
thanks
 
Old 08-03-2008, 01:03 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Does dig work correctly to query a hostname?

dig some_external_hostnmame_here
 
Old 08-03-2008, 08:49 PM   #5
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 23

Original Poster
Rep: Reputation: 15
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


Thanks.
 
Old 08-03-2008, 09:01 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.
 
Old 08-04-2008, 01:02 AM   #7
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 23

Original Poster
Rep: Reputation: 15
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.
Thanks
 
Old 08-04-2008, 01:28 AM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.
 
Old 08-04-2008, 08:24 AM   #9
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 23

Original Poster
Rep: Reputation: 15
Mr. C,
Thank you very much for all the info. I'm really grateful to you.
BTW, dont you sleep ??
 
Old 08-04-2008, 09:40 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,678
Blog Entries: 54

Rep: Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954
Quote:
Originally Posted by iamback View Post
BTW, dont you sleep
Bad question. What if he does?... Who's gonna answer your questions then? BTW, you *can* use a proxy to resolve addresses, see for instance 'proxychains' (search Sourceforge). It comes with 'proxyresolv' which works like 'dig' but then through your SOCKS or HTTP proxy. [EDIT] No that you have to of course, anything that can use http://proxyiproxyport/webhosturi type of URI's or accepts the proxy by configuration (like wget) can help. Depending on what you want to do of course.[/EDIT]

Last edited by unSpawn; 08-04-2008 at 09:47 AM.
 
Old 08-04-2008, 03:07 PM   #11
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
Let's hope proxychains doesn't get iamback fired or booted from his network.
 
Old 08-04-2008, 03:58 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,678
Blog Entries: 54

Rep: Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954Reputation: 2954
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.

Last edited by unSpawn; 08-04-2008 at 04:02 PM.
 
Old 08-10-2008, 01:23 PM   #13
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 23

Original Poster
Rep: Reputation: 15
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
 
  


Reply

Tags
proxy


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gethostbyname("localhost") sds Linux - Networking 4 01-06-2005 06:25 AM
difference between "Web server local URL" and "IPv4 address"? kpachopoulos Linux - General 2 09-17-2004 02:30 PM
Apache gives [alert] mod_unique_id: unable to gethostbyname ("") kerrymwarren Linux - Networking 3 08-13-2004 06:01 PM
Apache not starting properly -- "unable to gethostbyname" ColoRambler Linux - Newbie 8 04-25-2004 12:49 AM
"host" ok, but "ping" can't find ip address hardigunawan Linux - Networking 2 05-16-2002 06:41 PM


All times are GMT -5. The time now is 04:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration