[SOLVED] what to do after netconfig so all changes are visible
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.
Thanks for the reply. I know that I can do so, but I already have entered the hostname using netconfig and hence expect it to be set straight away.
I've done a little analysis. I had a look at /sbin/netconfig (I was surprised to find that it's a script) and found that it sets the hostname/domainname in /etc/HOSTNAME once both are specified (a minor bug as a user can still cancel the configuration at a later stage and ends up with an unexpected incorrect hostname after the next reboot).
Further at boottime, rc.M is responsible for setting the hostname. As running that file on a fully booted system more than likely has a lot of implications, I'm afraid (but not sure) that it can not be used.
For me the solution is to run the hostname command from within the netconfig script to set the hostname; this way the hostname command without parameters will at least reflect the contents of the file /etc/HOSTNAME.
For those who want to make that change (it's advised to make a backup of /sbin/netconfig first):
As root, open the file /sbin/netconfig using your favorite editor and search for etc/HOSTNAME; you should find something like the code below (without the bold line).
Next add the bold line and save the work
Code:
...
...
echo $HOSTNM.$DOMAIN > etc/HOSTNAME
/bin/hostname $HOSTNM
dialog -- title "SETUP IP ADDRESS ...
...
...
I might look a little further into this at a later stage (meaning when I'm more confident with scripting and have some time).
For me the solution is to run the hostname command from within the netconfig script to set the hostname; this way the hostname command without parameters will at least reflect the contents of the file /etc/HOSTNAME.
For those who want to make that change (it's advised to make a backup of /sbin/netconfig first):
As root, open the file /sbin/netconfig using your favorite editor and search for etc/HOSTNAME; you should find something like the code below (without the bold line).
Next add the bold line and save the work
Code:
...
...
echo $HOSTNM.$DOMAIN > etc/HOSTNAME
/bin/hostname $HOSTNM
dialog -- title "SETUP IP ADDRESS ...
...
...
I might look a little further into this at a later stage (meaning when I'm more confident with scripting and have some time).
WimS
It's your system to do as you wish/want. But why would you change a static file like '/etc/HOSTNAME'? When you setup your installation initially you are queried for a 'HOSTNAME'. You answer that query and the '/etc/HOSTNAME' file is generated with the name.
As I did not run the netconfig at installation but afterwards. And the hostname file is indeed set, but not reflected when you run the hostname command without parameters.
As I did not run the netconfig at installation but afterwards. And the hostname file is indeed set, but not reflected when you run the hostname command without parameters.
You should 'man hostname';
Code:
excerpt from 'man hostname'
:~# man hostname
Formatting page, please wait...
hostname [-v] [-F filename] [--file filename] [hostname]
domainname [-v] [-F filename] [--file filename] [name]
nodename [-v] [-F filename] [--file filename] [name]
hostname [-v] [-h] [--help] [-V] [--version]
dnsdomainname [-v]
nisdomainname [-v]
ypdomainname [-v]
DESCRIPTION
Hostname is the program that is used to either set or display the cur-
rent host, domain or node name of the system. These names are used by
many of the networking programs to identify the machine. The domain
name is also used by NIS/YP.
GET NAME
When called without any arguments, the program displays the current
names:
hostname will print the name of the system as returned by the gethost-
name(2) function.
domainname, nisdomainname, ypdomainname will print the name of the sys-
tem as returned by the getdomainname(2) function. This is also known as
the YP/NIS domain name of the system.
nodename will print the DECnet node name of the system as returned by
the getnodename(2) function.
dnsdomainname will print the domain part of the FQDN (Fully Qualified
Domain Name). The complete FQDN of the system is returned with hostname
--fqdn.
....
As I stated the 'HOSTNAME' is set when you do the 'SlackwareŽ' install. If you don't respond with a hostname then the default 'darkstar' is used for the '/etc/HOSTNAME'. If you want to change the 'HOSTNAME' then use the command with different options.
As I stated it is your system to do as you wish. But!
As I stated the 'HOSTNAME' is set when you do the 'SlackwareŽ' install. If you don't respond with a hostname then the default 'darkstar' is used for the '/etc/HOSTNAME'. If you want to change the 'HOSTNAME' then use the command with different options.
OK, please help me out here as I don't know exactly where you want to go.
Running netconfig does not set the 'HOSTNAME', it only writes it to '/etc/HOSTNAME'. In my opinion that's something different. One will not notice this easily as there is a reboot involved after the install which will take care of it but if one runs netconfig at a later stage you will notice.
I did read the man page and nowhere is an option to set the hostname permanently using the hostname command (which you seem to imply but maybe I misunderstood you).
My problem is that a supplied script (netconfig) sets the hostname in /etc/HOSTNAME but when one runs the hostname command without parameters afterwards, it does not reflect the contents of that file.
To get it right, one has to run the hostname command with the hostname specified during the netconfig (or reboot the system) in which case /etc/rc.d/rc.M will take care of it.
My proposed solution is to modify netconfig so the hostname command will reflect the changes made to the file /etc/HOSTNAME during the netconfig.
As I stated the 'HOSTNAME' is set when you do the 'SlackwareŽ' install. If you don't respond with a hostname then the default 'darkstar' is used for the '/etc/HOSTNAME'. If you want to change the 'HOSTNAME' then use the command with different options.
As I stated it is your system to do as you wish. But!
Each boot, your hostname is set based on the contents of /etc/HOSTNAME. The hostname command doesn't change this file, but the netconfig does. You need to change the file if you want the change to be permanent. This isn't a bad thing.
Wim Sturkenboom:
My understanding of netconfig is that it's purpose is to setup up the configuration files, and that's what it does. It's not a bug that those changes aren't reflected immediately, that's just how it works. Rerunning /etc/rc.d/rc.inet1 should reflect those changes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.