LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Can not get the default hostname to change on current (https://www.linuxquestions.org/questions/slackware-14/can-not-get-the-default-hostname-to-change-on-current-4175649985/)

TarFile 03-11-2019 09:20 PM

Can not get the default hostname to change on current
 
No matter what I do the hostname shows up as darkstar. It is set correctly in /etc/HOSTNAME. I can change it with hostname newname then hostname returns newname. It will not survive a reboot. I know this has happened in the past.

This is on current as of today.

This is driving me crazy where is darkstar coming from?

coralfang 03-11-2019 09:28 PM

Do you get any success by re-running the installer prompt:

Code:

# netconfig

evo2 03-11-2019 09:55 PM

Hi,

perhaps network manager is at fault like in https://www.linuxquestions.org/quest...-a-4175567087/

Evo.

abga 03-11-2019 10:03 PM

@TarFile
have a look in /etc/hosts

TarFile 03-11-2019 10:43 PM

That's the thing not running network manager. I tried everything else. Believe me I googled every way I could think of before posting. etc/NetworkManager/NetworkManager.conf has nothing about darkstar in it. It's somewhere else. I have been using Slackware since it came on 5 1/4 floppies so this is not something I am totally in the dark about.

abga 03-11-2019 11:04 PM

I'm only running Slackware -current on ARM and I don't have any issues with the hostname on that release.
The easiest way to setup the hostname is to use netconfig as @coralfang suggested.
If you go for the manual config, make sure you define your hostname, with the correct syntax if you have a static IP, in both /etc/hosts & /etc/HOSTNAME. Here you have an example:
https://www.linuxquestions.org/quest...6/#post5846761
Note that there's a code sequence in /etc/rc.d/rc.M, that sets the hostname based on what it finds in /etc/HOSTNAME
Code:

# 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


TarFile 03-11-2019 11:22 PM

I am aware of all that. It just does not work for some reason. I'll keep looking but there has to be a reason this is happening.

Uncle Lumpy 03-12-2019 08:58 AM

The only way around this that I've found is to set my hostname of choice when I compile a new kernel. For whatever reason with current, I too found that it always defaulted to darkstar no matter what I did. It might have something to do with what's in the /etc/rc.d/rc.M or /etc/rc.d/rc.S (I forget which) files regarding the hostname. Rather than messing with those, and since I always roll my own kernel, I just set the hostname in the kernel .config file and then it "sticks" upon reboot.

Best,
Lumpy

BW-userx 03-12-2019 09:31 AM

I've always changed both the /etc/HOSTNAME and /etc/hosts files to reflect the same new host name. reboot , done.

TarFile 03-12-2019 12:37 PM

Yes those are set correctly, still does not work for some reason.

I am able to override it it /etc/rc.local but that seems like a kludge to me.

coralfang 03-12-2019 03:18 PM

Quote:

Originally Posted by TarFile (Post 5973086)
Yes those are set correctly, still does not work for some reason.

I am able to override it it /etc/rc.local but that seems like a kludge to me.

Did you try setting the hostname with `/sbin/netconfig` ? That should set the hostname in all required places..

TarFile 03-12-2019 03:31 PM

Yes I set it with `/sbin/netconfig` all of the files are correct but still darkstar after reboot, unless I put overrides in /etc/rc.local.

abga 03-12-2019 04:04 PM

Quote:

Originally Posted by TarFile (Post 5973156)
Yes I set it with `/sbin/netconfig` all of the files are correct but still darkstar after reboot, unless I put overrides in /etc/rc.local.

The kernel in Slackware is built without a default hostname, that's CONFIG_DEFAULT_HOSTNAME="(none)", so the kernel shouldn't cause any problems.
By respecting the correct syntax for defining the hostname in both /etc/HOSTNAME & /etc/hosts I never got into issues like the one you're reporting now. Trying to rule out a bug in /bin/hostname or /sbin/netconfig, it'll be helpful if you could provide your actual /etc/HOSTNAME & /etc/hosts files and also provide some details about your setup, if you're using a static IP or DHCP & if you're using a local (your own) DNS server/resolver.
You could also try defining your hostname directly in the /proc/sys/kernel/
https://www.kernel.org/doc/Documenta...ctl/kernel.txt
"domainname & hostname:" Section:
Code:

# echo "darkstar" > /proc/sys/kernel/hostname
# echo "mydomain" > /proc/sys/kernel/domainname
has the same effect as
# hostname "darkstar"
# domainname "mydomain"


TarFile 03-13-2019 02:46 PM

# echo "darkstar" > /proc/sys/kernel/hostname
# echo "mydomain" > /proc/sys/kernel/domainname

Still won't survive a reboot.

Richard Cranium 03-13-2019 04:03 PM

Do you have a filesystem that mounts on /etc? (It would be difficult to do that and have stuff work in the first place, but just in case...)


All times are GMT -5. The time now is 07:02 PM.