Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Does OvZ overwrite /etc/hosts?
New on LowEndTalk? Please Register and read our Community Rules.

Does OvZ overwrite /etc/hosts?

raindog308raindog308 Administrator, Veteran
edited March 2013 in Help

I have an OvZ VPS. There's three IPs (venet0:0 through venet0:2).

I want the VPS's hostname to be the IP associated with venet0:2

So I change /etc/hosts, remove the venet0:0 IP, and put an entry for venet0:2

But when I reboot, I get:

# Auto-generated hostname. Please do not remove this comment.

And the venet0:0 hostname is back.

This is CentOS. There's no dhcp in the the ifcfg-eth* scripts, a grep -R for "Auto-generated" in /etc didn't show anything...

Is this something that OvZ does outside the container?

If so, is the best course of action to have a local init script that replaces /etc/hosts at the end of startup with what I want?


  • PatrickPatrick Member
    edited March 2013

    Yup that's OpenVZ, lock the file so it can't be changed on reboot.

    chattr +i /etc/hosts

  • @raindog308 What about adding A IP pointer DNS record? (Doing it the proper way.)

  • @Janevski this is not directly related, read what he is trying to do and understand we are referring to the host name. Not necessarily having any thing to do with the DNS as there are quite a few services which broadcast this name irrespective of your zone records. Man /etc/hosts if you don't understand. Or setup a fully working MTA in flavors of Postfix, Qmail, and Exim within an hour that are all properly configured and passing full PCI compliance.

    @raindog308 just use a start up file, it isn't worth messing with in any unreliable way when the change is by and large immediate.

  • JanevskiJanevski Member
    edited March 2013

    @natestamm Since i am quite bored enough at this moment and thus not willing to spend time and explain what i have installed and configured so far and how things are working by rule, let me answer You with the following video:

  • natestammnatestamm Member
    edited March 2013


    In modern systems, even though the host table has been superseded by

    DNS, it is still widely used for:

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    *curl_setopt($ch, CURLOPT_URL, '');

  • raindog308raindog308 Administrator, Veteran

    Guys, this really has nothing to do with DNS :-)

    Just trying to control which IP cPanel/WHM picks up as the host's IP.

  • @raindog308 said: this really has nothing to do with DNS

    This. Ok I'll stop. :D

  • @raindog308 said: I want the VPS's hostname to be the IP associated with venet0:2

    Change it within Solus maybe? "Set as Main IP Address"

  • raindog308raindog308 Administrator, Veteran

    Yep, @Francisco pointed out that's the easiest route.

  • emgemg Veteran

    I remember a thread on WHT about this. The OP thought that it was SolusVM, but it must have been OpenVZ that changed the files, not just /etc/hosts. Check out posts 6 and 11 for details about which files are altered.

Sign In or Register to comment.