LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 08:59 AM   #1
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 24

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, 11:42 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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 11:44 AM.
 
Old 08-03-2008, 11:52 AM   #3
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 24

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

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

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

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, 08:01 PM   #6
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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, 12:02 AM   #7
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 24

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, 12:28 AM   #8
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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, 07:24 AM   #9
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 24

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, 08:40 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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 08:47 AM.
 
Old 08-04-2008, 02:07 PM   #11
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Let's hope proxychains doesn't get iamback fired or booted from his network.
 
Old 08-04-2008, 02:58 PM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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 03:02 PM.
 
Old 08-10-2008, 12:23 PM   #13
iamback
LQ Newbie
 
Registered: Sep 2007
Posts: 24

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



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 05:25 AM
difference between "Web server local URL" and "IPv4 address"? kpachopoulos Linux - General 2 09-17-2004 01:30 PM
Apache gives [alert] mod_unique_id: unable to gethostbyname ("") kerrymwarren Linux - Networking 3 08-13-2004 05:01 PM
Apache not starting properly -- "unable to gethostbyname" ColoRambler Linux - Newbie 8 04-24-2004 11:49 PM
"host" ok, but "ping" can't find ip address hardigunawan Linux - Networking 2 05-16-2002 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:16 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
Open Source Consulting | Domain Registration