[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.
# Set the hostname.
if [ -r /etc/HOSTNAME ]; then
/bin/hostname $(cat /etc/HOSTNAME)
else
# fall back on this old default:
echo "darkstar.example.net" > /etc/HOSTNAME
/bin/hostname $(cat /etc/HOSTNAME)
fi
Well, the obvious question that I haven't seen asked yet is what permissions do you see on /etc/HOSTNAME? If it's not readable then the script will overwrite it each boot.
# Set the hostname.
if [ -r /etc/HOSTNAME ]; then
/bin/hostname $(cat /etc/HOSTNAME)
else
# fall back on this old default:
echo "darkstar.example.net" > /etc/HOSTNAME
/bin/hostname $(cat /etc/HOSTNAME)
fi
copied to rc.sethostname then ran it.
bash-5.0# ./rc.sethostname
hostname: the specified hostname is invalid
I saw that flash by at boot time right after the going multiuser message.
Aw crap HOSTNAME was invalid netconfig shoved the hostname and the domain as one hostname for some reason must have been too big. There is a bug somewhere probably in netconfig?
OK I am not exactly sure how this is supposed to work.
netconfig asks for a hostname then a domainname.
It puts hostname.domainname in /ect/HOSTNAME.
hostname on the command line returns hostname.domainname
domainname returns (none)
My problem was caused by the domainname I put in netconfig.
It has a problem if you use something like this domainname_name.org apparently the _ is not allowed in a doaminname at least it won't work here. Since I don't know the rules for domain names (if any) I just put in what I liked for the local network.
Still I think if netconfig asks for a domainname it should set it correctly, providing of course it's a name that meets whatever rules are in place.
Not sure if this is a bug or a feature.
OK for what its worth
AG Domain Name Rules Summary
Use only letters, numbers, or hyphen ("-")
Domain names cannot begin or end with a hyphen
Domain names cannot have more than 63 characters, not including .AG, .COM.AG, .NET.AG, .ORG.AG, .EDU.AG, .GOV.AG, ETC.
Maximum length of a complete (Fully Qualified, FQDN) domain name (including .separators) is 255 characters
Minimum length of a domain name is 1 character, not including extensions. However, all 1 character domain names are reserved by the Registry.
A name may begin with a digit
Two character domain names are allowed
Domain names considered offensive may be declined
For domains to be active on the Internet, they must have at least one configured and working name server.
There is no restriction on the physical location or IP address of these name servers.
The rest is not related to the names allowed.
This rules out the use of _ in a domainname the cause of my initial problem.
I still think domainname should be set ny netconfig but I suppose there may be a reason it's not.
OK if domainname gives you the NIS/YP domain is that not the one set up by netconfig?
No. All netconfig does with the domainname part is add it to the entry in /etc/hosts for the ip address entered, but as I said above, I believe netconfig is doing it wrong anyway by including the domain part in /etc/HOSTNAME.
Yes that does seem odd. Oh well it does show the correct hostname but does not set the domianname at all. I think I may have seem something about not setting domianname for some reason in one of the setup files somewhere in /etc.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.