Cannot ping linux (RedHat) machine by hostname

7,559

Solution 1

In order to ping a device by name, the name -> IP mapping must be in the DNS server's zone file for that domain. This has nothing to do with any configuration on the actual device itself - in fact, almost nothing you do on the machine will have any effect on what the name is.

Solution 2

In case you don't have access to your DNS machine, you can do the following: You can also add a entry in /etc/hosts file in a machine which you are using to ping your linux machine. Follow below steps

If you are using windows machine to ping your linux machine: 1) Go to start and click on RUN or (windows+r) 2) Type drivers and hit enter 3) Navigate to etc folder and edit hosts file 4) Add the entry here like . Localhost entry which is added there will give you hint of how to add the entry. And it's done.

If you are using linux machine to ping then 1) run 'vi /etc/hosts' command 2) Add a entry here same way mentioned for windows also 3) Save it :wq 4) service network restart (may not need it) and you are done.

Share:
7,559
O_O
Author by

O_O

Updated on September 18, 2022

Comments

  • O_O
    O_O over 1 year

    For some reason, a linux (RedHat) machine that I have is not ping-able by hostname! It is ping-able by IP address though. I have the same network configurations as another linux (RedHat) machine that is ping-able by hostname and IP address, and I'm not sure where I'm going wrong.

    Is there any other steps you see besides these:

    1. Under Network Configuration, select the eth0 device in the Devices tab, press on the Edit icon, and set Manual IP Address Settings. Ok, so this isn't probably necessary.. you can probably leave it on Automatically obtain IP address settings with dhcp, but I just wanted to show you guys what I have in my config.
    2. In the DNS tab, set the hostname, DNS & DNS search path.
    3. In the Hosts tab, set the IP address and hostname again.

    The command hostname on the machine's cmd does show my configured hostname from the DNS and Hosts tab.

  • O_O
    O_O over 12 years
    This totally makes sense. Gasp, and I just got it pinging. WooohooO!