#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    51
    Rep Power
    9

    Can't ping hostnames, only IPs


    Trying to transition all my machines over from XP to Ubuntu, but I'm running into the same problem on every Ubuntu machine...

    Internet works fine, and I can get to places like google.com by name. But when I try to ping hostnames on my home network from Ubuntu, the ping says "ping: unknown host <HOST>". If I ping IPs on the local network (e.g. ping 192.168.1.1), this goes through fine...

    This also happens the other way around (pinging Ubuntu machines from other machines). Can't ping hostnames, only IPs.

    Any idea what's wrong??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    407
    Rep Power
    25
    Originally Posted by johnnybeem
    Trying to transition all my machines over from XP to Ubuntu, but I'm running into the same problem on every Ubuntu machine...

    Internet works fine, and I can get to places like google.com by name. But when I try to ping hostnames on my home network from Ubuntu, the ping says "ping: unknown host <HOST>". If I ping IPs on the local network (e.g. ping 192.168.1.1), this goes through fine...

    This also happens the other way around (pinging Ubuntu machines from other machines). Can't ping hostnames, only IPs.

    Any idea what's wrong??
    you might have to add all the IP's into DNS, I don't think unix works the same as windows in regards to DNS, I think that Windows broadcasts all the names around the network, but Im not sure if *nix does.

    Try adding them to DNS and see what happens

    should work
  4. #3
  5. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Sep 2007
    Location
    outside Washington DC
    Posts
    2,642
    Rep Power
    3699
    Originally Posted by johnnybeem
    This also happens the other way around (pinging Ubuntu machines from other machines). Can't ping hostnames, only IPs.
    Pretty clearly you don't have proper host name resolution.
    on windows, use nslookup in a shell.
    on real OS, use dig in a shell.

    Find out why you can't resolve the names, fix that.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    51
    Rep Power
    9
    alright, well I did some google-ing and got it working almost how I want it...

    I installed some avahi, mdns, zeroconf packages (forget which ones) and now can ping from Windows <--> Ubuntu by pinging HOSTNAME.local

    Still can not ping actual hostnames (e.g. ping HOSTNAME)... However, strange thing is I started a Samba server on one Ubuntu computer and now from Windows I can "ping HOSTNAME". Could *not* do that before I started Samba.

    On Ubuntu, I still need to ping everything with .local

    Does anyone know if it's possible to ping without requiring the .local extension?? There must be a way
  8. #5
  9. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Sep 2007
    Location
    outside Washington DC
    Posts
    2,642
    Rep Power
    3699
    I'm not exactly sure I understand the problem you are describing, but if you have luck with :

    ping foo.local

    but

    ping foo

    fails, then you need to set your "default search domain'

    In Debian/Ubuntu, you can add the line:
    domain mydomain.com
    in your /etc/resolve.conf

    Not sure what the equivalent is in Windows

    Comments on this post

    • Edvallie agrees : right-on
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Location
    amsterdam
    Posts
    1
    Rep Power
    0

    a possible solution


    Originally Posted by fishtoprecords
    I'm not exactly sure I understand the problem you are describing, but if you have luck with :

    ping foo.local

    but

    ping foo

    fails, then you need to set your "default search domain'

    In Debian/Ubuntu, you can add the line:
    domain mydomain.com
    in your /etc/resolve.conf

    Not sure what the equivalent is in Windows
    In linux and windows there are host files
    in linux /etc/hosts in windows \windows\system32\drivers\etc\hosts + lmhost in those files you add
    entries like ip address hostname ( it's kind of an alternative
    to setting up a dns) in windows you tell inthe network setting
    ( the advanced setting to use the host file.

    When you ping the hostname of a computer the right
    ip address replies the same goes for linux\

    good luck

    linosi
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    39
    Rep Power
    6
    Windows also added netbios names which can be resolved by lmhosts, wins server or name query broadcast messages ... which helps any windows computer on the local network be able to find another by name without the help of dns servers, etc.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Location
    Philadelphia,PA
    Posts
    1
    Rep Power
    0

    Arrow A possible name problem solution.


    If your local network is small, you could do the following. Copy a single file /etc/hosts file to each of the machines on your network. This file maps
    computer names to IP addresses.
    This method becomes little unwieldy if you have a lot of machines on the network, if so then I suggest writing a shell script to automate this process a little bit, using the rcp command, or even better the rsync command.
    Another option is that you could run a local name server and have all of the
    local machines first try to resolve the ip addresses on the local DNS first, and then use the network DNS provider if there is no name to IP matching.
    This way you only have one file to update and transfer one file.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    2
    Rep Power
    0

    Try this little trick....


    before you all get too carried away.

    when winbind is installed, it's always nice to add "wins" to the hosts: line in /etc/nsswitch.conf.

    Code:
    hosts:          files dns mdns wins
    This will allow ordinary TCP/IP programs to resolve hostnames with netbios, so you can, for instance, do "ping <hostname>" instead of "ping 192.168.1.xxx". Of course, ping isn't all that wonderful, but it's a lot easer to do "ftp hostname" or "ssh hostname" or browse to "http://hostname" than using raw IP's for the local machines (assuming of course they are running the given service and the forewall on the target machine allows access to the right ports).
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    407
    Rep Power
    25
    Well done - you've dug up a 4 year old thread....

    Originally Posted by m_drunk
    before you all get too carried away.

    when winbind is installed, it's always nice to add "wins" to the hosts: line in /etc/nsswitch.conf.

    Code:
    hosts:          files dns mdns wins
    This will allow ordinary TCP/IP programs to resolve hostnames with netbios, so you can, for instance, do "ping <hostname>" instead of "ping 192.168.1.xxx". Of course, ping isn't all that wonderful, but it's a lot easer to do "ftp hostname" or "ssh hostname" or browse to "http://hostname" than using raw IP's for the local machines (assuming of course they are running the given service and the forewall on the target machine allows access to the right ports).
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    2
    Rep Power
    0
    Originally Posted by punkboii
    Well done - you've dug up a 4 year old thread....
    Yeah well....think Google cares how old it is? Top spot in Google with no answer. And while everything above is right, it's not how the problem is generally solved.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    407
    Rep Power
    25
    Can't really say fairer than that...

    Originally Posted by m_drunk
    Yeah well....think Google cares how old it is? Top spot in Google with no answer. And while everything above is right, it's not how the problem is generally solved.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,442
    Rep Power
    1688
    Yeah, but any question to which the suggested answer is, "let's add WINS ..." is just a wrong question!!! <troll/>
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo