Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Failed to set hostname, openrc
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
pyx
n00b
n00b


Joined: 12 Apr 2024
Posts: 4

PostPosted: Fri Apr 12, 2024 10:14 pm    Post subject: [Solved] Failed to set hostname, openrc Reply with quote

Hi there, I've been encountered something weird with hostname lately.

I am using openrc-0.54.

For example, if I have:

/etc/hostname
Code:
tux


/etc/conf.d/hostname
Code:
hostname="tux"


/etc/hosts
Code:
127.0.0.1   tux localhost
::1      tux localhost


Service "hostname" is in boot runlevel.

Instead of setting the host name to "tux", what I got is 13 digits of hex number (looks like random number but fixed for individual machine) as host name.

"rc-status -s" shows service "hostname" had been started.

Running "rc-config restart hostname" will set the host name correctly afterwards.

I have service "connman" in default runlevel, but I doubt this is relevant.

This problem started show up about 1 or 2 years ago. I have 5 gentoo boxes with almost identical hostname configuration, only differ in the hostname value (with different names), 3 of them are like that, a newly installed one (last week) worked fine (correctly setting hostname) for a week, after a few update and reboot, had the same problem.

Does anyone have same experience?


Last edited by pyx on Tue Apr 16, 2024 12:56 am; edited 2 times in total
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1922

PostPosted: Fri Apr 12, 2024 10:47 pm    Post subject: Reply with quote

This is most likely your DHCP provider setting a hostname on network starting. Not sure how to tell connman to bypass this.
Back to top
View user's profile Send private message
pyx
n00b
n00b


Joined: 12 Apr 2024
Posts: 4

PostPosted: Fri Apr 12, 2024 11:07 pm    Post subject: Reply with quote

grknight wrote:
This is most likely your DHCP provider setting a hostname on network starting. Not sure how to tell connman to bypass this.


Thank you. I will do some research on that.

Edit: confirmed, I removed service "connman" from runlevel default and the hostname is set correctly, now the problem becomes how do I bypass that like you said. BTW, service "display-manager" will crash if I removed "connman" from default runlevel. Will update if I fixed the problem.
Back to top
View user's profile Send private message
pyx
n00b
n00b


Joined: 12 Apr 2024
Posts: 4

PostPosted: Fri Apr 12, 2024 11:36 pm    Post subject: Reply with quote

Fixed with a (possibly ugly) workaround, I made service "hostname" start after "connman", thus, added service "connman" to runlevel boot and service "hostname" to runlevel default.

Thank you again, grknight
Back to top
View user's profile Send private message
grknight
Retired Dev
Retired Dev


Joined: 20 Feb 2015
Posts: 1922

PostPosted: Sat Apr 13, 2024 12:40 am    Post subject: Reply with quote

A quick search shows that editing /etc/connman/main.conf with the following may fix your issue:
Code:
[General]
AllowHostnameUpdates=false
Back to top
View user's profile Send private message
pyx
n00b
n00b


Joined: 12 Apr 2024
Posts: 4

PostPosted: Sat Apr 13, 2024 1:01 am    Post subject: Reply with quote

grknight wrote:
A quick search shows that editing /etc/connman/main.conf with the following may fix your issue:
Code:
[General]
AllowHostnameUpdates=false


https://github.com/aldebaran/connman/blob/914cf2749d4fc24b54f4a0c44f690090d08af147/doc/connman.conf.5#L96
You are right, haven't tried it yet but this should work.
Thank you.

Edit: tested, it worked.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum