You are not logged in.

#1 2019-02-19 15:32:08

vdraceil
Member
Registered: 2019-02-18
Posts: 9

[SOLVED] Where is my hostname string coming from?

I remember setting my hostname as 'vino_hp_envy_13' when I installed Arch Linux and did all the settings, like a year back.
I just happened to notice that my hostname is set to 'vinohpenvy13' (without underscores) after I added it as a part of my bash terminal prompt (PS1) string.

➜ hostname
vinohpenvy13

➜ hostname -f
vinohpenvy13

➜ cat /etc/hostname
vino_hp_envy_13

I haven't set any explicit hostname in my /etc/hosts file.
Although, I tried to add

127.0.0.1	vino_hp_envy_13.localdomain		vino_hp_envy_13

as suggested in some stackoverflow threads, but that didn't seem to help.

➜ cat /etc/hosts
#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost

Then I tried to set the hostname via hostnamectl and that didn't work either
The pretty hostname is correct, but the static one isn't. I guess thats being picked up in bash PS1 (when I use \h)

➜ hostnamectl
   Static hostname: vinohpenvy13
   Pretty hostname: vino_hp_envy_13
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 8dff5a90960a461f93c88cb73a15a63b
           Boot ID: 87bd7539519e420383ab721f3c1d6357
  Operating System: Arch Linux
            Kernel: Linux 4.20.8-arch1-1-ARCH
      Architecture: x86-64

➜ hostnamectl --static set-hostname vino_hp_envy_13
Could not set property: Invalid static hostname 'vino_hp_envy_13'

The on reading more about from where the hostname string is derived, I stumbled on the /etc/nsswitch.conf and getent
Outputs of them are below.

➜ cat /etc/nsswitch.conf 
passwd: files mymachines systemd
group: files mymachines systemd
shadow: files
publickey: files
hosts: files mymachines myhostname resolve [!UNAVAIL=return] dns
networks: files
protocols: files
services: files
ethers: files
rpc: files
netgroup: files

➜ cat /etc/machine-info 
PRETTY_HOSTNAME=vino_hp_envy_13

➜ getent ahosts `hostname`
fe80::8a78:73ff:fe82:aeec STREAM vinohpenvy13
fe80::8a78:73ff:fe82:aeec DGRAM  
fe80::8a78:73ff:fe82:aeec RAW    
192.168.0.113   STREAM 
192.168.0.113   DGRAM  
192.168.0.113   RAW   

I can see it showing `fe80::8a78:73ff:fe82:aeec STREAM vinohpenvy13` in the output of getent command but I do not know how to set it to vino_hp_envy_13.
This is definitely not a pressing issue, but I'd like to get it solved.
Any pointers would definitely be great.

Last edited by vdraceil (2019-02-22 15:43:10)

Offline

#2 2019-02-19 15:36:04

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,992
Website

Re: [SOLVED] Where is my hostname string coming from?

I would suspect, that it's been pushed to your client from an DHCP server.


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#3 2019-02-19 16:07:42

vdraceil
Member
Registered: 2019-02-18
Posts: 9

Re: [SOLVED] Where is my hostname string coming from?

schard wrote:

I would suspect, that it's been pushed to your client from an DHCP server.

Is there a way I can update or reset it?

Offline

#4 2019-02-19 16:16:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,576
Website

Re: [SOLVED] Where is my hostname string coming from?

Underscores are not valid in hostnames:
http://man7.org/linux/man-pages/man7/hostname.7.html


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#5 2019-02-19 16:46:21

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,992
Website

Re: [SOLVED] Where is my hostname string coming from?

Trilby's right. hostnamectl will silently strip invalid characters.

$ hostnamectl set-hostname host_name
$ hostnamectl
   Static hostname: hostname
   Pretty hostname: host_name
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: 304f5e1faa2b4baab317a1ff794ba1fb
           Boot ID: 257c7f492da544bb822285d8c9e10d68
  Operating System: Arch Linux
            Kernel: Linux 4.20.10-arch1-1-ARCH
      Architecture: x86-64

macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#6 2019-02-22 15:43:58

vdraceil
Member
Registered: 2019-02-18
Posts: 9

Re: [SOLVED] Where is my hostname string coming from?

Thank you schard & trilby.
I'll have my hostname set to something without underscores.

Offline

Board footer

Powered by FluxBB