[root@ns1 ~]# cat /etc/hostname
ns1.lgichn.com
[root@ns1 ~]# cat /etc/hosts
127.0.0.1 ns1 ns1.lgichn.com
::1 ns1 ns1.lgichn.com
[root@ns1 ~]# cat /etc/host.conf
order hosts,bind
multi on
nospoof on
[root@ns1 ~]# host ns1.lgichn.com
Host ns1.lgichn.com not found: 3(NXDOMAIN)
Any help is appreciated..
/etc/hosts entries are not working
Re: /etc/hosts entries are not working
host/nslookup resolve dns queries directly using nameservers. They do not use /etc/hosts. If you want to resolve hostnames from /etc/hosts then you need to use getent:
Code: Select all
getent hosts ns1.lgichn.com
Re: /etc/hosts entries are not working
I think host command can get the IP address of an hostname from /etc/hosts file.
I have been using the same method on CentOS 6 without using any DNS to resolve hostname to IP.
I have been using the same method on CentOS 6 without using any DNS to resolve hostname to IP.
Re: /etc/hosts entries are not working
Centos 6 should behave in exactly the same way as Centos 7 as regards the host command, it is a DNS lookup. If it works for this local hostname on a particular system I would hazard a guess that the system is set up as a nameserver, host and nslookup do not work with local /etc/hosts files. Check the man pages to confirm this:
HOST(1) BIND9 HOST(1)
NAME
host - DNS lookup utility
...