Debian – ping a domainname in /etc/hosts

debianlinux-networkingping

I am new in Linux. I want to test postfix. My Computer is a Mac G4 (AGP-Grafik, CPU 350 Mhz), running Debian Lenny.
Gateway 192.168.2.1
The Gateway I need for the router. The router connects two Computers to a printer.
IP-address of the machine: 192.168.2.111
Servername for postfix: brauneck.sul

brauneck:/etc/network# hostname -v
brauneck.sul

brauneck:/etc/bind# named-checkzone 192.168.2.in-add.arpa db.192.168.2   
zone 192.168.2.in-add.arpa/IN: loaded serial 1   
OK 
brauneck:/etc/bind# named-checkzonebrauneck.sul.inadd.arpadb.192.168.2   
zone brauneck.sul.in-add.arpa/IN: loaded serial 1   
OK   
brauneck:/etc/bind#  

To send a ping-command to localhost and brauneck.sul works without problems.

I want to create a new domainname. I put "www.stachelbeere.sul" in the /etc/hosts file with the IP Nr. 192.168.2.170.

brauneck:/etc/init.d# vim /etc/hosts   
#Die Datei /etc/hosts 
#27.10.16 nach www.unix.com/aix/90234...einfuegen von IPv4   
hosts=local4,bind4   
127.0.0.1 localhost loopback   
192.168.2.170 www.stachelbeere.sul stachelbeere  

The searching order in nsswitch.conf is: First files, then dns!
Additional I put the order in the file /etc/resolv.conf, first hosts and then bind – "order hosts bind", but it seems not necessary.

Now some questions:

  1. It doesn't matter whether the netword-card is up or down, I can ping localhost and my computer's name "brauneck.sul", but not the domainname www.stachelbeere.sul in the /etc/hosts file. I get "Destination Host Unreachable" or "Network is unreachable".

  2. Is it possible at all to send a ping-command to a domain in /etc/hosts? Or is it just in the old Linux Debian Lenny impossible?

  3. My own answer is (but I am not sure), the domains in the /etc/hosts file are used for a local network (LAN), so every hostname should go through the router to another computer, except localhost and the own server, here brauneck.sul.

Would be glad for some answers. Greetings from Leo

Best Answer

Here are the answers:

  1. You can ping localhost and computer name because they refer to the same machine (local machine) which resolves to 127.0.0.1. This has nothing to do with interface such as eth0. Traffic to 127.0.0.1 does through lo interface.
  2. You can send ping echo packet to any name as far as it is resolvable by your machine (either through hosts file or through DNS server).
  3. Not so accurate. The names are resolved by /etc/hosts or configured DNS servers in /etc/resolv.conf according to priority defined in /etc/nsswitch.conf.