Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've been having a problem where when our vps provider decides to restart the server (running Debian 5.0.8), the server fails to remember changes to /etc/hosts. All I need is an database alias that is used for the web applications on the server which points to 127.0.0.1 (localhost).

I want it to look like this:

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


127.0.0.1 localhost.localdomain localhost webservice database
# Auto-generated hostname. Please do not remove this comment.
XXX.XX.XXX.XX xxxxxx.net.au  xxxxxx www.xxxxxxx.net.au xxxxxxx

However whenever there is a reboot it resets itself to:

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


127.0.0.1 localhost.localdomain localhost webservice
# Auto-generated hostname. Please do not remove this comment.
XXX.XX.XXX.XX xxxxxx.net.au  xxxxxx www.xxxxxxx.net.au xxxxxxx

without the database, and I have to manually change the file to get things to work. This has been happening for awhile and has become a nuisance, but I can't seem to find a way to get changes to stick. Anyone know what to do?

share|improve this question

migrated from stackoverflow.com Jul 11 '11 at 3:12

This question came from our site for professional and enthusiast programmers.

    
Are you using a VPS? –  freedompeace Jun 16 '11 at 6:09
    
@zclark I do not see any difference between the two files you mentioned.Is that a type error or there is some thing which I missed? –  Registered User Jun 16 '11 at 6:15
    
Yeah I'm using a VPS. The difference in the files is that I add "database" to the end of the line starting with 127.0.0.1. –  zclark Jun 16 '11 at 6:17
    
@zclark Do you happen to have Network Manager or something similiar running? It does have some strange ideas wrt the 127.0.0.1-line. Otherwise, I’d suspect your hosts’ script doing strange stuff, as it already seems to be tampering with your /etc/hosts (# Auto-generated hostname. Please do not remove this comment.). –  Registered User Jun 16 '11 at 8:40
    
@zclark Try adding a new line pointing to "database" like this and see if that persists: 127.0.0.1 database –  Registered User Jun 16 '11 at 8:41

1 Answer 1

up vote 2 down vote accepted

Removing the #Auto-generated hostname line and then making the changes caused whatever was generating the host names to remember it now. Works for me but this may not work for everyone.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.