LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   quick DCHP question (https://www.linuxquestions.org/questions/linux-newbie-8/quick-dchp-question-72765/)

dcruz 07-14-2003 08:46 PM

quick DCHP question
 
Hi.

I read that RH9 will perform better if you enter the hostname and IP in /etc/hosts. In fact I did find thats true and RH seems speedier now. How do I have it dynamically update that file if the machines grabs another DCHP address?

jpbarto 07-15-2003 12:15 AM

linux gurus help me out on this one... /etc/hosts is an alternative to DNS name resolution. Why would redhat run faster if the localhost's machine would be entered into /etc/hosts?

dcruz, I'm not sure if a dhcp client such as dhcpcd would have such a feature. However you could easily write a small bash script that you could set to execute after you've pulled an IP address that would rewrite your /etc/hosts file.

MasterC 07-15-2003 12:33 AM

What's faster? Everything, or just getting online?

I know linux is built all around client/server framework, so maybe several applications that RH uses take the /etc/hosts into consideration? It might just be some of the services a user has starting that it increases the speed on, and then if that process completes correctly, other processes won't fumble over it?
Just thoughts...

Cool

amosshapira 07-15-2003 01:03 AM

Install a local caching DNS server
 
I'd suggest attacking this from another angel - instead of having to update a static (and sensitive) text file you might better install a caching DNS server on your system.

I'm a Debian user so I don't know RH and can't check things up myself, but in general what happens is that whenever your system has to translate its name into an address (or vice versa), it does the following:

1. Look in /etc/nswwitch.conf, it probably says:

hosts: files dns

2. Go to /etc/hosts, don't find the answer there.
3. Go to the DNS server configured in /etc/resolv.conf, probably over a line to your ISP.

So you can shorten times (and generally make your system resolve names and addresses quicker) by installing a caching DNS server and configuring your /etc/resolv.conf to something like:

nameserver 127.0.0.1
<rest of existing nameservers - they won't be used anymore but some caching DNS servers use this file for their own configuration, it depends which one you install>

Which means your DNS queries will access your own caching server - this caching server will only answer from the cache it built up, or recursively query "real" DNS server and cache their answers for you.

Again, since I'm not a RH user I can't point you to the right package to install without doing some digging, and since you have RH installed on your machine then you must be in a better position to start the digging than me.

(General security advice - if you haven't setup a firewall yet then do it, block all ports including port 53 (the DNS port). You don't need to allow outside access to this port in order to make the caching server work. You might also be able to tell the caching DNS server to listen only on the localhost interface, that would be a good thing in addition to a firewall)

jpbarto 07-15-2003 08:30 AM

amosshapira, I agree. I was just about to say the same thing. /etc/hosts is simply a text-file DNS. By running named locally and telling it simply to cache addresses you'll get the equivallent of a dynamic /etc/hosts plus all the supposed speed boosts of having all those IP addresses already available. And named doesn't punish you with much overhead so you're cpu performance and so on won't take much of a hit. Now if only I could teach my damned DLink router to run a DNS for my whole network I'd be in business.

amosshapira 07-15-2003 11:31 AM

Quote:

Originally posted by jpbarto
Now if only I could teach my damned DLink router to run a DNS for my whole network I'd be in business.
Does your DLink router have DNS and you just have problem configuring it?
In any case - why not configure your Linux as the DNS server for the network?
I'm not familiar with the properties of this router, but generally having everything else go through your Linux also gives you an excellent firewall.

cydd420 07-16-2003 08:54 AM

You could also try changing the /etc/resolv.conf file to not include you localhost. This would force it to only use DNS to get names resolved on the internet.

amosshapira 07-16-2003 11:25 AM

Quote:

Originally posted by cydd420
You could also try changing the /etc/resolv.conf file to not include you localhost. This would force it to only use DNS to get names resolved on the internet.
Who are you answer to?
The idea behind my suggestion was that you ask a DNS caching server on the local machine which will either:[list=1][*]Find the answer in its cache.[*]Lookup the answer via other DNS servers, cache it and return it.[/list=1]
So what's the benefit of removing the localhost from /etc/resolv.conf?
Also it still won't prevent programs from looking up /etc/hosts, that's controlled by the "files" in /etc/nsswitch.conf.


All times are GMT -5. The time now is 12:21 PM.