Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • can't use "_" in RHEL 9 hostname

    Posted on

    in RHEL 9 (

    5.14.0-70.22.1.el9_0.x86_64
    )
    I have tried to change the static hostname from
    rhel9test1
    to
    rhel9_test1
    ( add a "
    _
    " ) but it won't change

    $ ssh rhel9_test1 
     [root@rhel9test1 ~]# uname -a 
    Linux rhel9test1 5.14.0-70.22.1.el9_0.x86_64 #1 SMP PREEMPT Tue Aug 2 10:02:12 EDT 2022 x86_64 x86_64 x86_64 GNU/Linux
    [root@rhel9test1 ~]# echo rhel9_test1 > /proc/sys/kernel/hostname
    [root@rhel9test1 ~]# cat /proc/sys/kernel/hostname
     rhel9_test1
    [root@rhel9test1 ~]# hostname rhel9_test1
    [root@rhel9test1 ~]# cat /etc/sysconfig/network | grep HOSTNAME
    HOSTNAME=rhel9_test1 
    [root@rhel9test1 ~]# sysctl kernel.hostname=rhel9_test1 
    kernel.hostname = rhel9_test1 
    [root@rhel9test1 ~]# cat /etc/hosts | grep rhel9 10.180.107.140 rhel9_test1.1800flowers.int rhel9_test1
    [root@rhel9test1 ~]# hostnamectl 
    Static hostname: rhel9test1  how to change 
    Pretty hostname: rhel9_test1 
    Transient hostname: rhel9_test1 
    [root@rhel9test1 ~]# bash
    [root@rhel9_test1 ~]#
    

    looks good now BUT after reboot --- it is not saved. Static hostname is not changed

    [root@rhel9_test1 ~]# reboot 
    Connection to rhel9_test1 closed by remote host. 
    Connection to rhel9_test1 closed. 
    
    $ ssh rhel9_test1 
    [root@rhel9test1 ~]# cat /proc/sys/kernel/hostname
    rhel9test1     
    [root@rhel9test1 ~]# hostnamectl
    Static hostname: rhel9test1 
    Pretty hostname: rhel9_test1
    

    this yields an error

    [root@rhel9test1 ~]# hostnamectl set-hostname rhel9_test1 --static 
    Could not set static hostname: Invalid static hostname 'rhel9_test1' 
    [root@rhel9test1 ~]#
    

    QUESTION >> why can't I use an "

    _
    " ( underscore ) in the RHEL 9 hostname. the above works fine in RHEL 8.

    What am i missing ?!?

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2026 Red Hat