LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   what to do after netconfig so all changes are visible (https://www.linuxquestions.org/questions/slackware-14/what-to-do-after-netconfig-so-all-changes-are-visible-636016/)

Wim Sturkenboom 04-17-2008 10:17 AM

what to do after netconfig so all changes are visible
 
I'm changing the network configuration using netconfig on a Slackware 12 box.

If I check ifconfig and hostname the changes have not been made. Changes have however been made to /etc/hosts and /etc/rc.d/rc.inet1.conf.

Which script/program do I need to run to make the changes take effect. I tried /etc/rc.d/rc.inet1 but that did not help.

Bruce Hill 04-17-2008 10:32 AM

Did you restart the service yet?
Code:

/etc/rc.d/rc.inet1 restart

Wim Sturkenboom 04-17-2008 10:50 AM

Thanks for the reply

I did run it (as said in the first post) but as I did not see the MAIN section in that file I assumed that it could be run without arguments.

It does not solve the whole issue as hostname and the login prompt still reflect the old names. But at least the IP info is there.

Bruce Hill 04-17-2008 11:01 AM

To change your system's hostname issue "/bin/hostname <new-name>" - "man hostname" will help.

Wim Sturkenboom 04-18-2008 01:44 AM

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).

WimS

onebuck 04-18-2008 05:55 PM

Hi,

Quote:

Originally Posted by Wim Sturkenboom (Post 3124922)
<snip>

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.

Wim Sturkenboom 04-20-2008 09:14 AM

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.

onebuck 04-20-2008 12:28 PM

Hi,
Quote:

Originally Posted by Wim Sturkenboom (Post 3126942)
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!:study:

Wim Sturkenboom 04-21-2008 12:23 AM

Quote:

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.

WimS

ice_nine 04-21-2008 02:21 AM

Quote:

Originally Posted by onebuck (Post 3127091)

...

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!:study:

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.


All times are GMT -5. The time now is 04:29 PM.