[SOLVED] Can not get the default hostname to change on current
SlackwareThis Forum is for the discussion of Slackware Linux.
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.
Historically it was only the hostname and not the full canonical FQDN. Search for word 'hostname' in current's Changelog to see when it was changed in Slackware.
Yes, the rc script used to do something along the lines of:
hostname $(cut -f1 -d. /etc/HOSTNAME)
It was changed here:
Code:
Sat Mar 24 19:47:01 UTC 2018
a/sysvinit-scripts-2.1-noarch-8.txz: Rebuilt.
rc.M: Set default hostname using FQDN. Thanks to Andrzej Telszewski.
I disagreed with the change and commented here on LQ at the time, but as it's easy enough to workaround by simply not putting the FQDN in /etc/HOSTNAME I didn't push the issue when nothing came of it.
From hostname (1)
Code:
THE FQDN
The FQDN (Fully Qualified Domain Name) of the system is the name that
the resolver(3) returns for the host name, such as, ursula.example.com.
It is usually the hostname followed by the DNS domain name (the part
after the first dot). You can check the FQDN using hostname --fqdn or
the domain name using dnsdomainname.
You cannot change the FQDN with hostname or dnsdomainname.
The recommended method of setting the FQDN is to make the hostname be
an alias for the fully qualified name using /etc/hosts, DNS, or NIS.
For example, if the hostname was "ursula", one might have a line in
/etc/hosts which reads
127.0.1.1 ursula.example.com ursula
Technically: The FQDN is the name getaddrinfo(3) returns for the host
name returned by gethostname(2). The DNS domain name is the part after
the first dot.
Therefore it depends on the configuration of the resolver (usually in
/etc/host.conf) how you can change it. Usually the hosts file is parsed
before DNS or NIS, so it is most common to change the FQDN in
/etc/hosts.
That clearly says to me that Slackware is doing the wrong thing here.
That clearly says to me that Slackware is doing the wrong thing here.
It says to me that the man page has not been updated. Everyone else switched to using "hostname" to store the FQDN long ago. I fought the change in Slackware for a long time, going so far as to write patches to keep using the short no-domain-name hostname. Perhaps I'll search my email to find out what the report was that prompted me to go with the flow on this, but given how much effort was previously put into sticking with the short hostname, I'm going to venture that it was time to make this change.
Anyway, if you really think this is the wrong thing to do, you'll need to point out what it breaks. Then perhaps I'll be motivated to dig up what using the short hostname breaks and we can compare notes.
If this is what everyone else is doing then my apologies. I can only go by what is in the docs. If they lie to me, I can't help that.
POSIX doesn't help as it simply defines it as "a name within a connected network".
The only other thing I can point at would be that HOST_NAME_MAX is 64, but dns names can go much longer, so a fqdn might potentially not fit, but people are unlikely to hit that one anyway as no one likes names that long.
I have nothing concrete to point at that I know of that this breaks. Maybe programmers have just got into the habit of assuming that gethostname(2) may or may not return a fqdn and now allow for both possibilities.
Right, I've just been over in my OpenBSD box to cross-reference and over there both gethostname() and uname -n both return the domain part, so it does indeed seem that what Slackware is doing is in line with standard conventions. So egg all over face here! That's the last f***ing time I believe anything written on a linux man-page!
I just ran into this & think I found a bug in the setup process. After installing Slackware & during configuration it let me use an underscore in my hostname, but after reboot it resorted to darkstar. When I manually removed the _ from /etc/HOSTNAME & rebooted it used my hostname, as expected and as it has done since I first started using slackware in 1996.
I just ran into this & think I found a bug in the setup process. After installing Slackware & during configuration it let me use an underscore in my hostname, but after reboot it resorted to darkstar. When I manually removed the _ from /etc/HOSTNAME & rebooted it used my hostname, as expected and as it has done since I first started using slackware in 1996.
It might not be very well documented and the setup script might lack some sanity check. However, a hostname may only consist of:
letters a-z
digits 0-9
hyphen (-)
The hostname may not start with a hyphen. Trying to add other characters to a hostname like @£#$%/_ will give you trouble.
It might not be very well documented and the setup script might lack some sanity check. However, a hostname may only consist of:
letters a-z
digits 0-9
hyphen (-)
The hostname may not start with a hyphen. Trying to add other characters to a hostname like @£#$%/_ will give you trouble.
regards Henrik
Code:
The file should contain a single newline-terminated hostname
string. Comments (lines starting with a "#") are ignored. The
hostname should be composed of up to 64 7-bit ASCII lower-case
alphanumeric characters or hyphens forming a valid DNS domain
name. It is recommended that this name contains only a single
label, i.e. without any dots. Invalid characters will be filtered
out in an attempt to make the name valid, but obviously it is
recommended to use a valid name and not rely on this filtering.
The file should contain a single newline-terminated hostname
string. Comments (lines starting with a "#") are ignored. The
hostname should be composed of up to 64 7-bit ASCII lower-case
alphanumeric characters or hyphens forming a valid DNS domain
name. It is recommended that this name contains only a single
label, i.e. without any dots. Invalid characters will be filtered
out in an attempt to make the name valid, but obviously it is
recommended to use a valid name and not rely on this filtering.
Yes, it is possible to find that information on the web with a search engine like google. However, I haven't found that information in any man-page installed on Slackware 15.0. My currently oldest running version of Slackware is 9.1, also back then that man page was missing from the system.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.