LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2014, 11:20 AM   #1
haitaoqiu
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Rep: Reputation: Disabled
change hostname


I setup a virtual machine runs Fedora Linux. I changed the hostname by command: hostname virtuallinux. But then when I do command: ping virtuallinux, I got this error:

ping: unknown host virtuallinux

How do I make the new hostname known within my network?

Thanks!
 
Old 04-29-2014, 01:23 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
I assume you did your ping from a server outside the server you renamed?

Whatever server you did the ping from is looking for the hostname you gave it and would typically get that from DNS, NIS or /etc/hosts (on UNIX/Linux - hosts file is in a separate location on Windows).

DNS would be a service offered by something else (e.g. a BIND server, TinyDNS, Windows Domain Controller). NIS is less common but still around and would be a serivce offered by an NIS (or NIS+) server. /etc/hosts is local to the server that did the ping.

You can type "host <hostname>" or "nslookup <hostname>" to see if it is in DNS. You can type "grep <hostname> /etc/hosts" to see if it is in the local hosts file. Note that you might want to do the above tests with the IP rather than the name to see what name comes back on revers lookup.

On UNIX/Linux the order of what to search is defined in /etc/nsswitch.conf on the line that begins "hosts:"
Examples:

hosts: db files nisplus nis dns # Searches a datafile first, then /etc/hosts then NIS+ then NIS then DNS

hosts: files dns # Searches /etc/hosts first then DNS.

Note that "host" and "nslookup" on most systems will NOT resolve from /etc/hosts - ping will.
 
1 members found this post helpful.
Old 04-29-2014, 02:28 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,561

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
To expand on what MensaWater said, a computer's hostname is what it calls itself. It has absolutely no bearing on what other computers call it. If you want another computer to be able to call it by some special name, then you either need to tell that computer what IP you want mapped to the name, or if it's using a local DNS server to resolve names, you need to tell the DNS server what IP you want mapped to the name.
 
Old 04-29-2014, 03:25 PM   #4
haitaoqiu
LQ Newbie
 
Registered: Apr 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MensaWater View Post
I assume you did your ping from a server outside the server you renamed?

Whatever server you did the ping from is looking for the hostname you gave it and would typically get that from DNS, NIS or /etc/hosts (on UNIX/Linux - hosts file is in a separate location on Windows).

DNS would be a service offered by something else (e.g. a BIND server, TinyDNS, Windows Domain Controller). NIS is less common but still around and would be a serivce offered by an NIS (or NIS+) server. /etc/hosts is local to the server that did the ping.

You can type "host <hostname>" or "nslookup <hostname>" to see if it is in DNS. You can type "grep <hostname> /etc/hosts" to see if it is in the local hosts file. Note that you might want to do the above tests with the IP rather than the name to see what name comes back on revers lookup.

On UNIX/Linux the order of what to search is defined in /etc/nsswitch.conf on the line that begins "hosts:"
Examples:

hosts: db files nisplus nis dns # Searches a datafile first, then /etc/hosts then NIS+ then NIS then DNS

hosts: files dns # Searches /etc/hosts first then DNS.

Note that "host" and "nslookup" on most systems will NOT resolve from /etc/hosts - ping will.
Thanks! I was pinging it from the same host. But I misspelled the hostname.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 08:09 PM
getting errors related to hostname -- security problem? ok to change hostname? sneakyimp Linux - Server 2 11-18-2012 06:25 PM
Hostname change Ammad Linux - General 5 05-04-2010 08:54 AM
after hostname change, syslogd still output previous hostname to messages file tiger2000 Linux - General 3 07-22-2009 10:36 PM
How to change the hostname? kbklinux Linux - Networking 3 02-13-2009 03:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:34 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration