extension for /etc/hosts












7















Is it possible to extend the file /etc/hosts on ubuntu16.04?



I have many ubuntu-servers, all servers should use the same /etc/hosts file, except some special entries.
My preffered solution would be an directory (/etc/hosts.d) with some extra files. Then I would be able to copy the original hosts file to every server and store a specialized file in the directory.



Any solutions?
Thanks.










share|improve this question


















  • 2





    Has someone experience with the dotdee package? dotdee manpage. This seems to be a solution for me.

    – Christian M
    Jul 21 '16 at 4:27








  • 1





    Interesting idea, wasn't aware of that tool. But from the question you don't seem to need to generate the file dynamically. You might be better off considering using a full-fledged configuration management solution like Ansible and generate the files from templates.

    – techraf
    Jul 21 '16 at 5:00






  • 1





    Good question. It would be very nice if /etc/hosts.d/ would work

    – guettli
    Feb 14 at 12:53











  • @guettli I suggest have a look at things like dnsmasq

    – Robert Riedl
    Feb 14 at 15:18


















7















Is it possible to extend the file /etc/hosts on ubuntu16.04?



I have many ubuntu-servers, all servers should use the same /etc/hosts file, except some special entries.
My preffered solution would be an directory (/etc/hosts.d) with some extra files. Then I would be able to copy the original hosts file to every server and store a specialized file in the directory.



Any solutions?
Thanks.










share|improve this question


















  • 2





    Has someone experience with the dotdee package? dotdee manpage. This seems to be a solution for me.

    – Christian M
    Jul 21 '16 at 4:27








  • 1





    Interesting idea, wasn't aware of that tool. But from the question you don't seem to need to generate the file dynamically. You might be better off considering using a full-fledged configuration management solution like Ansible and generate the files from templates.

    – techraf
    Jul 21 '16 at 5:00






  • 1





    Good question. It would be very nice if /etc/hosts.d/ would work

    – guettli
    Feb 14 at 12:53











  • @guettli I suggest have a look at things like dnsmasq

    – Robert Riedl
    Feb 14 at 15:18
















7












7








7








Is it possible to extend the file /etc/hosts on ubuntu16.04?



I have many ubuntu-servers, all servers should use the same /etc/hosts file, except some special entries.
My preffered solution would be an directory (/etc/hosts.d) with some extra files. Then I would be able to copy the original hosts file to every server and store a specialized file in the directory.



Any solutions?
Thanks.










share|improve this question














Is it possible to extend the file /etc/hosts on ubuntu16.04?



I have many ubuntu-servers, all servers should use the same /etc/hosts file, except some special entries.
My preffered solution would be an directory (/etc/hosts.d) with some extra files. Then I would be able to copy the original hosts file to every server and store a specialized file in the directory.



Any solutions?
Thanks.







16.04 hosts






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 21 '16 at 4:05









Christian MChristian M

463




463








  • 2





    Has someone experience with the dotdee package? dotdee manpage. This seems to be a solution for me.

    – Christian M
    Jul 21 '16 at 4:27








  • 1





    Interesting idea, wasn't aware of that tool. But from the question you don't seem to need to generate the file dynamically. You might be better off considering using a full-fledged configuration management solution like Ansible and generate the files from templates.

    – techraf
    Jul 21 '16 at 5:00






  • 1





    Good question. It would be very nice if /etc/hosts.d/ would work

    – guettli
    Feb 14 at 12:53











  • @guettli I suggest have a look at things like dnsmasq

    – Robert Riedl
    Feb 14 at 15:18
















  • 2





    Has someone experience with the dotdee package? dotdee manpage. This seems to be a solution for me.

    – Christian M
    Jul 21 '16 at 4:27








  • 1





    Interesting idea, wasn't aware of that tool. But from the question you don't seem to need to generate the file dynamically. You might be better off considering using a full-fledged configuration management solution like Ansible and generate the files from templates.

    – techraf
    Jul 21 '16 at 5:00






  • 1





    Good question. It would be very nice if /etc/hosts.d/ would work

    – guettli
    Feb 14 at 12:53











  • @guettli I suggest have a look at things like dnsmasq

    – Robert Riedl
    Feb 14 at 15:18










2




2





Has someone experience with the dotdee package? dotdee manpage. This seems to be a solution for me.

– Christian M
Jul 21 '16 at 4:27







Has someone experience with the dotdee package? dotdee manpage. This seems to be a solution for me.

– Christian M
Jul 21 '16 at 4:27






1




1





Interesting idea, wasn't aware of that tool. But from the question you don't seem to need to generate the file dynamically. You might be better off considering using a full-fledged configuration management solution like Ansible and generate the files from templates.

– techraf
Jul 21 '16 at 5:00





Interesting idea, wasn't aware of that tool. But from the question you don't seem to need to generate the file dynamically. You might be better off considering using a full-fledged configuration management solution like Ansible and generate the files from templates.

– techraf
Jul 21 '16 at 5:00




1




1





Good question. It would be very nice if /etc/hosts.d/ would work

– guettli
Feb 14 at 12:53





Good question. It would be very nice if /etc/hosts.d/ would work

– guettli
Feb 14 at 12:53













@guettli I suggest have a look at things like dnsmasq

– Robert Riedl
Feb 14 at 15:18







@guettli I suggest have a look at things like dnsmasq

– Robert Riedl
Feb 14 at 15:18












1 Answer
1






active

oldest

votes


















4














No, it's not possible using standard mechanisms.



derobert in his answer on Unix.SE suggested the following workarounds:




'There are a couple approaches you could use instead:




  • Set up a (possibly local-only) DNS server. Some of these give a lot of flexibility, and you can definitely spread your host files over multiple files, or even machines. If you're trying to include the same list of hosts on a bunch of machines, then DNS is probably the right answer.


  • Set up some other name service (NIS, LDAP, etc.). Check the glibc NSS docs for what is supported. Personally, I think you should use DNS in most all cases.


  • Make yourself an /etc/hosts.d directory or similar, and write some scripts to concatenate them all together (most trivial: cat /etc/hosts.d/*.conf > /etc/hosts, though you'll probably want a little better to e.g., sort), and run that script at boot, or from cron, or manually whenever you update the files.








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%2f801127%2fextension-for-etc-hosts%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    No, it's not possible using standard mechanisms.



    derobert in his answer on Unix.SE suggested the following workarounds:




    'There are a couple approaches you could use instead:




    • Set up a (possibly local-only) DNS server. Some of these give a lot of flexibility, and you can definitely spread your host files over multiple files, or even machines. If you're trying to include the same list of hosts on a bunch of machines, then DNS is probably the right answer.


    • Set up some other name service (NIS, LDAP, etc.). Check the glibc NSS docs for what is supported. Personally, I think you should use DNS in most all cases.


    • Make yourself an /etc/hosts.d directory or similar, and write some scripts to concatenate them all together (most trivial: cat /etc/hosts.d/*.conf > /etc/hosts, though you'll probably want a little better to e.g., sort), and run that script at boot, or from cron, or manually whenever you update the files.








    share|improve this answer






























      4














      No, it's not possible using standard mechanisms.



      derobert in his answer on Unix.SE suggested the following workarounds:




      'There are a couple approaches you could use instead:




      • Set up a (possibly local-only) DNS server. Some of these give a lot of flexibility, and you can definitely spread your host files over multiple files, or even machines. If you're trying to include the same list of hosts on a bunch of machines, then DNS is probably the right answer.


      • Set up some other name service (NIS, LDAP, etc.). Check the glibc NSS docs for what is supported. Personally, I think you should use DNS in most all cases.


      • Make yourself an /etc/hosts.d directory or similar, and write some scripts to concatenate them all together (most trivial: cat /etc/hosts.d/*.conf > /etc/hosts, though you'll probably want a little better to e.g., sort), and run that script at boot, or from cron, or manually whenever you update the files.








      share|improve this answer




























        4












        4








        4







        No, it's not possible using standard mechanisms.



        derobert in his answer on Unix.SE suggested the following workarounds:




        'There are a couple approaches you could use instead:




        • Set up a (possibly local-only) DNS server. Some of these give a lot of flexibility, and you can definitely spread your host files over multiple files, or even machines. If you're trying to include the same list of hosts on a bunch of machines, then DNS is probably the right answer.


        • Set up some other name service (NIS, LDAP, etc.). Check the glibc NSS docs for what is supported. Personally, I think you should use DNS in most all cases.


        • Make yourself an /etc/hosts.d directory or similar, and write some scripts to concatenate them all together (most trivial: cat /etc/hosts.d/*.conf > /etc/hosts, though you'll probably want a little better to e.g., sort), and run that script at boot, or from cron, or manually whenever you update the files.








        share|improve this answer















        No, it's not possible using standard mechanisms.



        derobert in his answer on Unix.SE suggested the following workarounds:




        'There are a couple approaches you could use instead:




        • Set up a (possibly local-only) DNS server. Some of these give a lot of flexibility, and you can definitely spread your host files over multiple files, or even machines. If you're trying to include the same list of hosts on a bunch of machines, then DNS is probably the right answer.


        • Set up some other name service (NIS, LDAP, etc.). Check the glibc NSS docs for what is supported. Personally, I think you should use DNS in most all cases.


        • Make yourself an /etc/hosts.d directory or similar, and write some scripts to concatenate them all together (most trivial: cat /etc/hosts.d/*.conf > /etc/hosts, though you'll probably want a little better to e.g., sort), and run that script at boot, or from cron, or manually whenever you update the files.









        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 '17 at 12:37


























        community wiki





        2 revs
        techraf































            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%2f801127%2fextension-for-etc-hosts%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

            flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

            Mangá

            Eduardo VII do Reino Unido