1

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

12
  • 1
    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? Commented Feb 3, 2015 at 9:23
  • @KoenvanderRijt I updated question please check that.. It contains the above four lines
    – AnNaMaLaI
    Commented Feb 3, 2015 at 9:29
  • 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. Commented Feb 3, 2015 at 9:35
  • In my nsswtich.conf: hosts: files dns line is there.. Shall i comment that line ?
    – AnNaMaLaI
    Commented Feb 3, 2015 at 9:38
  • no dont comment it. It should be there. Can you please explain how you are testing this? from a browser on a different machine? Commented Feb 3, 2015 at 9:41

2 Answers 2

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.

2
  • @Håvid Falch makes a good point also. Commented Feb 3, 2015 at 10:51
  • Thanks @Koen for your support via chat to debug the problem
    – AnNaMaLaI
    Commented Feb 3, 2015 at 10:52
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .