View previous topic :: View next topic |
Author |
Message |
akrmn24 n00b
Joined: 24 Nov 2024 Posts: 16
|
Posted: Mon Jan 13, 2025 6:02 pm Post subject: Proper way to set hostname |
|
|
In the installation manual it says to set the hostname in /etc/hostname. But this has no effect for me. In my terminal it shows just user@#, and hostname command returns a blank entry, and various programs that depend on the hostname give warnings. It only gets set when I use the hostname command (hostname <name>). Then I logout and log back in and I see the user@hostname in the terminal.
I'm trying this on a MUSL / arm64 / openrc system btw. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9864 Location: almost Mile High in the USA
|
Posted: Mon Jan 13, 2025 7:17 pm Post subject: |
|
|
After changing /etc/hostname you'll need to make openrc reread it.
/etc/init.d/hostname restart (or a reboot) should do it?
As an aside, does changing /etc/conf.d/hostname even work? The code looks wrong... or is it... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1045 Location: Somewhere in Denmark
|
Posted: Mon Jan 13, 2025 7:37 pm Post subject: |
|
|
eccerr0r wrote: | After changing /etc/hostname you'll need to make openrc reread it.
/etc/init.d/hostname restart (or a reboot) should do it?
As an aside, does changing /etc/conf.d/hostname even work? The code looks wrong... or is it... |
I'm setting hostname with/in /etc/conf.d/hostname since forever - works perfectly fine. Code: | ns ~ # cat /etc/conf.d/hostname
# Hostname fallback if /etc/hostname does not exist
hostname="ns.vlh.dk"
ns ~ # hostname
ns.vlh.dk |
|
|
Back to top |
|
|
Ralphred l33t
Joined: 31 Dec 2013 Posts: 701
|
Posted: Mon Jan 13, 2025 8:25 pm Post subject: |
|
|
freke wrote: | hostname="ns.vlh.dk"
ns ~ # hostname
ns.vlh.dk[/code] | My mail server does odd things if I set the hostname to an FQDN and not just the host, like sending mail from root@hostname.mydomain.com.mydomain.com.
The only time the FQDN is set outside the context of "connect to/use this <IP|FQDN>" optional software config files is in /etc/hosts, re: Code: | 127.0.0.1 <FQDN> <hostname> localhost |
|
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9864 Location: almost Mile High in the USA
|
Posted: Mon Jan 13, 2025 9:59 pm Post subject: |
|
|
hostname should be just the name of the host, not fqdn.
domain name is separate.
I was staring at the init script for hostname and it just looks wrong for some reason. maybe there's some other script that handles /etc/conf.d/hostname. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
freke Veteran
Joined: 23 Jan 2003 Posts: 1045 Location: Somewhere in Denmark
|
Posted: Tue Jan 14, 2025 4:26 pm Post subject: |
|
|
/etc/conf.d/hostname is handled by /etc/init.d/hostname if /etc/hostname is missing: Code: | start()
{
local h source
if read -r h _ 2> /dev/null < /etc/hostname; then
source="/etc/hostname"
elif [ -n "${hostname}" ]; then
h=${hostname}
source="/etc/conf.d/${RC_SVCNAME}"
fi | and setting fqdn in /etc/conf.d/hostname seems to work/resolve fine for me Code: | ns ~ # hostname -s
ns
ns ~ # hostname -d
vlh.dk
ns ~ # hostname -f
ns.vlh.dk | done that for years on my servers (mail-/web-) |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9864 Location: almost Mile High in the USA
|
Posted: Tue Jan 14, 2025 6:25 pm Post subject: |
|
|
perhaps what I'm missing is the implicit sourcing of conf.d/hostname else it doesn't ever actually read the file... ahh. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
|