Scientific Linux Forum.org



  Reply to this topicStart new topicStart Poll

> Changing of Hostname
ahmadkakakhail
 Posted: Apr 26 2017, 11:29 AM
Quote Post


SLF Newbie


Group: Members
Posts: 2
Member No.: 3863
Joined: 26-April 17









Hello!

I am new user of Scientific Linux. I want to change the hostname for my machine. I read online that in the file /etc/sysconfig/network, we can edit the hostname. Well I did and run the hostname command and it showed me the changed hostname. But when I used command hostname -f which is requirement in my case that it should return the hostname, it returned unknown host.

I read on some other link that I must edit the file /etc/hosts but when I checked through other machines running Scientific Linux, I didn't see any changes in that file, it is same as created at first. But those machines are returning hostname when I run the command hostname -f.

Can anybody tell me please what could be the problem?

Thanks in Advance!
PM
^
burakkucat
 Posted: Apr 26 2017, 01:40 PM
Quote Post


SLF Administrator
****

Group: Admins
Posts: 200
Member No.: 14
Joined: 10-April 11









That is odd.

You should only need to set the hostname in the /etc/sysconfig/network file.

Running the hostname command with the -v flag will output further details.

For example, this is what I see --

CODE

[Duo2 ~]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=Duo2
[Duo2 ~]$

[Duo2 ~]$ hostname -v -f
gethostname()=`Duo2'
Resolving `Duo2' ...
Result: h_name=`Duo2'
Result: h_addr_list=`192.168.1.3'
Duo2
[Duo2 ~]$


I wonder . . . Have you re-booted the system after setting the hostname in the /etc/sysconfig/network file?

--------------------
user posted image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.
PMUsers Website
^
ahmadkakakhail
 Posted: Apr 27 2017, 07:35 AM
Quote Post


SLF Newbie


Group: Members
Posts: 2
Member No.: 3863
Joined: 26-April 17









Thanks for replying burakkucat.

Yes I have rebooted the system after changing the file /etc/sysconfig/network but it didn't show the hostname after running the hostname -f command.

I have tried hostname -v -f as well but when I did, I got this output:

[root@ciit ~]# hostname -v -f
gethostname()=`ciit'
Resolving `ciit' ...
hostname: Unknown host

I don't know what could be the problem because it should change it using this method.
PM
^
burakkucat
 Posted: Apr 27 2017, 04:32 PM
Quote Post


SLF Administrator
****

Group: Admins
Posts: 200
Member No.: 14
Joined: 10-April 11









Hmm . . .

Please try adding a line to your /etc/hosts file that specifies both the hostname and the IP address to which it is mapped. (Assuming that it is a static IP address.)

For example, this is the line I have in my /etc/hosts file --

CODE

192.168.1.3 Duo2

--------------------
user posted image 100% Linux and, previously, Unix. Co-founder of the ELRepo Project.
PMUsers Website
^
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll