Adding/overwriting hosts to /etc/hosts on DEBIAN (And OpenMediaVault)

Leave a comment

September 28, 2012 by aubreykloppers

This took me a while to understand.  Basically you need to add a script to your /etc/init.d/ directory, Change the ACL and add the script to your RC-LEVELS.


a. create a file /etc/init.d/ and add the following content:

# Provides: /etc/hosts
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start hosts file

case “$1” in

echo “Starting script blah ”
echo “Could do more here”

echo “#Added by Aubrey” >/etc/hosts
echo “ localhost” >>/etc/hosts
echo “ MYHOST” >>/etc/hosts
echo “” >>/etc/hosts
echo “# SERVERS” >>/etc/hosts
echo “ myhost1” >>/etc/hosts
echo “ myhost2” >>/etc/hosts



echo “Usage: /etc/init.d/ {start}”
exit 1

exit 0

b. Change the acl:

chmod 755

c. write the file to your rcX.d directories:

update-rc.d defaults


1. Remember the HEADER of the file must be EXACT, else it will fail.

2. Setting the ACL.

That’s it.  Works like a charm!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

counter for wordpress
%d bloggers like this: