Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36

Thread: About the hosts file

  1. #1
    Join Date
    Dec 2008
    Location
    Montana, USA
    Posts
    700

    Default About the hosts file

    My question: Is it allowable to have an entry in my hosts file that has the hostname and ip address of my computer in it?

    Example: My computer's hostname is ASU-X99 and it's ip address is 10.111.10.5
    Can that entry be added to the hosts file on this computer without causing problems? Especially if it is below the 127.0.0.1 entry?

    The reason for my question is:
    I have 5 openSUSE systems, a NAS and 3 printers on my network. I am in the habit of doing updates to all the computers in my network from my computer using ssh to log into each of them, using ssh bart@<hostname>, and using zypper up. I should say that all devices except mobile phones have reserved addresses.

    I have been having very inconsistent results using hostnames as often I get a name or service not known response. All seems well if the entries are in the hosts file of the various computers, but I would like to use the same file for all the computers, giving me one central point for management, rather than got to each one if/when I need to make a change.

    My router (TP-Link 7602) does not have a DNS server in it.

    Bart

  2. #2
    Join Date
    Jun 2008
    Location
    East of Podunk
    Posts
    33,118
    Blog Entries
    15

    Default Re: About the hosts file

    Quote Originally Posted by montana_suse_user View Post
    My question: Is it allowable to have an entry in my hosts file that has the hostname and ip address of my computer in it?

    Example: My computer's hostname is ASU-X99 and it's ip address is 10.111.10.5
    Can that entry be added to the hosts file on this computer without causing problems? Especially if it is below the 127.0.0.1 entry?

    The reason for my question is:
    I have 5 openSUSE systems, a NAS and 3 printers on my network. I am in the habit of doing updates to all the computers in my network from my computer using ssh to log into each of them, using ssh bart@<hostname>, and using zypper up. I should say that all devices except mobile phones have reserved addresses.

    I have been having very inconsistent results using hostnames as often I get a name or service not known response. All seems well if the entries are in the hosts file of the various computers, but I would like to use the same file for all the computers, giving me one central point for management, rather than got to each one if/when I need to make a change.

    My router (TP-Link 7602) does not have a DNS server in it.

    Bart
    Hi
    I normally just have localhost tied to 127.0.0.x and hostname against the static ip address..... I just have a localhosts text file and just append to /etc/hosts on machines.
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3
    Join Date
    Dec 2008
    Location
    Montana, USA
    Posts
    700

    Default Re: About the hosts file

    Quote Originally Posted by malcolmlewis View Post
    Hi
    I normally just have localhost tied to 127.0.0.x and hostname against the static ip address..... I just have a localhosts text file and just append to /etc/hosts on machines.
    Not completely sure I understand. Do you mean there is an entry:
    127.0.0.1 localhost

    and another at:
    192.168.1.x <your local hostname>

    ?

    Bart

  4. #4
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,991
    Blog Entries
    1

    Default Re: About the hosts file

    Quote Originally Posted by montana_suse_user View Post
    Not completely sure I understand. Do you mean there is an entry:
    127.0.0.1 localhost

    and another at:
    192.168.1.x <your local hostname>

    ?

    Bart
    Refer
    Code:
    man 5 hosts
    openSUSE Leap 15.3; KDE Plasma 5

  5. #5
    Join Date
    Jun 2011
    Location
    Germany
    Posts
    696

    Default Re: About the hosts file

    @montana_suse_user,

    I can confirm it doesn't do any harm if a host's own hostname and IP is listed in it's "/etc/hosts". I have a similar setup / approach. I don't use only one file but being lazy I just copy the full list of hosts into the file / the YaST dialog when doing a fresh install. That's my habit since many years and I have never had any issue that I could think of being related to it.

  6. #6
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    30,707

    Default Re: About the hosts file

    Quote Originally Posted by montana_suse_user View Post
    Not completely sure I understand. Do you mean there is an entry:
    127.0.0.1 localhost

    and another at:
    192.168.1.x <your local hostname>

    ?

    Bart
    That is rather normal. And the sequence is of no importance.
    Henk van Velden

  7. #7
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    4,844

    Default Re: About the hosts file

    Quote Originally Posted by montana_suse_user View Post
    Is it allowable to have an entry in my hosts file that has the hostname and ip address of my computer in it?
    .
    I have been having very inconsistent results using hostnames as often I get a name or service not known response. All seems well if the entries are in the hosts file of the various computers, but I would like to use the same file for all the computers, giving me one central point for management, rather than got to each one if/when I need to make a change.
    .
    My router (TP-Link 7602) does not have a DNS server in it.
    Then, you'll have to setup a DNS server for your LAN – assuming that, it's a small private LAN, a «Raspberry Pi» or, something similar, will be more than sufficient for your needs.
    • Trying to maintain consistent ‘/etc/hosts’ files across all hosts in a network is and, always was, a Sisyphus task and, doomed to error …

  8. #8
    Join Date
    Jan 2014
    Location
    Erlangen
    Posts
    3,848

    Default Re: About the hosts file

    Quote Originally Posted by montana_suse_user View Post
    My question: Is it allowable to have an entry in my hosts file that has the hostname and ip address of my computer in it?

    Example: My computer's hostname is ASU-X99 and it's ip address is 10.111.10.5
    Can that entry be added to the hosts file on this computer without causing problems? Especially if it is below the 127.0.0.1 entry?

    The reason for my question is:
    I have 5 openSUSE systems, a NAS and 3 printers on my network. I am in the habit of doing updates to all the computers in my network from my computer using ssh to log into each of them, using ssh bart@<hostname>, and using zypper up. I should say that all devices except mobile phones have reserved addresses.

    I have been having very inconsistent results using hostnames as often I get a name or service not known response. All seems well if the entries are in the hosts file of the various computers, but I would like to use the same file for all the computers, giving me one central point for management, rather than got to each one if/when I need to make a change.

    My router (TP-Link 7602) does not have a DNS server in it.

    Bart
    Does that work: https://www.tp-link.com/de/support/faq/1712/ ?

    The local network here consists of several hosts and all of the openSUSE machines have this single identical configuration file:
    Code:
    erlangen:~ # cat /etc/systemd/network/20-wired.network     
    [Match] 
    Name=e* 
    
    [Network] 
    DHCP=yes 
    Domains=fritz.box 
    erlangen:~ #
    Each of them has a unique static hostname:
    Code:
    erlangen:~ # hostnamectl  
     Static hostname: erlangen 
           Icon name: computer-desktop 
             Chassis: desktop  
            Location: home 
          Machine ID: 94f3af277bac4a8eb57da425c9677379 
             Boot ID: 799357efba7f4566bd72611875e7810e 
    Operating System: openSUSE Tumbleweed                 
         CPE OS Name: cpe:/o:opensuse:tumbleweed:20220423 
              Kernel: Linux 5.17.4-1-default 
        Architecture: x86-64 
     Hardware Vendor: Micro-Star International Co., Ltd. 
      Hardware Model: MS-7C56 
    erlangen:~ #
    The above is all I need to check.
    i7-6700K (2016), i5-8250U (2018), AMD Ryzen 5 3400G (2020), 5600X (2022) openSUSE Tumbleweed, KDE Plasma

  9. #9
    Join Date
    Jun 2008
    Location
    Auckland, NZ
    Posts
    23,991
    Blog Entries
    1

    Default Re: About the hosts file

    Quote Originally Posted by karlmistelberger View Post
    Does that work: https://www.tp-link.com/de/support/faq/1712/ ?

    The local network here consists of several hosts and all of the openSUSE machines have this single identical configuration file:
    How does this relate to the OP's questions in any way?
    openSUSE Leap 15.3; KDE Plasma 5

  10. #10
    Join Date
    Dec 2008
    Location
    Montana, USA
    Posts
    700

    Default Re: About the hosts file

    @dcurtisfra

    Sisyphus ?




Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •