Tuesday, July 24, 2012

"Unknown Host" When Pinging Local Debian Machine

I recently had a problem where pinging a machine by its IP works, but pinging by its hostname yielded the following error message:

ping: cannot resolve HOSTNAME: Unknown host

Here is my setup:
  • HOSTNAME is a machine running Debian 6.0.5 Squeeze with HOSTNAME as its hostname.
  • WINDOWS is the hostname of the Debian machine when Windows 7 is running
    • Windows 7 was installed & used prior to Debian
  • MAC is the machine that I am trying to ping HOSTNAME from
  • Both computers are connected to a Buffalo AirStation WHR-HP-G300N running its default firmware, DD-WRT. All computers use DHCP to get an IP address.

 

The Quick Fix

    'ping WINDOWS' results in successfully pinging the Debian machine. This is because the router has WINDOWS as the host name for the machine at HOSTNAME's IP address. Treating 'WINDOWS' as the hostname for the Debian machine is a quick fix for this issue.

     

    The Slightly Less Quick, But Preferred Fix

    By default, Debian does not send its hostname when getting an IP address with DHCP. Edit '/etc/dhcp/dhclient.conf' and replace this line:

    #send host-name "andare.fugure.com";

    With this line:
    send host-name "HOSTNAME";


    I restarted MAC and HOSTNAME and was successfully able to ping HOSTNAME.