-   Linux - Networking (
-   -   Change hostname Centos (

blackRonin 06-08-2014 11:54 AM

Change hostname Centos
1 Attachment(s)

I'm using centos on lenovo x220.
During installation i set up "centosx220" hostname

But after installation complete i see different hostname (220-THINK).
I added attachment

I also see "localhost" on top of the prompt window.

Help me please.

lleb 06-08-2014 05:39 PM

the localhost at the top of the terminal is 100% correct. you opened a GUI konsole and you are local are you not? then yes that is correct.

to see your host name of the system, in konsole type

$ hostname
it will report the systems hostname. it will look something like this:

[user@server ~]$ hostname

That is direct from my CentOS box.

blackRonin 06-09-2014 02:56 AM


piotr@X220-THINK:~$ hostname
piotr@X220-THINK:~$ su -
root@X220-THINK:~# hostname
I don't understand why i have X220-THINK, when i didn't type that anywhare.

evo2 06-09-2014 03:00 AM


the hostname can be set by the dhcp server. What is your network setup?


blackRonin 06-09-2014 04:59 AM

I have soho router DRG A226G, which is also dhcp server

I looked into router settings, but i couldn't find any options to change hostname or dhcp server settings.

I also tried search into router user manual, but i can't find any dhcp settings there too.

ndc85430 06-09-2014 05:35 AM

You can also set the hostname in /etc/sysconfig/network. Add or edit the line beginning "HOSTNAME=". See, e.g. this.

blackRonin 06-09-2014 04:07 PM

There is no other way ?
Whey is stored hostname typed during install proces ?

jamison20000e 06-09-2014 05:41 PM

I've used:
some distros have set it on me too kinda like way, way back when I used winblow$

lleb 06-09-2014 09:13 PM

yeah, should like something like this:

[user@server ~]$ cat /etc/sysconfig/network


fill in your details.

GaWdLy 06-09-2014 09:25 PM

BlackRonin: In RH variants like CentOS, hostname is set by DHCP, or in /etc/sysconfig/network. Setting it on the fly ie- '# hostname [somename]' is not permanent and won't persist across reboots.

If you are using the GUI, and NetworkManager, be sure to have the correct hostname set there, too.

blackRonin 06-10-2014 03:31 PM

GaWdLy, i remember when i changed hostname by editting /et/sysconfig/network
Name was changed in console, but other clients in network saw old hostname, and router too.
I couldn't see and ping by new hostname.

So, how i can change it in DHCP ?

GaWdLy 06-10-2014 04:17 PM


Originally Posted by blackRonin (Post 5185878)
GaWdLy, i remember when i changed hostname by editting /et/sysconfig/network
Name was changed in console, but other clients in network saw old hostname, and router too.
I couldn't see and ping by new hostname.

After a full service stop/start, or a reboot?


So, how i can change it in DHCP ?
I think it's set by the DHCP server...

blackRonin 06-10-2014 06:38 PM

GaWdLy, yes after reboot still the same in router settings:


[root@linux1 ~]# cat /etc/sysconfig/network
Quote: localhost.localdomain localhost.localdomain localhost4 localhost4.localdomain4 localhost linux1
::1 localhost.localdomain localhost.localdomain localhost6 localhost6.localdomain6 localhost linux1
And in router is see:

In router i have see no option to change that.

michaelk 06-10-2014 08:58 PM

The DHCP client sends the hostname to the server.

Try adding the directive DHCP_HOSTNAME=hostname to your /etc/sysconfig/network-scripts/ifcfg-eth0

lleb 06-11-2014 08:43 PM

most DHCP servers set the name, but if the DHCP server requires the name from the client, then you would use the DHCP_HOSTNAME= from michaelk's post.


DHCP_HOSTNAME — Only use this option if the DHCP server requires the client to specify a hostname before receiving an IP address.

All times are GMT -5. The time now is 01:18 AM.