Howdy, Stranger!

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


Setting your hostname????
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Setting your hostname????

geodirkgeodirk Member

So just how do you set your hostname permanently? I have a CentoOS 5 box running on OpenVZ. From the command prompt I can temporarily set the hostname with the command:
hostname newdomainname.net

From what I read online, you edit your /etc/sysconfig/network file and put the hostname in there as well:

NETWORKING="yes"
GATEWAYDEV="venet0"
NETWORKING_IPV6="yes"
IPV6_DEFAULTDEV="venet0"
HOSTNAME="newdomainname.net"

But as soon as I reboot, both the 'hostname' command and the 'network' file go right back to the original domain.

What is magically changing them back?

Comments

  • change your hostname in /etc/hosts

  • try this:

    vi /etc/rc.d/rc.local

    add there :

    hostname newdomainname.net

    done !

  • CoreyCorey Member

    @geodirk said:
    So just how do you set your hostname permanently? I have a CentoOS 5 box running on OpenVZ. From the command prompt I can temporarily set the hostname with the command:
    hostname newdomainname.net

    From what I read online, you edit your /etc/sysconfig/network file and put the hostname in there as well:

    NETWORKING="yes"
    GATEWAYDEV="venet0"
    NETWORKING_IPV6="yes"
    IPV6_DEFAULTDEV="venet0"
    HOSTNAME="newdomainname.net"

    But as soon as I reboot, both the 'hostname' command and the 'network' file go right back to the original domain.

    What is magically changing them back?

    Openvz resets your containers network configuration on reboot. Do this

    vzctl set --hostname your.hostname.com --save

    Thanked by 1geodirk
  • AThomasHoweAThomasHowe Member
    edited April 2014

    edit: I can't read.

  • @Corey said:
    vzctl set --hostname your.hostname.com --save

    That got me on the right track. The SolusVM control panel always overwrites the container settings. Once I changed it there, the innards of the vm changed.

    Thanks.

  • MonsteRMonsteR Member
    edited April 2014

    nano /etc/sysconfig/network
    add or edit
    HOSTNAME=myserver.domain.com

    now edit it in /etc/hosts
    and make your you type, hostname domain.yourhostname.com

    The 'hostname' command will let you change the hostname on the server that the commandline remembers, but it will not actively update all programs that are running under the old hostname.

    Then a
    /etc/init.d/network restart
    Should do it :)

    Also another note is make sure the solusvm hostname on the panel is up to date.

  • For OpenVZ you can try following:

    chattr +i /etc/hosts

    Now all other actions excepts read will be denied for this file even for root user.

    The same goes for the dns resolvers configuration file '/etc/resolv.conf' if you don't like that default settings back again after a reboot.

    Note that only root user can set or unset this 'immutable' attribute, to unset it run this:

    chattr -i file_name

  • @Corey said:
    vzctl set --hostname your.hostname.com --save

    I could not locate the vzctl command on my VPS, is that perhaps a system command not available to the VPS that is running on OpenVZ?

    P.S just curious about the command, my hostname is setting properly :)

  • ePANePAN Member

    If your host allow to change the hostname, you can do it from your client area (whcms) or solusvm cp. Or just ask your host via ticket to make a change.

  • @gutshotz said:
    P.S just curious about the command, my hostname is setting properly :)

    Yes that command is only available to the host running your VPS

  • rskrsk Member, Patron Provider

    gutshotz said: I could not locate the vzctl command on my VPS, is that perhaps a system command not available to the VPS that is running on OpenVZ?

    P.S just curious about the command, my hostname is setting properly :)

    vzctl is run by your host. It is found on the node.

  • @rsk said:
    vzctl is run by your host. It is found on the node.

    Yup. And I'm puzzled why this was offered as a solution. He did specify he had a VPS, not a node.

  • CoreyCorey Member

    joelgm said: Yup. And I'm puzzled why this was offered as a solution. He did specify he had a VPS, not a node.

    I offered the correct way to set the hostname on an OpenVZ machine. He never said he didn't have access to the hostnode, and if he didn't he can tell the provider to execute the command for him.

  • Corey said: He never said he didn't have access to the hostnode, and if he didn't he can tell the provider to execute the command for him.

    Most people who have containers have no access to the host nodes. And there are better ways to set hostname on a container than bothering the provider for such a simple issue.

    I believe the easiest method would be editing the file /etc/hostname, and then setting the immutable flag on it, as someone has already suggested.

  • DylanDylan Member

    joelgm said: I believe the easiest method would be editing the file /etc/hostname, and then setting the immutable flag on it, as someone has already suggested.

    Even easier is just changing it in Solus, which is what the OP didn't know to do but eventually figured out.

  • @Dylan said:
    Even easier is just changing it in Solus, which is what the OP didn't know to do but eventually figured out.

    Sort of true, I knew that you could change it there, I just didn't know that was the only place you could change it and that if you didn't, Solus would keep overwriting it. @Corey got me on the right track. Thanks again!

  • VPNVPN Member

    @Dylan said:
    Even easier is just changing it in Solus, which is what the OP didn't know to do but eventually figured out.

    My experience with SolusVM has taught me that the setting in the control panel doesn't do anything on the container lol.

  • OkieDoke said: My experience with SolusVM has taught me that the setting in the control panel doesn't do anything on the container lol.

    Same with me.. :D

  • DylanDylan Member
    edited April 2014

    OkieDoke said: My experience with SolusVM has taught me that the setting in the control panel doesn't do anything on the container lol.

    It's supposed to, but there is a SolusVM+OpenVZ bug where the hostname gets stuck (it shows the new one in Solus, but the container keeps the old one). If that happens you have to either manually set and read-only it or ticket the provider and ask them to change it (vzctl still works).

    It seems to be fixed in newer versions and/or with the new bootstrap theme, but it consistently happens for me with providers using the old one.

  • VPNVPN Member

    @joelgm and @Dylan said:

    Glad its not just me then ha.

Sign In or Register to comment.