LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Change hostname Centos (http://www.linuxquestions.org/questions/linux-networking-3/change-hostname-centos-4175507422/)

blackRonin 06-08-2014 12:54 PM

Change hostname Centos
 
1 Attachment(s)
Hello

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 06: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
Code:

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

[user@server ~]$ hostname
server.somename

That is direct from my CentOS box.

blackRonin 06-09-2014 03:56 AM

Quote:

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

evo2 06-09-2014 04:00 AM

Hi,

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

Evo2.

blackRonin 06-09-2014 05: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.
http://beghiero.myftp.org/mendocino8...r%20Manual.pdf

ndc85430 06-09-2014 06: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 05:07 PM

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

jamison20000e 06-09-2014 06:41 PM

I've used: http://www.cyberciti.biz/faq/linux-change-hostname/
some distros have set it on me too kinda like way, way back when I used winblow$

lleb 06-09-2014 10:13 PM

yeah, should like something like this:
Code:

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

NETWORKING=yes
HOSTNAME=server.mylan
GATEWAY=192.168.xxx.xxx

fill in your details.

GaWdLy 06-09-2014 10: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 04: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 05:17 PM

Quote:

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?

Quote:

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

blackRonin 06-10-2014 07:38 PM

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

Quote:

[root@linux1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=linux1
NOZEROCONF=yes
GATEWAYDEV=eth0
IPV6INIT=yes
IPV6_DEFAULTDEV=eth0
NETWORKING_IPV6=yes
etc/hosts
Quote:

127.0.0.1 localhost.localdomain localhost.localdomain localhost4 localhost4.localdomain4 localhost linux1
::1 localhost.localdomain localhost.localdomain localhost6 localhost6.localdomain6 localhost linux1
And in router is see:
"new-host 192.168.1.228"

In router i have see no option to change that.

michaelk 06-10-2014 09: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 09:43 PM

https://access.redhat.com/site/docum...ng-client.html

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.

Quote:

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 07:17 PM.