Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I run a number of Linux distros on different computers of my LAN. I want to provide a unique hostname for each distro, so that when I share files between them I can easily identify the distro on my LAN. Currently a number of these distros have as the hostname "localhost.localdomain", which obviously does not distinguish one distro from another.
I understand how I can permananently change the hostname for each distro. After changing the hostname is there any other file I need to synchronize with the hostname change, such as entries in the /etc/hosts file, or can just changing the hostname, usually in the /etc/hosts file, be the only thing I have to do so that my effort works correctly ?
Last edited by eldiener; 03-31-2017 at 01:38 PM.
Reason: grammar correction
I was not sure if changing the hostname affects any other files, such as /etc/hosts, needed for Linux networking. I will assume from your curt reply that it does not. I did not want to change the hostname in order to find that other networking functionality would stop working.
Hostname and entries in /etc/hosts are really not related in any manner. /etc/hosts is a manual lookup table that matches IP addresses to a name but it does not need to match the actual hostname.
If you share files using samba then by default it will automatically use the hostname as the netbios name which will be displayed if you use the file browser to browse the network. localhost is specific to that computer so you can either change the host name or use the netbios name directive in your smb.conf files. netbios names are limited to 15 characters.
If using /etc/hosts your computers need to have a static IP address. You can either use your router DHCP server's address reservation configuration or configure each PC. If using a manual static IP you also need to add DNS nameserver information to access the internet via NetworkManager.
You can also run a small DNS server (dnsmasq) on one of the computers which is not difficult to setup.
We use host files and host name on a few places where I work at. Machine XYZ12 is always set up to be static xx,yy,zz,12 for example. Each machine has same list of hosts file entries. Has worked well to match naming to ip address outside of DNS lookups.
Not all distro's follow the name lookup in some cases. You may have to set lookup so that ping XYZ12 will look to hosts file before other entries.
As noted above you could even set up netbios name server or other ways to automate it.
yes it was curt, sorry.
the sentence that goes with it is always the same and i guess i was tired typing it out... it would be something like this:
have a look at these search results, try things out or tell us which questions are left over after applying one or several of the solutions, with a link to that solution for our benefit.
Hostname and entries in /etc/hosts are really not related in any manner. /etc/hosts is a manual lookup table that matches IP addresses to a name but it does not need to match the actual hostname.
If you share files using samba then by default it will automatically use the hostname as the netbios name which will be displayed if you use the file browser to browse the network. localhost is specific to that computer so you can either change the host name or use the netbios name directive in your smb.conf files. netbios names are limited to 15 characters.
If using /etc/hosts your computers need to have a static IP address. You can either use your router DHCP server's address reservation configuration or configure each PC. If using a manual static IP you also need to add DNS nameserver information to access the internet via NetworkManager.
You can also run a small DNS server (dnsmasq) on one of the computers which is not difficult to setup.
Thank you for the explanation. A number of links for changing the hostname for various Linux distros mention changing /etc/hosts to match the changed hostname. In other words if there were a previous hostname of simpley 'localhost.localdomain' and I change that in the hostname file to 'MyIndividualName.localdomain' the links suggest changing any instance of 'localhost.localdomain' in the /etc/hosts file to 'MyIndividualName.localdomain'. Since you say that the hostname and the '/etc/hosts' file are unrelated why would any of these links suggest changing '/etc/hosts' to match the new hostname ?
Debian based systems use the file /etc/hostname to read the hostname of the system at boot time
...
RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot.
i use archlinux, and the file /etc/hostname exists, and contains the hostname.
Poor Man's DNS, aka /etc/hosts is what I'd use. It's fast, doesn't need a reboot.
Systems that don't ask for hostname during install, I guess are meant to be manually configured?
/etc/issue or /etc/issue.net is usually shown to me, when there is one. How are you sharing files? One-to-many or many-to-many hosts?
You haven't explained that process at all, except to say you do it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.