How to setup hostname permanently

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.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #99515
    Member
    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-conf on runlevels 2,3,4,5 but then X fails

      rc-update-rc.d hostname defaults

      sysv-rc-conf --list hostname
      hostname     2:on       3:on    4:on    5:on    S:on

      Has 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.
      #99519
      Moderator
      Brian Masinick
        Helpful
        Up
        0
        ::

        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 Masinick

        #99543
        Member
        Xunzi_23
          Helpful
          Up
          0
          ::

          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 = false

          #99588
          Member
          jeffmernier
            Helpful
            Up
            0
            ::

            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.
            #99633
            Member
            xinomilo
              Helpful
              Up
              0
              ::

              always did :

              hostname newname
              echo 'newname' > /etc/hostname

              that would change hostname. permanently.

              and as @masinick writes, changes in /etc/hosts to be able to ping hostname (and some daemons use that, iirc).

            Viewing 5 posts - 1 through 5 (of 5 total)
            • You must be logged in to reply to this topic.