LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-05-2010, 08:42 AM   #1
tiger.woods
Member
 
Registered: Mar 2006
Posts: 122

Rep: Reputation: 15
Networking questions and general confusion...?


I'm really confused on how to properly setup my webserver's /ets/hosts file. This server does not do DNS but should be able to deliver mail messages from the server, notifications, etc. This machine also has 2 NIC's one that is used for the public IP and another for local connections, they are 192.168.2.99 (public) and 192.168.1.99 (local).

I'm really getting confused on the proper use of the domainname, hostname, machinename and aliases, etc...

I was hoping someone could school me a bit on the differences and the uses.

Below is my current /etc/hosts file...

Quote:
127.0.0.1 localhost
192.168.2.99 dns.mydomain.com , dns
::1 ip6-localhost , ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Thanks for any pointers and tips you could give.

Last edited by tiger.woods; 09-05-2010 at 03:13 PM.
 
Old 09-05-2010, 02:10 PM   #2
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
Sorry for the very short suggestion, but:
man hosts
 
Old 09-05-2010, 03:17 PM   #3
tiger.woods
Member
 
Registered: Mar 2006
Posts: 122

Original Poster
Rep: Reputation: 15
Yes, that was very short and not really helpful but thanks for the suggestion.
 
Old 09-05-2010, 05:20 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Host file is to use a name instead of an IP address.

As you can see the first line says localhost. Whenever you put localhost into a place where an IP might be used the system will look first to the host file (unless you use a proxy.pac file) and it will substitute the IP address you have for that name. In this case 127.0.0.1
 
Old 09-05-2010, 06:06 PM   #5
tiger.woods
Member
 
Registered: Mar 2006
Posts: 122

Original Poster
Rep: Reputation: 15
So should every IP be listed in the /etc/hosts file?

When the box is trying to figure out what it's domainname and or hostname is what will it use, the loopback address?

When I do the following:

#hostname
dns

#domainname
(none)

So the box doesn't know its domainname...???
 
Old 09-06-2010, 06:32 AM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Does this help? (Although they do make the mistake of allowing the spellchecker to correct 'resolv.conf' to 'resolve.conf', which always makes you look as if you don't know what you are writing about.)
 
Old 09-06-2010, 09:52 AM   #7
tiger.woods
Member
 
Registered: Mar 2006
Posts: 122

Original Poster
Rep: Reputation: 15
Does "localhost.localdomain" really belong in the /etc/hosts file?

127.0.0.1 your-node-name.your-domain.com localhost.localdomain localhost
XXX.XXX.XXX.XXX node-name

So here's my setup does this make sense?

127.0.0.1 mydomain.com localhost.localdomain localhost
192.168.2.99 dns.mydomain.com , dns


Is it really necessary for me to also list the other 2 internal IP's or will the loopback address take care of any name requests?

Thanks.

Last edited by tiger.woods; 09-06-2010 at 10:04 AM.
 
Old 09-06-2010, 02:45 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Hosts really are two things. One is simply a way to keep people from typing ip addresses. The other use is for security. You could also maybe speed up lookup's for your common 20 or 30 web sites that you visit each day.

You should only put a few in hosts file of your own. Hosts file is what you want to use to avoid using an IP address. It is a convenience rather than a needed item. In fact you tend to forget what you put in a hosts file and then have troubles.

Hosts are for local lan setups usually but can be used to protect your system. See hosts file blocking web pages. I strongly suggest you put in a good hosts file from one of those sites.

Loopback is rather tricky. Some os's don't need a nic card installed. It will loopback through the IP stack as well as ping on some setups.
 
Old 09-06-2010, 02:47 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
The loopback address is for your local machine, not for other computers on the network. You could list other hosts that your server uses, however as you have a dns server on the network, this isn't necessary. /etc/hosts might contain your router's IP address and give it a name for convenience, but you wouldn't include your server's IP address for the NIC device that connects to the router.

At home, I fix the IP/MAC address mappings in my router so that all the hosts always are given the same IP address by the router's DHCP server. That way I can maintain an /etc/hosts file on each host and not worry about one of the IP addresses changing. Servers are usually configured to have static IP addresses. Include your servers in the /etc/hosts file that that computer uses. If your host doesn't use dns to resolve a server's IP address, it won't need to use your dns to resolve the name.
Some people go further and maintain hostname / MAC address mappings in /etc/ethers and have this info loaded by arp when they boot up. ( your system my do this if /etc/ethers exists when you boot ) This can help protect against Cane and Abel type attacks.

Aliases in your /etc/hosts file are for your convenience. It will probably contain just the hostname and not the domain part.

Last edited by jschiwal; 09-06-2010 at 02:54 PM.
 
  


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
General Networking questions..NAT/Router crnchyfrog Linux - Networking 5 11-07-2004 11:44 PM
Linux Wireless Networking Confusion redneon Linux - Wireless Networking 3 01-18-2004 02:39 PM
Few general networking type questions b_usa General 5 03-06-2003 03:41 PM

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

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