LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-31-2017, 12:37 PM   #1
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 106

Rep: Reputation: 17
Providing hostname for Linux distro


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 12:38 PM. Reason: grammar correction
 
Old 03-31-2017, 01:03 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
https://duckduckgo.com/?q=linux+perm...y+set+hostname
what don't you understand?
 
Old 03-31-2017, 03:16 PM   #3
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 106

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by ondoho View Post
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.
 
Old 03-31-2017, 03:17 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
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.

Last edited by michaelk; 03-31-2017 at 03:18 PM.
 
Old 03-31-2017, 03:37 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,921

Rep: Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618Reputation: 3618
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.
 
1 members found this post helpful.
Old 04-01-2017, 01:05 AM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by eldiener View Post
curt reply
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.
 
1 members found this post helpful.
Old 04-01-2017, 01:44 AM   #7
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 106

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by michaelk View Post
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 ?
 
Old 04-01-2017, 02:14 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
first result(!) from the search i suggested in post #2:
http://www.ducea.com/2006/08/07/how-...-linux-system/
Quote:
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.

qed.
 
Old 04-01-2017, 06:34 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
True, some distributions do add the hostname to /etc/hosts that resolves to localhost (127.0.1.1) like debian but Redhat based distributions do not.

http://serverfault.com/questions/363...n-127-0-0-1-in
 
Old 04-01-2017, 07:14 AM   #10
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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.

Code:
172.16.128.420 EricCartmanLikesMint
172.16.128.420 StanMarshHatesUbuntu
So arbitrary, it's not even funny.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Server Providing mirrors of Linux distros slayerking Linux - General 1 05-28-2012 03:49 PM
Keep in IP address, hostname, etc in Slax BackTrack2 distro Adam555 Linux - Newbie 4 05-30-2007 07:22 AM
How abt providing torrents in the linux download section jayakrishnan LQ Suggestions & Feedback 2 12-17-2005 03:24 AM
Linux providing ICS subaruwrx Debian 2 03-23-2005 11:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration