How to remove .local suffix from Ubuntu hostname?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite
1












When I try to connect to my Ubuntu device with the ssh terminal command, I have to add .local suffix to Ubuntu hostname. For example, if I want to ssh to my device with its hostname, my ssh command must have the .local suffix and command has the following format:



ssh username@device_hostname.local 


I'm aware that the .local suffix was appended by avahi (zeroconf) Linux service, but is there any quick (easy) way to bypass it? I want to be able to "ssh" my device only by its hostname without .local suffix at the end of the command, like this:



ssh username@device_hostname


What exactly I want to achieve is to completely remove the .local suffix from host name. I've read about running my private DNS server, but I would like to know if there is a less complex solution.










share|improve this question



















  • 3




    A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh
    – Takkat
    Apr 18 at 12:47






  • 3




    Possible duplicate of Host alias for ssh
    – Takkat
    Apr 20 at 9:40










  • @Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution?
    – Boixos Noi
    Apr 20 at 13:11






  • 1




    Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups?
    – Thomas Ward♦
    Apr 20 at 13:52














up vote
2
down vote

favorite
1












When I try to connect to my Ubuntu device with the ssh terminal command, I have to add .local suffix to Ubuntu hostname. For example, if I want to ssh to my device with its hostname, my ssh command must have the .local suffix and command has the following format:



ssh username@device_hostname.local 


I'm aware that the .local suffix was appended by avahi (zeroconf) Linux service, but is there any quick (easy) way to bypass it? I want to be able to "ssh" my device only by its hostname without .local suffix at the end of the command, like this:



ssh username@device_hostname


What exactly I want to achieve is to completely remove the .local suffix from host name. I've read about running my private DNS server, but I would like to know if there is a less complex solution.










share|improve this question



















  • 3




    A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh
    – Takkat
    Apr 18 at 12:47






  • 3




    Possible duplicate of Host alias for ssh
    – Takkat
    Apr 20 at 9:40










  • @Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution?
    – Boixos Noi
    Apr 20 at 13:11






  • 1




    Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups?
    – Thomas Ward♦
    Apr 20 at 13:52












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





When I try to connect to my Ubuntu device with the ssh terminal command, I have to add .local suffix to Ubuntu hostname. For example, if I want to ssh to my device with its hostname, my ssh command must have the .local suffix and command has the following format:



ssh username@device_hostname.local 


I'm aware that the .local suffix was appended by avahi (zeroconf) Linux service, but is there any quick (easy) way to bypass it? I want to be able to "ssh" my device only by its hostname without .local suffix at the end of the command, like this:



ssh username@device_hostname


What exactly I want to achieve is to completely remove the .local suffix from host name. I've read about running my private DNS server, but I would like to know if there is a less complex solution.










share|improve this question















When I try to connect to my Ubuntu device with the ssh terminal command, I have to add .local suffix to Ubuntu hostname. For example, if I want to ssh to my device with its hostname, my ssh command must have the .local suffix and command has the following format:



ssh username@device_hostname.local 


I'm aware that the .local suffix was appended by avahi (zeroconf) Linux service, but is there any quick (easy) way to bypass it? I want to be able to "ssh" my device only by its hostname without .local suffix at the end of the command, like this:



ssh username@device_hostname


What exactly I want to achieve is to completely remove the .local suffix from host name. I've read about running my private DNS server, but I would like to know if there is a less complex solution.







dns hostname avahi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 21 at 22:40









David Foerster

26.1k1361106




26.1k1361106










asked Apr 18 at 12:39









Boixos Noi

133




133







  • 3




    A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh
    – Takkat
    Apr 18 at 12:47






  • 3




    Possible duplicate of Host alias for ssh
    – Takkat
    Apr 20 at 9:40










  • @Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution?
    – Boixos Noi
    Apr 20 at 13:11






  • 1




    Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups?
    – Thomas Ward♦
    Apr 20 at 13:52












  • 3




    A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh
    – Takkat
    Apr 18 at 12:47






  • 3




    Possible duplicate of Host alias for ssh
    – Takkat
    Apr 20 at 9:40










  • @Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution?
    – Boixos Noi
    Apr 20 at 13:11






  • 1




    Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups?
    – Thomas Ward♦
    Apr 20 at 13:52







3




3




A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh
– Takkat
Apr 18 at 12:47




A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh
– Takkat
Apr 18 at 12:47




3




3




Possible duplicate of Host alias for ssh
– Takkat
Apr 20 at 9:40




Possible duplicate of Host alias for ssh
– Takkat
Apr 20 at 9:40












@Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution?
– Boixos Noi
Apr 20 at 13:11




@Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution?
– Boixos Noi
Apr 20 at 13:11




1




1




Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups?
– Thomas Ward♦
Apr 20 at 13:52




Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups?
– Thomas Ward♦
Apr 20 at 13:52










2 Answers
2






active

oldest

votes

















up vote
1
down vote



accepted










Your clients will need at least one way to resolve the hostname to an IP address. The mechanism you already discovered works through automatic configuration and happens within the .local domain name.



You could define the mapping from hostname to IP addresses on every client, but this is not recommended practice.



You will have to go through some kind of automatic name resolution mechanism, all of which require use of some kind of domain name in the background.



However, you can easily get rid of having to type the domain name each time by doing one of:



ssh hostname canonicalisation



If you put the following into /etc/ssh_config or ~/.ssh/config:



Host *
CanonicalDomains local
CanonicalizeHostname yes


ssh will automatically append local to any hostname. So when you type ssh host it will actually do ssh host.local.



search domains



While the above will work only for ssh, you can also configure a similar thing for all network connections by configuring the dns resolver on your client accordingly. It is the "classical" way of having hostname shortcuts.



Depending on which setup you have, you would add local to the list of search domains. This is what I do. There should be plenty description for this available, like this.



hardcoding to /etc/hosts



This is not recommended at all, because although it seems simple in the beginning, it will become hard to maintain soon. But it is the only way known to me that allows to completely get rid of domain names.



Edit the file /etc/hosts and add lines like this:



192.168.1.3 host3
192.168.1.4 host4


While the first word in each line is the IP address of the corresponding host. You have to do that on every client. After that you can use ssh host3, and not even in the background a domain name will be used.






share|improve this answer



























    up vote
    -1
    down vote













    In /etc/hostname is the name you want to update. For example mydomiain.com and I'm assuming you have root access. The command hostname can also be used. So you'll need to update the file with vi. Whatever is in line 1 needs to be updated with your domain name. Pretty simple.






    share|improve this answer




















    • This doesn't achieve what OP describes in the last paragraph. -1
      – David Foerster
      Apr 21 at 22:40










    • What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
      – Webmaster TheCMG
      Apr 21 at 22:44










    • In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
      – Webmaster TheCMG
      Apr 21 at 22:46










    • Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
      – David Foerster
      Apr 21 at 22:49











    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    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%2f1026099%2fhow-to-remove-local-suffix-from-ubuntu-hostname%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    Your clients will need at least one way to resolve the hostname to an IP address. The mechanism you already discovered works through automatic configuration and happens within the .local domain name.



    You could define the mapping from hostname to IP addresses on every client, but this is not recommended practice.



    You will have to go through some kind of automatic name resolution mechanism, all of which require use of some kind of domain name in the background.



    However, you can easily get rid of having to type the domain name each time by doing one of:



    ssh hostname canonicalisation



    If you put the following into /etc/ssh_config or ~/.ssh/config:



    Host *
    CanonicalDomains local
    CanonicalizeHostname yes


    ssh will automatically append local to any hostname. So when you type ssh host it will actually do ssh host.local.



    search domains



    While the above will work only for ssh, you can also configure a similar thing for all network connections by configuring the dns resolver on your client accordingly. It is the "classical" way of having hostname shortcuts.



    Depending on which setup you have, you would add local to the list of search domains. This is what I do. There should be plenty description for this available, like this.



    hardcoding to /etc/hosts



    This is not recommended at all, because although it seems simple in the beginning, it will become hard to maintain soon. But it is the only way known to me that allows to completely get rid of domain names.



    Edit the file /etc/hosts and add lines like this:



    192.168.1.3 host3
    192.168.1.4 host4


    While the first word in each line is the IP address of the corresponding host. You have to do that on every client. After that you can use ssh host3, and not even in the background a domain name will be used.






    share|improve this answer
























      up vote
      1
      down vote



      accepted










      Your clients will need at least one way to resolve the hostname to an IP address. The mechanism you already discovered works through automatic configuration and happens within the .local domain name.



      You could define the mapping from hostname to IP addresses on every client, but this is not recommended practice.



      You will have to go through some kind of automatic name resolution mechanism, all of which require use of some kind of domain name in the background.



      However, you can easily get rid of having to type the domain name each time by doing one of:



      ssh hostname canonicalisation



      If you put the following into /etc/ssh_config or ~/.ssh/config:



      Host *
      CanonicalDomains local
      CanonicalizeHostname yes


      ssh will automatically append local to any hostname. So when you type ssh host it will actually do ssh host.local.



      search domains



      While the above will work only for ssh, you can also configure a similar thing for all network connections by configuring the dns resolver on your client accordingly. It is the "classical" way of having hostname shortcuts.



      Depending on which setup you have, you would add local to the list of search domains. This is what I do. There should be plenty description for this available, like this.



      hardcoding to /etc/hosts



      This is not recommended at all, because although it seems simple in the beginning, it will become hard to maintain soon. But it is the only way known to me that allows to completely get rid of domain names.



      Edit the file /etc/hosts and add lines like this:



      192.168.1.3 host3
      192.168.1.4 host4


      While the first word in each line is the IP address of the corresponding host. You have to do that on every client. After that you can use ssh host3, and not even in the background a domain name will be used.






      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        Your clients will need at least one way to resolve the hostname to an IP address. The mechanism you already discovered works through automatic configuration and happens within the .local domain name.



        You could define the mapping from hostname to IP addresses on every client, but this is not recommended practice.



        You will have to go through some kind of automatic name resolution mechanism, all of which require use of some kind of domain name in the background.



        However, you can easily get rid of having to type the domain name each time by doing one of:



        ssh hostname canonicalisation



        If you put the following into /etc/ssh_config or ~/.ssh/config:



        Host *
        CanonicalDomains local
        CanonicalizeHostname yes


        ssh will automatically append local to any hostname. So when you type ssh host it will actually do ssh host.local.



        search domains



        While the above will work only for ssh, you can also configure a similar thing for all network connections by configuring the dns resolver on your client accordingly. It is the "classical" way of having hostname shortcuts.



        Depending on which setup you have, you would add local to the list of search domains. This is what I do. There should be plenty description for this available, like this.



        hardcoding to /etc/hosts



        This is not recommended at all, because although it seems simple in the beginning, it will become hard to maintain soon. But it is the only way known to me that allows to completely get rid of domain names.



        Edit the file /etc/hosts and add lines like this:



        192.168.1.3 host3
        192.168.1.4 host4


        While the first word in each line is the IP address of the corresponding host. You have to do that on every client. After that you can use ssh host3, and not even in the background a domain name will be used.






        share|improve this answer












        Your clients will need at least one way to resolve the hostname to an IP address. The mechanism you already discovered works through automatic configuration and happens within the .local domain name.



        You could define the mapping from hostname to IP addresses on every client, but this is not recommended practice.



        You will have to go through some kind of automatic name resolution mechanism, all of which require use of some kind of domain name in the background.



        However, you can easily get rid of having to type the domain name each time by doing one of:



        ssh hostname canonicalisation



        If you put the following into /etc/ssh_config or ~/.ssh/config:



        Host *
        CanonicalDomains local
        CanonicalizeHostname yes


        ssh will automatically append local to any hostname. So when you type ssh host it will actually do ssh host.local.



        search domains



        While the above will work only for ssh, you can also configure a similar thing for all network connections by configuring the dns resolver on your client accordingly. It is the "classical" way of having hostname shortcuts.



        Depending on which setup you have, you would add local to the list of search domains. This is what I do. There should be plenty description for this available, like this.



        hardcoding to /etc/hosts



        This is not recommended at all, because although it seems simple in the beginning, it will become hard to maintain soon. But it is the only way known to me that allows to completely get rid of domain names.



        Edit the file /etc/hosts and add lines like this:



        192.168.1.3 host3
        192.168.1.4 host4


        While the first word in each line is the IP address of the corresponding host. You have to do that on every client. After that you can use ssh host3, and not even in the background a domain name will be used.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 22 at 0:15









        Sebastian Stark

        4,703938




        4,703938






















            up vote
            -1
            down vote













            In /etc/hostname is the name you want to update. For example mydomiain.com and I'm assuming you have root access. The command hostname can also be used. So you'll need to update the file with vi. Whatever is in line 1 needs to be updated with your domain name. Pretty simple.






            share|improve this answer




















            • This doesn't achieve what OP describes in the last paragraph. -1
              – David Foerster
              Apr 21 at 22:40










            • What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
              – Webmaster TheCMG
              Apr 21 at 22:44










            • In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
              – Webmaster TheCMG
              Apr 21 at 22:46










            • Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
              – David Foerster
              Apr 21 at 22:49















            up vote
            -1
            down vote













            In /etc/hostname is the name you want to update. For example mydomiain.com and I'm assuming you have root access. The command hostname can also be used. So you'll need to update the file with vi. Whatever is in line 1 needs to be updated with your domain name. Pretty simple.






            share|improve this answer




















            • This doesn't achieve what OP describes in the last paragraph. -1
              – David Foerster
              Apr 21 at 22:40










            • What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
              – Webmaster TheCMG
              Apr 21 at 22:44










            • In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
              – Webmaster TheCMG
              Apr 21 at 22:46










            • Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
              – David Foerster
              Apr 21 at 22:49













            up vote
            -1
            down vote










            up vote
            -1
            down vote









            In /etc/hostname is the name you want to update. For example mydomiain.com and I'm assuming you have root access. The command hostname can also be used. So you'll need to update the file with vi. Whatever is in line 1 needs to be updated with your domain name. Pretty simple.






            share|improve this answer












            In /etc/hostname is the name you want to update. For example mydomiain.com and I'm assuming you have root access. The command hostname can also be used. So you'll need to update the file with vi. Whatever is in line 1 needs to be updated with your domain name. Pretty simple.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Apr 21 at 21:23









            Webmaster TheCMG

            1




            1











            • This doesn't achieve what OP describes in the last paragraph. -1
              – David Foerster
              Apr 21 at 22:40










            • What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
              – Webmaster TheCMG
              Apr 21 at 22:44










            • In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
              – Webmaster TheCMG
              Apr 21 at 22:46










            • Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
              – David Foerster
              Apr 21 at 22:49

















            • This doesn't achieve what OP describes in the last paragraph. -1
              – David Foerster
              Apr 21 at 22:40










            • What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
              – Webmaster TheCMG
              Apr 21 at 22:44










            • In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
              – Webmaster TheCMG
              Apr 21 at 22:46










            • Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
              – David Foerster
              Apr 21 at 22:49
















            This doesn't achieve what OP describes in the last paragraph. -1
            – David Foerster
            Apr 21 at 22:40




            This doesn't achieve what OP describes in the last paragraph. -1
            – David Foerster
            Apr 21 at 22:40












            What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
            – Webmaster TheCMG
            Apr 21 at 22:44




            What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist
            – Webmaster TheCMG
            Apr 21 at 22:44












            In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
            – Webmaster TheCMG
            Apr 21 at 22:46




            In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu
            – Webmaster TheCMG
            Apr 21 at 22:46












            Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
            – David Foerster
            Apr 21 at 22:49





            Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change.
            – David Foerster
            Apr 21 at 22:49


















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1026099%2fhow-to-remove-local-suffix-from-ubuntu-hostname%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491