4

I have a computer with Debian at home, acting as a server with two Ethernet cards: eth0 connected to the router in DHCP mode and eth1 to a switch (static address) that holds four more computers.

I'm using the PC to be the gateway-firewall of the others. Since I only have four more PCs in the internal network, I don't want to set up BIND on the server. It is easier to use the file hosts to solve the names of the four PCs, but I can't make the server look into the file /etc/hosts. The server has no configuration at all; it's only using the defaults gotten from my ISP. How can I make the server resolve the addresses in the file hosts?

2 Answers 2

8

That's because the /etc/hosts is simply a file on your Debian server that it utilizes for its own name resolution.

It doesn't use the file to provide any DNS services.

Since you don't want to set up BIND can I recommend that you look at dnsmasq instead?

It's lightweight and can act as a DNS and DHCP server, simply by making use of your hosts file.

4
  • i can't even solve it from the server. I type "host" then tab and it shows the list of the PCs but it doesn't solve it Commented May 14, 2015 at 15:50
  • 1
    dnsmasq really is the way to go for this type of small configuration. Really. Go on. Try it. Commented May 14, 2015 at 15:58
  • 1
    I use dnsmasq for almost exactly this situation. I found that dnsmasq configuration wasn't particularly easy, so maybe you should pick this as THE answer, then try to get dnsmasq to do what you want, asking questions about dnsmasq instead. Commented May 14, 2015 at 16:31
  • @roaima i tried and it works great, i didn't have to config re-solvers or create a zone like I used to do with bind9. dnsmasq is certainly recommended for simple networks where no special configurations is required. +1 Commented May 16, 2015 at 12:12
2

I believe what you're looking for is in /etc/nsswitch.conf

From the man page: The Name Service Switch (NSS) configuration file, /etc/nsswitch.conf, is used by the GNU C Library to determine the sources from which to obtain name-service information in a range of categories, and in what order. ...

   Here is an example /etc/nsswitch.conf file:

       passwd:         compat
       group:          compat
       shadow:         compat

       hosts:          dns [!UNAVAIL=return] files
       networks:       nis [NOTFOUND=return] files
       ethers:         nis [NOTFOUND=return] files
       protocols:      nis [NOTFOUND=return] files
       rpc:            nis [NOTFOUND=return] files
       services:       nis [NOTFOUND=return] files

Set:

hosts: files dns

in your /etc/nsswitch.conf, and the machine should then use the hosts file first for host information, then fallback to the DNS.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.