LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-08-2014, 11:54 AM   #1
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Rep: Reputation: Disabled
Change hostname Centos


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.
Attached Thumbnails
Click image for larger version

Name:	screen.png
Views:	30
Size:	250.3 KB
ID:	15694  

Last edited by blackRonin; 06-08-2014 at 11:55 AM.
 
Old 06-08-2014, 05:39 PM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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.
 
1 members found this post helpful.
Old 06-09-2014, 02:56 AM   #3
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-09-2014, 03:00 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

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

Evo2.
 
1 members found this post helpful.
Old 06-09-2014, 04:59 AM   #5
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
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
 
Old 06-09-2014, 05:35 AM   #6
ndc85430
Member
 
Registered: Apr 2014
Distribution: Slackware
Posts: 92

Rep: Reputation: Disabled
You can also set the hostname in /etc/sysconfig/network. Add or edit the line beginning "HOSTNAME=". See, e.g. this.
 
1 members found this post helpful.
Old 06-09-2014, 04:07 PM   #7
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
There is no other way ?
Whey is stored hostname typed during install proces ?
 
Old 06-09-2014, 05:41 PM   #8
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
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$
 
Old 06-09-2014, 09:13 PM   #9
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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.
 
Old 06-09-2014, 09:25 PM   #10
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
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.
 
Old 06-10-2014, 03:31 PM   #11
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
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 ?
 
Old 06-10-2014, 04:17 PM   #12
GaWdLy
Member
 
Registered: Feb 2013
Location: San Jose, CA
Distribution: RHEL/CentOS/Fedora
Posts: 457

Rep: Reputation: Disabled
Quote:
Originally Posted by blackRonin View Post
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...
 
Old 06-10-2014, 06:38 PM   #13
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-10-2014, 08:58 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,703

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
The DHCP client sends the hostname to the server.

Try adding the directive DHCP_HOSTNAME=hostname to your /etc/sysconfig/network-scripts/ifcfg-eth0
 
Old 06-11-2014, 08:43 PM   #15
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
'hostname some_name' does not change the hostname. stf92 Slackware 11 02-21-2013 07:09 PM
getting errors related to hostname -- security problem? ok to change hostname? sneakyimp Linux - Server 2 11-18-2012 05:25 PM
Centos 6 - machine does not know it's own hostname yanom Red Hat 1 07-18-2012 12:21 AM
change hostname of LINUX CentOS 5 while running informix server ytd Linux - General 5 08-11-2009 01:04 AM
after hostname change, syslogd still output previous hostname to messages file tiger2000 Linux - General 3 07-22-2009 09:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration