Set Hostname before deployment

Please add the ability for users to set the hostname beforehand prior to deployment of VPS. Because right now the default hostname is something like vultr.guest.

Sure it's easy to change but wouldn't it be a nice feature to add.


  • You can customize this and many other items on your VM using our startup script feature.
  • How would the script get the name one assigned to the VM in your interface?

    That is what I think would help the most.. been able to name the machine.

    and get that as the hostname.
  • Now all my VPS has the name like root@322. When I doing something, I don't know what machines.
  • edited June 2014
    To change your hostname you need to change your hostname file

    On Ubuntu just type in:
    nano /etc/hostname
    Type your hostname there then save and type the following:
    hostname -F /etc/hostname
    Then restart your server and after you've logged back in, it will say username@your_chosen_hostname
  • So, there is now way for the startup script to know the name one assigned to the VM on the interface?
  • At the moment, no. We will look into making this available via the API though.
  • couldn't you just use the label field thats already there? This seems like a pretty fundamental feature especially for those folks looking to spin up lots of nodes.
  • This is a very old thread... the label has been available via the API for many months now.
  • yes the label IS available but the hostname does not get set to the label - as far as I can see there is no way to provision a host WITH a hostname unless I'm not seeing something?
  • Well for anyone else who has the same issue here is a work around (in the form of a Vultr startup script) for ubuntu/deb. Basically it will set the hostname to whatever your label is set to. (Make sure you replace your API key) :

    apt-get -y install jq

    MAIN_IP="$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' | xargs echo -n $1)"
    VULTR_HOST=$(curl | jq ".[] | select(.main_ip==\"$MAIN_IP\") | .label" | xargs echo -n $1)

    echo $VULTR_HOST > /etc/hostname
    hostname $VULTR_HOST
    hostname -b -F /etc/hostname
  • edited April 2015
    + 1 for setting the default hostname from the label. Right now, all instances get a hostname of "vultr.guest" which is really confusing.
  • still +1, this is annoying :) please add option to set hostname via API thanks
  • edited January 2016
    We are working on finalizing testing for this setting across all our different images and barring any unforeseen issues, it will be available soon.
  • In case anyone is wondering can be done in startup scripts with:

    linux: (Must be done after all other startup script items... and reboot afterwards)

    #change the hostname
    hostnamectl set-hostname MY-NEW-HOST-NAME
    sed -i "s/vultr.guest/MY-NEW-HOST-NAME/g" /etc/hosts

    win: (change hostname and reboot to take effect)
    wmic computersystem where name="%COMPUTERNAME%" call rename name="MY-NEW-HOST-NAME"
    shutdown -r

  • Would this option to set the hostname from the instance label via startup script also work if the new instances are deployed from a snapshot?
  • Vultr startup scripts only run on the initial deployment. If you're planing to use snapshots, you'd have to configure a script to run when your snapshot instance boots before saving the snapshot.
  • edited November 2017
    Here is a script to automatically change the hostname to the label name on new instances deployed via Snapshots.

    1. Place it under /etc/network/if-up.d/hostname
    2. Make file executable (chmod +x hostname)
    3. Replace the API key and make sure you allow access.

Sign In or Register to comment.