Revert/Prevent hostname change





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















This is a shot in the dark here ...



I'm using a service called Strato-Server-Cloud which is basicaly a rudimentary version of AWS or Google-Compute. They changed their interface and/or engine recently. Ever since, all new Ubuntu 16 instances I create have the problem of thier hostname being reverted on reboot.



Here is what I usually do:



/etc/hostname



www.example.com


/etc/hosts



127.0.0.1 www.example.com www
[...]


On Ubuntu 16 additionally:



hostnamectl set-hostname www


After doing the steps above:



hostname -> www
hostname -f -> www.example.com


hostnamectl



Static hostname: www
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


After reboot rebooting



hostname -> XXX
hostname -f -> XXX.strato.net


hostname-ctl



Static hostname: www
Transient hostname: XXX
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


Note the transient hostname



Oddly enough the hosts and hostname files are intact.



I Also tried changing /etc/init/hostname.conf to the following



description     "set system hostname"

start on startup

task
exec hostname -b -F /etc/hostname.mod; full=$(cat /etc/hostname.mod);short=(${full//./ }); hostnamectl set-hostname $short


I put the hostname also in /etc/hostname.mod to ensure there is no overwriting going on. Executing the above exec-statement manually fixes everything but it doesn't seem to be effective during the boot-sequence ...



Unfortunately I'm pretty lost here ... I would assume the /etc/init/hostname.conf gets executed during boot but then the hostname gets overriden by another script? Has anyone ever had such an issue and knows how to fix it?
I guess I could look into some linux version of a file-spy that documents what processes touch which files and find the offending script that way ... This does sound like a lot of work however ...



If someone could at least point out the livecycle of the hostname, that is the steps of how it is determined and where one could hook into this would already help me a lot.



Thanks in advance for your time and effort



Edit



I guess it would also help to explain why this is bad :-) OpenLDAP refuses to work correctly in STARTTLS mode if the hostname isn't properly configured. Since I never had the problem of not being able to change the hostname I don't know what other service might malefunction as well. A minimal solution to the problem would therefor have to become effective before service like OpenLDAP are started.










share|improve this question




















  • 1





    How does this computer get its IP address? dhcp? If yes, try to delete host-name from the request line in /etc/dhcp/dhclient.conf.

    – Doug Smythies
    Jan 23 '17 at 15:01











  • @doug Mister Smythies you da man! You know of all the things I considered like their hypervisor messing with the virtual disk image on reboot, I never imagined it to be something this stupid. Indeed there was a host-name directive and deleting it fixed everything. Make your comment an anwser and I accept it.

    – user3240383
    Jan 23 '17 at 15:28


















1















This is a shot in the dark here ...



I'm using a service called Strato-Server-Cloud which is basicaly a rudimentary version of AWS or Google-Compute. They changed their interface and/or engine recently. Ever since, all new Ubuntu 16 instances I create have the problem of thier hostname being reverted on reboot.



Here is what I usually do:



/etc/hostname



www.example.com


/etc/hosts



127.0.0.1 www.example.com www
[...]


On Ubuntu 16 additionally:



hostnamectl set-hostname www


After doing the steps above:



hostname -> www
hostname -f -> www.example.com


hostnamectl



Static hostname: www
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


After reboot rebooting



hostname -> XXX
hostname -f -> XXX.strato.net


hostname-ctl



Static hostname: www
Transient hostname: XXX
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


Note the transient hostname



Oddly enough the hosts and hostname files are intact.



I Also tried changing /etc/init/hostname.conf to the following



description     "set system hostname"

start on startup

task
exec hostname -b -F /etc/hostname.mod; full=$(cat /etc/hostname.mod);short=(${full//./ }); hostnamectl set-hostname $short


I put the hostname also in /etc/hostname.mod to ensure there is no overwriting going on. Executing the above exec-statement manually fixes everything but it doesn't seem to be effective during the boot-sequence ...



Unfortunately I'm pretty lost here ... I would assume the /etc/init/hostname.conf gets executed during boot but then the hostname gets overriden by another script? Has anyone ever had such an issue and knows how to fix it?
I guess I could look into some linux version of a file-spy that documents what processes touch which files and find the offending script that way ... This does sound like a lot of work however ...



If someone could at least point out the livecycle of the hostname, that is the steps of how it is determined and where one could hook into this would already help me a lot.



Thanks in advance for your time and effort



Edit



I guess it would also help to explain why this is bad :-) OpenLDAP refuses to work correctly in STARTTLS mode if the hostname isn't properly configured. Since I never had the problem of not being able to change the hostname I don't know what other service might malefunction as well. A minimal solution to the problem would therefor have to become effective before service like OpenLDAP are started.










share|improve this question




















  • 1





    How does this computer get its IP address? dhcp? If yes, try to delete host-name from the request line in /etc/dhcp/dhclient.conf.

    – Doug Smythies
    Jan 23 '17 at 15:01











  • @doug Mister Smythies you da man! You know of all the things I considered like their hypervisor messing with the virtual disk image on reboot, I never imagined it to be something this stupid. Indeed there was a host-name directive and deleting it fixed everything. Make your comment an anwser and I accept it.

    – user3240383
    Jan 23 '17 at 15:28














1












1








1








This is a shot in the dark here ...



I'm using a service called Strato-Server-Cloud which is basicaly a rudimentary version of AWS or Google-Compute. They changed their interface and/or engine recently. Ever since, all new Ubuntu 16 instances I create have the problem of thier hostname being reverted on reboot.



Here is what I usually do:



/etc/hostname



www.example.com


/etc/hosts



127.0.0.1 www.example.com www
[...]


On Ubuntu 16 additionally:



hostnamectl set-hostname www


After doing the steps above:



hostname -> www
hostname -f -> www.example.com


hostnamectl



Static hostname: www
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


After reboot rebooting



hostname -> XXX
hostname -f -> XXX.strato.net


hostname-ctl



Static hostname: www
Transient hostname: XXX
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


Note the transient hostname



Oddly enough the hosts and hostname files are intact.



I Also tried changing /etc/init/hostname.conf to the following



description     "set system hostname"

start on startup

task
exec hostname -b -F /etc/hostname.mod; full=$(cat /etc/hostname.mod);short=(${full//./ }); hostnamectl set-hostname $short


I put the hostname also in /etc/hostname.mod to ensure there is no overwriting going on. Executing the above exec-statement manually fixes everything but it doesn't seem to be effective during the boot-sequence ...



Unfortunately I'm pretty lost here ... I would assume the /etc/init/hostname.conf gets executed during boot but then the hostname gets overriden by another script? Has anyone ever had such an issue and knows how to fix it?
I guess I could look into some linux version of a file-spy that documents what processes touch which files and find the offending script that way ... This does sound like a lot of work however ...



If someone could at least point out the livecycle of the hostname, that is the steps of how it is determined and where one could hook into this would already help me a lot.



Thanks in advance for your time and effort



Edit



I guess it would also help to explain why this is bad :-) OpenLDAP refuses to work correctly in STARTTLS mode if the hostname isn't properly configured. Since I never had the problem of not being able to change the hostname I don't know what other service might malefunction as well. A minimal solution to the problem would therefor have to become effective before service like OpenLDAP are started.










share|improve this question
















This is a shot in the dark here ...



I'm using a service called Strato-Server-Cloud which is basicaly a rudimentary version of AWS or Google-Compute. They changed their interface and/or engine recently. Ever since, all new Ubuntu 16 instances I create have the problem of thier hostname being reverted on reboot.



Here is what I usually do:



/etc/hostname



www.example.com


/etc/hosts



127.0.0.1 www.example.com www
[...]


On Ubuntu 16 additionally:



hostnamectl set-hostname www


After doing the steps above:



hostname -> www
hostname -f -> www.example.com


hostnamectl



Static hostname: www
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


After reboot rebooting



hostname -> XXX
hostname -f -> XXX.strato.net


hostname-ctl



Static hostname: www
Transient hostname: XXX
Icon name: computer-vm
Chassis: vm
Machine ID: [ID]
Boot ID: [ID]
Virtualization: microsoft
Operating System: Ubuntu 16.04.1 LTS
Kernel: Linux 4.4.0-59-generic
Architecture: x86-64


Note the transient hostname



Oddly enough the hosts and hostname files are intact.



I Also tried changing /etc/init/hostname.conf to the following



description     "set system hostname"

start on startup

task
exec hostname -b -F /etc/hostname.mod; full=$(cat /etc/hostname.mod);short=(${full//./ }); hostnamectl set-hostname $short


I put the hostname also in /etc/hostname.mod to ensure there is no overwriting going on. Executing the above exec-statement manually fixes everything but it doesn't seem to be effective during the boot-sequence ...



Unfortunately I'm pretty lost here ... I would assume the /etc/init/hostname.conf gets executed during boot but then the hostname gets overriden by another script? Has anyone ever had such an issue and knows how to fix it?
I guess I could look into some linux version of a file-spy that documents what processes touch which files and find the offending script that way ... This does sound like a lot of work however ...



If someone could at least point out the livecycle of the hostname, that is the steps of how it is determined and where one could hook into this would already help me a lot.



Thanks in advance for your time and effort



Edit



I guess it would also help to explain why this is bad :-) OpenLDAP refuses to work correctly in STARTTLS mode if the hostname isn't properly configured. Since I never had the problem of not being able to change the hostname I don't know what other service might malefunction as well. A minimal solution to the problem would therefor have to become effective before service like OpenLDAP are started.







16.04 cloud hostname






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 23 '17 at 14:56







user3240383

















asked Jan 23 '17 at 14:44









user3240383user3240383

84




84








  • 1





    How does this computer get its IP address? dhcp? If yes, try to delete host-name from the request line in /etc/dhcp/dhclient.conf.

    – Doug Smythies
    Jan 23 '17 at 15:01











  • @doug Mister Smythies you da man! You know of all the things I considered like their hypervisor messing with the virtual disk image on reboot, I never imagined it to be something this stupid. Indeed there was a host-name directive and deleting it fixed everything. Make your comment an anwser and I accept it.

    – user3240383
    Jan 23 '17 at 15:28














  • 1





    How does this computer get its IP address? dhcp? If yes, try to delete host-name from the request line in /etc/dhcp/dhclient.conf.

    – Doug Smythies
    Jan 23 '17 at 15:01











  • @doug Mister Smythies you da man! You know of all the things I considered like their hypervisor messing with the virtual disk image on reboot, I never imagined it to be something this stupid. Indeed there was a host-name directive and deleting it fixed everything. Make your comment an anwser and I accept it.

    – user3240383
    Jan 23 '17 at 15:28








1




1





How does this computer get its IP address? dhcp? If yes, try to delete host-name from the request line in /etc/dhcp/dhclient.conf.

– Doug Smythies
Jan 23 '17 at 15:01





How does this computer get its IP address? dhcp? If yes, try to delete host-name from the request line in /etc/dhcp/dhclient.conf.

– Doug Smythies
Jan 23 '17 at 15:01













@doug Mister Smythies you da man! You know of all the things I considered like their hypervisor messing with the virtual disk image on reboot, I never imagined it to be something this stupid. Indeed there was a host-name directive and deleting it fixed everything. Make your comment an anwser and I accept it.

– user3240383
Jan 23 '17 at 15:28





@doug Mister Smythies you da man! You know of all the things I considered like their hypervisor messing with the virtual disk image on reboot, I never imagined it to be something this stupid. Indeed there was a host-name directive and deleting it fixed everything. Make your comment an anwser and I accept it.

– user3240383
Jan 23 '17 at 15:28










2 Answers
2






active

oldest

votes


















4














For computers that get their IP address via dchp, the default client file, /etc/dhcp/dhclient.conf, includes asking for what the host-name should be in the request:



request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;


You can remove that from the request:



request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search,
dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;


I am not sure if: There might be unintended side effects; The domain-name should also be deleted from the request.






share|improve this answer
























  • Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

    – user3240383
    Jan 23 '17 at 16:05



















0














Old post, I know, but this helped me solve the same problem. I'm updating this for future search engine users experiencing the same problem.



It wasn't hostnamectl's fault this time.



If you're trying to change the hostname on a VPS server and it just doesn't want to change - your VM may be getting its hostname from the host machine/hypervisor.



In my case, I had to log into the VPS provider dashboard and change the hostname there.






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f875276%2frevert-prevent-hostname-change%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    For computers that get their IP address via dchp, the default client file, /etc/dhcp/dhclient.conf, includes asking for what the host-name should be in the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    You can remove that from the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    I am not sure if: There might be unintended side effects; The domain-name should also be deleted from the request.






    share|improve this answer
























    • Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

      – user3240383
      Jan 23 '17 at 16:05
















    4














    For computers that get their IP address via dchp, the default client file, /etc/dhcp/dhclient.conf, includes asking for what the host-name should be in the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    You can remove that from the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    I am not sure if: There might be unintended side effects; The domain-name should also be deleted from the request.






    share|improve this answer
























    • Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

      – user3240383
      Jan 23 '17 at 16:05














    4












    4








    4







    For computers that get their IP address via dchp, the default client file, /etc/dhcp/dhclient.conf, includes asking for what the host-name should be in the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    You can remove that from the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    I am not sure if: There might be unintended side effects; The domain-name should also be deleted from the request.






    share|improve this answer













    For computers that get their IP address via dchp, the default client file, /etc/dhcp/dhclient.conf, includes asking for what the host-name should be in the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    You can remove that from the request:



    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    I am not sure if: There might be unintended side effects; The domain-name should also be deleted from the request.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 23 '17 at 15:45









    Doug SmythiesDoug Smythies

    7,46631631




    7,46631631













    • Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

      – user3240383
      Jan 23 '17 at 16:05



















    • Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

      – user3240383
      Jan 23 '17 at 16:05

















    Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

    – user3240383
    Jan 23 '17 at 16:05





    Thanks again. Should unintended side effects arise in the future im going to add them to my question. Pending that everything seems fine.

    – user3240383
    Jan 23 '17 at 16:05













    0














    Old post, I know, but this helped me solve the same problem. I'm updating this for future search engine users experiencing the same problem.



    It wasn't hostnamectl's fault this time.



    If you're trying to change the hostname on a VPS server and it just doesn't want to change - your VM may be getting its hostname from the host machine/hypervisor.



    In my case, I had to log into the VPS provider dashboard and change the hostname there.






    share|improve this answer




























      0














      Old post, I know, but this helped me solve the same problem. I'm updating this for future search engine users experiencing the same problem.



      It wasn't hostnamectl's fault this time.



      If you're trying to change the hostname on a VPS server and it just doesn't want to change - your VM may be getting its hostname from the host machine/hypervisor.



      In my case, I had to log into the VPS provider dashboard and change the hostname there.






      share|improve this answer


























        0












        0








        0







        Old post, I know, but this helped me solve the same problem. I'm updating this for future search engine users experiencing the same problem.



        It wasn't hostnamectl's fault this time.



        If you're trying to change the hostname on a VPS server and it just doesn't want to change - your VM may be getting its hostname from the host machine/hypervisor.



        In my case, I had to log into the VPS provider dashboard and change the hostname there.






        share|improve this answer













        Old post, I know, but this helped me solve the same problem. I'm updating this for future search engine users experiencing the same problem.



        It wasn't hostnamectl's fault this time.



        If you're trying to change the hostname on a VPS server and it just doesn't want to change - your VM may be getting its hostname from the host machine/hypervisor.



        In my case, I had to log into the VPS provider dashboard and change the hostname there.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 4 at 15:54









        Taco BobTaco Bob

        1817




        1817






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f875276%2frevert-prevent-hostname-change%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Category:香港粉麵

            List *all* the tuples!

            Channel [V]