LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   /etc/hosts resolving before DNS resolving ? (https://www.linuxquestions.org/questions/linux-networking-3/etc-hosts-resolving-before-dns-resolving-111080/)

markraem 11-01-2003 07:40 AM

/etc/hosts resolving before DNS resolving ?
 
Hi ,

I am running RED HAT 8.

I have 2 ethernet interfaces.

-1 eth interface is a DHCP client (and gets IP + DNS entries via DHCP). This interface is connected to an antranet with DNS servers on.

-1 eth interface has a static ip address. This interface is connected to a small LAN

In /etc/hosts, I created some entries that make part of the LAN that is connected to the static interface :
more /etc/hosts
10.10.10.2 server2
10.10.10.3 server3

when I do : ping server2
I notice that the RED HAT sends out a DNS request via the DHCP interface.
Off course there is no reply from that server.
then I got reply message from 127.0.0.1 !!!
I see that no ping request goes out on my static eth interface !!

So, I have following questions :
1. Why does the RED HAT does not look in my /etc/hosts file ?
2. Is there a possibility to first look in /etc/hosts before sending a DNS request ?

david_ross 11-01-2003 08:20 AM

Welcome to LQ.

The config file /etc/host.conf contains the configuration for name resolution order - for more info see:
man host.conf

markraem 11-02-2003 03:39 AM

I looked in the file /etc/host.conf and it contains following line :

order hosts,bind


This means that first hosts file will be looked up and afterwards the bind.

So why does my box first looks out on DNS ?

On my box, IP forwarding is enabled. Can this be a problem ?

Robert0380 11-02-2003 04:39 AM

are teh IPs (10.10.10.X) pingable?

markraem 11-02-2003 04:54 AM

Problem is solved.
For a reason I do not understand, server2 was assigned to 127.0.0.1 in my hosts file.

Since you normally do not need to touch 127.0.0.1 in the hosts file, I completely overlooked this.

I removed the server2 entry 127.0.0.1 from the hosts entry, and problem is solved.

Anyway, I learned that there is a way in changing the resolving order via /etc/host.conf.

This flexibility is according to me not possible on any WIN* platform.

Thansk for your time !


All times are GMT -5. The time now is 08:40 PM.