LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-31-2003, 03:20 PM   #1
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
/etc/hosts File


Big question here. I own the domain name www.myspecificdomainname.com. In my /etc/hosts file I have:

69.69.65.65 www.myspecificdomainname.com
127.0.0.1 localhost

I don't even know if this is right but my webserver works. Anyway, could I put in a line like:

69.69.65.65 ssh.myspecificdomainname.com

and then people could ssh into ssh.myspecificdomainname.com

I see people who have machine names like "the_matrix" and "lin-serv". When I boot up the GUI logon says "Welcome to myspecificdomainname.com" Can I change my computers name.

Yes I know this is extremly NOOBISH but thats why I put it here. I missed this part of Linux class.
 
Old 01-31-2003, 03:56 PM   #2
ringo
LQ Newbie
 
Registered: Jan 2003
Posts: 15

Rep: Reputation: 0
I believe the /etc/hosts file is for you own local machine only.

I don't think it involves any of the outside world.

I use it for DNS'ing local ips.
Lets say you have a computer beside you on the LAN.
It's IP is 192.168.1.3

You can put:
192.168.1.3 computerbesideme
...in your hosts file.

then, you can ssh/ftp/ping/telnet computerbesideme

and it will use 192.168.1.3

Ringo..........
 
Old 01-31-2003, 03:56 PM   #3
rockdw
Member
 
Registered: Nov 2002
Location: Chicago, IL
Distribution: Rasbian, Debian, Gentoo, RHEL
Posts: 63

Rep: Reputation: 15
The actual hostname of your box should be some kind of name, for example let's assume it is anubis. Then the FQDN would be:
anubis.myspecificdomainname.com
and the hostname would be:
anubis

Your /etc/hosts should have:
69.69.65.65 anubis.myspecificdomainname.com anubis
where the ip address is available on the outside.
www.myspecificdomainname.com should be an alias to
myspecificdomainname.com which should be handled by your specific nameserver.

As for ssh-ing to the box, the only requirement is that you have the ssh port 22 enabled. Then all you need to do is ssh to ANY name that resolves to your address. you can even ssh directly to the ip address if you want to.
 
Old 01-31-2003, 04:13 PM   #4
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Original Poster
Rep: Reputation: 57
Okay so here is my situation. I purchased the address www.mydomainname.com from domainmonger.com. I have it configured there to resolve www.mydomainname.com to 68.69.65.65.

Are you saying that I could change my /etc/hosts file to look like this:

68.69.65.65 anubis.mydomainname.com anubis

no 68.69.65.65 localhost right? If I change this nothing will happen to www.mydomainname.com right?

 
Old 01-31-2003, 05:06 PM   #5
Wolven
Member
 
Registered: Jan 2003
Posts: 195

Rep: Reputation: 30
You would still want

127.0.0.1 localhost

to be in there.

Simply put, the /etc/hosts file is so YOUR machine will override the DNS settings of the internet. (VERY simply put, and somewhat erroneous, but works in the context of this situation.)


What exactly is it you are trying to accomplish with this?

The DNS server that is managing mydomainname.com will handle all of the resolving for the rest of the world.
 
Old 01-31-2003, 07:17 PM   #6
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Just to confuse issues more.... I have a FQDN that resolves to a DHCP IP address, using a free service on some DNS...

What do I put in /etc/hosts for my IP?
 
Old 01-31-2003, 09:05 PM   #7
ringo
LQ Newbie
 
Registered: Jan 2003
Posts: 15

Rep: Reputation: 0
if your FQDN is already DNS'd on a DNS server, you don't need to put anything in the /etc/hosts file.

that file is only for DNS'ing things on your local computer only.

It is normally not used.

Ringo....
 
Old 02-01-2003, 01:04 AM   #8
moses
Senior Member
 
Registered: Sep 2002
Location: Arizona, US, Earth
Distribution: Slackware, (Non-Linux: Solaris 7,8,9; OSX; BeOS)
Posts: 1,152

Rep: Reputation: 48
The /etc/hosts file is basically so that your machine doesn't have
to look for a DNS server for the machine names that are in the
hosts file. For example, if I knew that Crashed_Again's IP
address was 68.69.65.65 and I didn't want to do name resolution
every time I connect to that machine, I could put a line in my
/etc/hosts file like so:
68.69.65.65 crash crashed_again twww.crashspecificdomainname.com
Or what ever other alia I wanted for it.
My /etc/hosts file contains all the hostnames from my work so
that when I need to connect to work I can use a short alias for
those machines, and it doesn't have to go through my ISP's slow
DNS server, it just connects to a specific IP address.
The /etc/hosts file is almost completely useless for connecting to
the machine it exists on. . . Use or $HOSTNAME localhost.
 
  


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
hosts file? milesstandish Red Hat 2 11-02-2004 11:57 PM
PB with /etc/hosts file(s) ptreves Linux - Networking 0 09-10-2004 07:39 PM
does the /etc/hosts file work same as the M$ hosts file? Lleb_KCir Linux - Software 6 04-03-2004 05:33 PM
/etc/hosts file plexi100 Linux - Newbie 4 10-16-2003 06:03 PM
Hosts.allow file skopje909 Linux - Security 3 11-16-2001 10:49 AM


All times are GMT -5. The time now is 11:55 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