Forum › Forums › New users › New Users and General Questions › How to setup hostname permanently
- This topic has 4 replies, 4 voices, and was last updated Feb 15-7:43 am by xinomilo.
-
AuthorPosts
-
February 13, 2023 at 5:13 pm #99515Member
jeffmernier
Hi Folks,
During fresh installation I set up <hostname> to ‘antix’ but after reboot the hostname ($HOSTNAME) is ‘dhcppc7’. First question is: where ‘dhcppc7’ is coming from?
I have check <hostname> in /etc/hostname (and /etc/hosts) and it is ‘antix’ like it was provided during the installation.I can change hostname from ‘dhcppc7’ to ‘antix’ with the script provided
/etc/init.d/hostname.sh start
which reads from /etc/hostname and set $HOSTNAME temporarily to ‘antix’ but after reboot hostname is restored to ‘dhcppc7’I also tried to start the hostname service at boot from
/usr/sbin/sysv-rc-confon runlevels 2,3,4,5 but then X failsrc-update-rc.d hostname defaultssysv-rc-conf --list hostname hostname 2:on 3:on 4:on 5:on S:onHas anybody knows a way to make this permanent?
Thanks!
- This topic was modified 2 months, 3 weeks ago by jeffmernier.
- This topic was modified 2 months, 3 weeks ago by jeffmernier.
- This topic was modified 2 months, 3 weeks ago by jeffmernier.
February 13, 2023 at 6:09 pm #99519Moderator
Brian Masinick
::https://duckduckgo.com/?q=how+to+change+linux+hostname+permanently&t=h_&ia=web is a search string that provides several answers.
One thing to do is to set the name of your system in the file /etc/hostname.
The second is to set the name and the address of your system in the file /etc/hosts.
Third, run: /etc/init.d/hostname restart.
All of these commands require privileged access.https://www.tecmint.com/set-hostname-permanently-in-linux/ goes through some examples.
Since we do not use systemd, don’t follow any steps that reference it, whether from
tecmint or any other source.--
Brian MasinickFebruary 14, 2023 at 7:22 am #99543MemberXunzi_23
::Hi, if connman is used it must also be taken in to consideration.
Manual and text points to need, the main.conf must be changed as
below./etc/connman/main.conf
# Allow ConnMan to change the system hostname. This can
# happen for example if we receive DHCP hostname option.
# Default value is true.
AllowHostnameUpdates = false# Allow ConnMan to change the system domainname. This can
# happen for example if we receive DHCP domainname option.
# Default value is true.
AllowDomainnameUpdates = falseFebruary 14, 2023 at 5:37 pm #99588Memberjeffmernier
::thanks so much! That worked. You’re good!
I believe I can restore /etc/init.d/hostname to /etc/init.d/hostname.sh script because /etc/init.d/hostname service was not involved in this issue.
- This reply was modified 2 months, 3 weeks ago by jeffmernier.
February 15, 2023 at 7:43 am #99633Member
xinomilo
::always did :
hostname newname echo 'newname' > /etc/hostnamethat would change hostname. permanently.
and as @masinick writes, changes in /etc/hosts to be able to ping hostname (and some daemons use that, iirc).
-
AuthorPosts
- You must be logged in to reply to this topic.