Fedora Linux Support Community & Resources Center
  #1  
Old 10th December 2005, 08:19 PM
tgrier Offline
Registered User
 
Join Date: Jan 2005
Posts: 101
Host Names

How do I change the host names for my computers?

I will have 4 machines runningFC4.
I am not running a Web server oranything. All 4 connect to a NETGEAR router that is connected to a cable modem for internet.

When I open a terminal ..on each machine ..
it is <username>@localhost~
tgrier@localhost~

Should each computer be "named" something?
How do I change that?

Thank you.
trg
  #2  
Old 10th December 2005, 08:28 PM
jim's Avatar
jim Offline
Retired Community Manager & Avid Drinker Of Suds
 
Join Date: Feb 2005
Location: Rochester NY
Age: 38
Posts: 4,176
you need to edit the /etc/hosts file
Quote:
[jalawre@Home ~]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 home localhost.localdomain localhost
whats marked in the bold is the host name

EDIT
furthermore to edit this file

su (root)
gedit /etc/hosts ( for gedit text editor)
or

vi /etc/hosts ( using vi )

add the host name you want after the 127.0.0.1

so for example i want to name my PC windowsSucks
127.0.0.1 windowsSucks localhost.localdomain localhost

save the changes and reboot
__________________
Registered Linux User: #376813
Western NY
My linux site
Smolt Profile

please remember to say if you problem was solved

Did you get your id10t award today?

Last edited by fedorajim; 10th December 2005 at 08:32 PM.
  #3  
Old 11th December 2005, 12:15 AM
tgrier Offline
Registered User
 
Join Date: Jan 2005
Posts: 101
Good answer.. and made me laugh.. thanks ...
trg
  #4  
Old 11th December 2005, 12:28 AM
Zigzagcom Offline
Registered User
 
Join Date: Feb 2005
Location: CALIFORNIA, yeah
Age: 86
Posts: 1,657
That is the way you do it with DHCP. If you have a static IP set, then add the IP below 127.0.0.1 like so....
127.0.0.1 localhost.localdomain localhost
192.168.1.30 winSuck.lollypop winSuck

http://www.cpqlinux.com/hostname.html
__________________
Ziggy

Last edited by Zigzagcom; 11th December 2005 at 12:32 AM.
  #5  
Old 11th December 2005, 01:36 AM
tgrier Offline
Registered User
 
Join Date: Jan 2005
Posts: 101
Here is my host file

>>>>>>>>>>..
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

>>>>>>>>>>...

It is connected to a netgear router.. and then to a cable modem.
If I want to call my computer... tgrier
how would I change it...
I want to be clear.
thanks
trg
  #6  
Old 11th December 2005, 01:37 AM
nandowong's Avatar
nandowong Offline
Registered User
 
Join Date: Nov 2004
Posts: 511
so if one computer where name winSuck and you wanted to ssh to it would you:

ssh username@winSuck ?

also what does the lollypop represent? is it the network group?
__________________
I dont pitch linux to my friends, I let windows do that for me :D
I like chicken :D
  #7  
Old 11th December 2005, 02:26 AM
Zigzagcom Offline
Registered User
 
Join Date: Feb 2005
Location: CALIFORNIA, yeah
Age: 86
Posts: 1,657
/etc/hosts file....

Remember that you are resolving names to IP addresses.
Your hosts file can act as the poor man's DNS by adding entries of IP address/ name combinations (mappings).
On a small network it might be easier to assign static IP's (like 192.168.1.10, 192.168.1.11 etc) to each machine and then add them to the hosts file. Otherwise, the common SOHO/residential routers
have DNS capabilities, which you could enable.

Let's say you have three machines. You give them the static IP's and host names:
192.168.1.10 tgrier1
192.168.1.11 tgrier2
192.168.1.12 tgrier3

The /etc/hosts file for tgrier1, tgrier2 and tgrier3 would look like this:

Quote:
/etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.1.10 tgrier1
192.168.1.11 tgrier2
192.168.1.12 tgrier3
Now you can reference tgrier2 from tgrier1 by just typing tgrier2 (user@tgrier2, ssh tgrier2, etc. etc.), because the local hosts file points to 192.168.1.11.
There would be no reason to prevent you from creating your own domain, but you couldn't use it on the internet, i.e., machines from the internet would not be able to resolve the IP address unless it was a legal and registered domain name (xxxx.com, xxxx.org, etc), and you have DNS set up.

For example, you can create a domain called grier.inc and then name your machines
tgrier1.grier.inc, tgrier2.grier.inc and tgrier3.grier.inc.

The hosts file would end up like this:

Quote:
/etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.1.10 tgrier1.grier.inc tgrier1 tg1
192.168.1.11 tgrier2.grier.inc tgrier2 tg2
192.168.1.12 tgrier3.grier.inc tgrier3 tg3
Notice tg1, tg2 and tg3. I have created nicknames or aliases for the fully qualified domain names, so now I can reference the machines by them.

What is cool about the hosts file, is when working on web-site development, you often create the pages with links in them, that reference your real domain name, such as www.grier.com.
If you haven't registered the name yet, but need to view them in your browser to make sure it all works as intended, you create an entry in your hosts file that references the www.grier.com domain, i.e., the development site on the machine:

Quote:
/etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.1.10 www.grier.com
Now you can enter the url into your browser without it trying to resolve the name via DNS on the internet i.e., it resolves it via the hosts file. Obviously you would need content and a web server enabled to do this.
If you actually click on the link above (www.grier.com), you would be taken to a site that claims ownership of the domain. Likewise, if you had a web-site already running somewhere (www.grier.com hosted for example), the entry in the hosts file would conflict, if your intent was to resolve the real site instead of your development site on the local machine. You would then have to remove the entry or comment it by placing a hash/pound character (#) in front of the line.
__________________
Ziggy

Last edited by Zigzagcom; 11th December 2005 at 02:59 AM.
  #8  
Old 11th December 2005, 03:16 AM
tgrier Offline
Registered User
 
Join Date: Jan 2005
Posts: 101
Thank you for all the info. It is awesome.

So ARE you saying .. I should set up static IPs for my computers ... and turn off the DNS feature of my router? .. .is that that "best" way to go?
  #9  
Old 11th December 2005, 03:27 AM
Zigzagcom Offline
Registered User
 
Join Date: Feb 2005
Location: CALIFORNIA, yeah
Age: 86
Posts: 1,657
Not neccessarily. If you can make entries via the router, by all means use it if you like. You would just have to play with the various host names. However, if the router looses the configuration, you'd need to reconfigure it. In /etc/host it's there for good, unless you change it.
You don't have to drop DNS in the router, just because you use static IP's. Just mess around with it,
it's the best way to learn...break it, fix it, break it, fix it. Write down the settings that work, then play.
There are many ways to achieve similar results, so you just need to understand how, and then settle on what you prefer.

Go back to the link I posted in post#4. You'll see info on the /etc/HOSTNAME file.
Check out the info on /etc/sysconfig/network. Also take a peek at /etc/resolv.conf
Those are all files that tie into networking, DNS, hostnames etc. It can become complex at first, but as you grow more familiar with certain networking issues, they all start making sense.
Look at the command ifconfig -a in a terminal. Check out ifconfig -h for help. Just take your time.
__________________
Ziggy

Last edited by Zigzagcom; 11th December 2005 at 03:45 AM.
  #10  
Old 11th December 2005, 03:43 AM
tgrier Offline
Registered User
 
Join Date: Jan 2005
Posts: 101
Rock on.
Will do... I will work on breaking it tonight.
and then fix it in the morning...

I understand what you are saying .... that is how I have learned a great deal so far....
however.. I needed a little direction on this issue before ... breaking out on my own..
Thank you again.
trg
  #11  
Old 11th December 2005, 03:46 AM
Zigzagcom Offline
Registered User
 
Join Date: Feb 2005
Location: CALIFORNIA, yeah
Age: 86
Posts: 1,657
Way to go...
__________________
Ziggy
  #12  
Old 11th December 2005, 03:55 AM
nandowong's Avatar
nandowong Offline
Registered User
 
Join Date: Nov 2004
Posts: 511
thanks Zigzagcom you the man
__________________
I dont pitch linux to my friends, I let windows do that for me :D
I like chicken :D
  #13  
Old 11th December 2005, 04:29 AM
smfinley's Avatar
smfinley Offline
Retired Community Manager
 
Join Date: Jul 2004
Posts: 1,335
In addition you should edit your /etc/sysconfig/network file and replace "localhost.localdomain" with your fully qualified domain name if you are running a web server, ftp server, etc. on one of your machines. If so be sure to open/forward the appropriate ports in iptables and in your router's firewall. See the web server section at Fedora Core Installation Notes, this, this, and this.
__________________
Stanton Finley
stanton-finley.net
  #14  
Old 11th December 2005, 04:37 AM
Zigzagcom Offline
Registered User
 
Join Date: Feb 2005
Location: CALIFORNIA, yeah
Age: 86
Posts: 1,657
Thanks Stanton, for pointing it out. Kinda rounds this thread off nicely.
__________________
Ziggy
  #15  
Old 13th December 2005, 04:26 PM
LarryJ's Avatar
LarryJ Offline
Registered User
 
Join Date: Nov 2005
Location: W. Montana, USA
Posts: 103
Access to files

Apparently, the file /etc/resolv.conf can be edited from the Gnome Desktop by Desktop, SystemSettings, Network then click on the DNS tab.

Similarly (I think!) the file /etc/hosts can be edited from Desktop, SystemSettings, Network then click on the Hosts tab.

I say I think because I find the same information via desktop Network as I do in the files except that the line
127.0.0.1 localhost.localdomain localhost
is missing from the desktop gui version. If you click with New(+) and try to enter the line
127.0.0.1 localhost.localdomain localhost
the localhost line still does not show up in the Network Configuration, Hosts window!

Also if you edit the /etc/hosts file from Desktop, System Settings, Network Hosts tab, and click save, you over write the old version of your /etc/hosts file. I find it curious that if you use the gui to edit /etc/hosts the comment below is deleted:
# Do not remove the following line, or various programs
# that require network functionality will fail.

Someday, if I live long enough, I hope to be able to write a better version of the Network Config Hosts tab/window. I would show the line for localhost and if the user tried to delete it, pop up a window saying deletion of this line is forbidden because "Various program that require nework functionality will fail" if this line is deleted.


I'm beginning to appreciate why I should avoid the M$ style gui configuration editors.
gedit /etc/hosts works great and allows me to write comments to myself.

Last edited by LarryJ; 13th December 2005 at 04:36 PM.
Closed Thread

Tags
host, names

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Local host names without domain using Bind onlyteo Servers & Networking 4 10th May 2009 10:25 PM
Help!! Resolving Host Names nicwillemse Servers & Networking 6 14th August 2007 05:35 AM
Host Names? tardis_junkie Servers & Networking 2 19th February 2006 11:06 PM
SAMBA problem (host names?) draget Servers & Networking 4 18th August 2005 08:55 AM


Current GMT-time: 07:48 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat