1820711 Members
3216 Online
109627 Solutions
New Discussion юеВ

updating /etc/hosts

 
shashi kanth
Super Advisor

updating /etc/hosts

After adding few hosts and their IP address in /etc/hosts file, what service we need to restart in-order to changes will effect ?


If i add a host-IP in /etc/hosts file, and if i try to to ping the host_name immediately, then the resolving host-name_to_IP is not happening.

I believe, in-order to changes will effect, we need to restart the resolver, what is the right command to restart the resolver ?
8 REPLIES 8
Sandy Chen
Honored Contributor

Re: updating /etc/hosts

after updating /etc/hosts you doesn't have to restart any services. have you tried to ping the host using ip address?

regards,
sandy
I never think of the future. It comes soon enough.
shashi kanth
Super Advisor

Re: updating /etc/hosts

Yes, it is pinging the IP, but not with name.
Jeeshan
Honored Contributor

Re: updating /etc/hosts

after adding the hostname along with IP in /etc/hosts file, you must able to ping by name.

Post your /etc/hosts entries.
a warrior never quits
Asif Sharif
Honored Contributor

Re: updating /etc/hosts

HI Shashi,

It should ping, No, the change takes effect immediately.

see the Example /etc/hosts

The following /etc/hosts entry contains an IP address, hostname, and alias names (host3.site2.region4 and grace).

#cat /etc/hosts
192.6.1.1 host3 host3.site2.region4 grace

Regards,
Asif Sharif
Regards,
Asif Sharif
Torsten.
Acclaimed Contributor

Re: updating /etc/hosts

Check if you really use the hosts file, or even DNS only!

see

http://docs.hp.com/en/B3921-60631/nsswitch.conf.4.html

/etc/nsswitch.conf

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
shashi kanth
Super Advisor

Re: updating /etc/hosts

Ok, i found the problem.

The host which i have added into the /etc/hosts file is also having any entry in the DNS.

If i remove the DNS server in /etc/resolv.conf, then it is pinging.

Now i am facing another problem.

Whenever i rebooted the box, the DNS server is automatically adding into /etc/resolv.conf , even though i explicitly removed the DNS server entry in /etc/resolv.conf file.

How to solve this issue ?

I don't want my system to use DNS server for resolving. But i can't remove /etc/resolv.conf file because my application needs the domain name and it will check /etc/resolv.conf for domain name.
Torsten.
Acclaimed Contributor

Re: updating /etc/hosts

/etc/nsswitch !

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   

Re: updating /etc/hosts

did you check your nsswitch file.