Mailing List Archive

Can I avoid DNS lookup for servername?
Hi all,
I have configured a VH using private as well as public IP. I would like
to make sure
that the requests from the server ( on which apache is running ) are
resolved locally -
without any DNS lookup. I have specified the private IP with servername in
the /etc/hosts.
But any request from from the server still do the DNS lookup.
Any suggestions on how to avoid DNS lookup?

Here is the VH section
<VirtualHost 10.x.x.2 213.x.x.250>
ServerName dtd.mydomain.com
...
</VirtualHost>


The /etc/hosts file:
127.0.0.1 localhost
10.x.x.2 dtd.mydomain.com


Appreciate your help,
Santosh






---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Can I avoid DNS lookup for servername? [ In reply to ]
Santosh Deshpande wrote:
>
> Hi all,
> I have configured a VH using private as well as public IP. I would like
> to make sure
> that the requests from the server ( on which apache is running ) are
> resolved locally -
> without any DNS lookup. I have specified the private IP with servername in
> the /etc/hosts.
> But any request from from the server still do the DNS lookup.
> Any suggestions on how to avoid DNS lookup?
>
> Here is the VH section
> <VirtualHost 10.x.x.2 213.x.x.250>
> ServerName dtd.mydomain.com
> ...
> </VirtualHost>
>
> The /etc/hosts file:
> 127.0.0.1 localhost
> 10.x.x.2 dtd.mydomain.com

The order of technique for name resolution is controlled by
/etc/nsswitch.conf. If you have a line like:

hosts: files dns

then your machine will first look in "files" (i.e. /etc/hosts) then, if
it doesn't resolve the name, use DNS.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: Can I avoid DNS lookup for servername? [ In reply to ]
what happens if the the line
hosts: files dns
is commented out? Does it not look in the /etc/hosts first anyway?

regards,
Santosh


-----Original Message-----
From: obo@bourse.ch [mailto:obo@bourse.ch]
Sent: 18 February 2002 12:46
To: users@httpd.apache.org
Subject: Re: Can I avoid DNS lookup for servername?


Santosh Deshpande wrote:
>
> Hi all,
> I have configured a VH using private as well as public IP. I would like
> to make sure
> that the requests from the server ( on which apache is running ) are
> resolved locally -
> without any DNS lookup. I have specified the private IP with servername
in
> the /etc/hosts.
> But any request from from the server still do the DNS lookup.
> Any suggestions on how to avoid DNS lookup?
>
> Here is the VH section
> <VirtualHost 10.x.x.2 213.x.x.250>
> ServerName dtd.mydomain.com
> ...
> </VirtualHost>
>
> The /etc/hosts file:
> 127.0.0.1 localhost
> 10.x.x.2 dtd.mydomain.com

The order of technique for name resolution is controlled by
/etc/nsswitch.conf. If you have a line like:

hosts: files dns

then your machine will first look in "files" (i.e. /etc/hosts) then, if
it doesn't resolve the name, use DNS.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Can I avoid DNS lookup for servername? [ In reply to ]
Santosh Deshpande wrote:
>
> what happens if the the line
> hosts: files dns
> is commented out? Does it not look in the /etc/hosts first anyway?

Probably. According to my man page for nsswitch.conf:

"The library functions contain compiled-in default entries that are
used if the appropriate entry in nsswitch.conf is absent or
syntactically incorrect."

The underlying function in this case is gethostbyname() - I suppose its
default value is system dependent, but /etc/hosts would be a good
default (works on any system - even without a network).

However, since there's a mechansim for setting the order, why not use
it? if you say:

hosts: files

then you can be sure gethostbyname() will *only* look in /etc/hosts and
*will not* use DNS for name resolution.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Can I avoid DNS lookup for servername? [ In reply to ]
On Mon, Feb 18, 2002 at 02:34:04PM -0000, Santosh Deshpande wrote:
> what happens if the the line
> hosts: files dns
> is commented out? Does it not look in the /etc/hosts first anyway?

It depends on what the default is. On my RH 7.2 machine,
'man nsswitch.conf' indicates the default is dns and then files.

Maurice

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: Can I avoid DNS lookup for servername? [ In reply to ]
Thank you, Maurice/Owen. My best bet would to define it in 'nsswitch.conf'.

rgds,
Santosh


-----Original Message-----
From: Maurice Aubrey [mailto:maurice@hevanet.com]
Sent: 18 February 2002 14:42
To: users@httpd.apache.org; santosh.deshpande@office.sourceree.com
Subject: Re: Can I avoid DNS lookup for servername?


On Mon, Feb 18, 2002 at 02:34:04PM -0000, Santosh Deshpande wrote:
> what happens if the the line
> hosts: files dns
> is commented out? Does it not look in the /etc/hosts first anyway?

It depends on what the default is. On my RH 7.2 machine,
'man nsswitch.conf' indicates the default is dns and then files.

Maurice

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org