CentOS Cannot resolve any hostnames

22,752

Solution 1

We found out it was a DNS problem

first we added the and domainname.com to the /etc/hosts file of the workstation. This resolved the issue. So we concluded it was a DNS issue.

after that we queried his DNS servers with 'dig @' which gave no results. Without the proper dns records the workstation will never find the correct hosts.

Solution 2

Your network configuration is hardly the issue here. Is the domain you are testing registered? The first DNS in your list the is the Google public DNS. It won't come up with valid addresses for fictious test domains.

Make sure that only your internal DNS servers are in resolv.conf, and make sure that there are valid records in it for the domain you are testing with.

Share:
22,752

Related videos on Youtube

AnNaMaLaI
Author by

AnNaMaLaI

I am a web developer, Worked on various Social community networking websites and E-commerce websites. Knowledge in Zend/Cakephp/Yii/Magento/Joomla/wordpress/Facebook apps/Twitter apps/ Google map Apis/Yelp Apis/ Janrain Apis

Updated on September 18, 2022

Comments

  • AnNaMaLaI
    AnNaMaLaI almost 2 years

    I am trying to set up a server(PHP/HTTPD) in CentOS. When I use ipaddress to access the website its working fine. But using domain name its not working. So I used ping command to check.

    ping 246.246.44.66 // Working fine 
    ping example.com // ping: unknown host example.com
    

    Here is /etc/sysconfig/network-scripts/ifcfg-eth0:

    DEVICE="eth0"
    TYPE="Ethernet"
    IPV6INIT="no"
    MTU="1500"
    NM_CONTROLLED="yes"
    
    ONBOOT="yes"
    BOOTPROTO="static"
    IPADDR="246.246.44.66"
    NETMASK="255.255.255.0"
    GATEWAY="246.246.44.71"
    

    /etc/sysconfig/network:

    NETWORKING=yes
    HOSTNAME=example.com
    

    /etc/hosts:

    246.246.44.66 example.com
    127.0.0.1   localhost
    

    /etc/resolv.conf:

    domain example.com
    nameserver 8.8.8.8
    nameserver 246.246.44.65
    nameserver 246.246.44.64
    

    while using route command

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    246.246.44.0    *               255.255.255.0   U     0      0        0 eth0
    link-local      *               255.255.0.0     U     1002   0        0 eth0
    link-local      *               255.255.0.0     U     1003   0        0 eth1
    default         246.246.44.1    0.0.0.0         UG    0      0        0 eth0
    

    Please help me. Also correct me if I am wrong because I am programmer not a server admin

    • Koen van der Rijt
      Koen van der Rijt over 9 years
      what is the content of /etc/resolv.conf? You list all kinds of configurations but not the one that matters. In resolv.conf you configure your dns servers. Also in nsswitch.conf what do you have configured for hosts?
    • AnNaMaLaI
      AnNaMaLaI over 9 years
      @KoenvanderRijt I updated question please check that.. It contains the above four lines
    • Koen van der Rijt
      Koen van der Rijt over 9 years
      a reason for a server to not look at your /etc/hosts file first could be because of a line in your /etc/nsswitch.conf file. 'hosts: files dns' this displays the order of resources to check when resolving a hostname. Also you are checking from a different IP and not locally? I might have not picked up on that. if thats the case you either need to check if that domainname is present in the DNS or you can test this by adding the same line in your own hosts file.
    • AnNaMaLaI
      AnNaMaLaI over 9 years
      In my nsswtich.conf: hosts: files dns line is there.. Shall i comment that line ?
    • Koen van der Rijt
      Koen van der Rijt over 9 years
      no dont comment it. It should be there. Can you please explain how you are testing this? from a browser on a different machine?
    • Neoburner
      Neoburner over 9 years
      Judging that you can ping yourself on IPADDR="246.246.44.66" have a check for your routes by doing a: route -a
    • AnNaMaLaI
      AnNaMaLaI over 9 years
      I didnt get you clearly
    • Koen van der Rijt
      Koen van der Rijt over 9 years
    • Neoburner
      Neoburner over 9 years
      Check the routes on your server, and check traffic is going out your default gateway... post the output of route -a here
    • AnNaMaLaI
      AnNaMaLaI over 9 years
      yes check my question updated the route things
    • Neoburner
      Neoburner over 9 years
      Can you ping 246.246.44.1 ?
  • Koen van der Rijt
    Koen van der Rijt over 9 years
    @Håvid Falch makes a good point also.
  • AnNaMaLaI
    AnNaMaLaI over 9 years
    Thanks @Koen for your support via chat to debug the problem