You are not logged in.

#1 2010-01-14 14:14:55

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Can I See Your /etc/hosts File?

I was a little confused about the /etc/hosts file on Arch Linux. I know how to set my Arch 'hostname' in rc.conf file however I get confused after reading this.

Until now I have been doing:

127.0.0.1      mypc.mydomain.tld     mypc

So that has been working fine for me because when I run the 'hostname -f' command, I get my expected FQDN. I am guessing based on the Wiki, my example is wrong, no?


./

Offline

#2 2010-01-14 14:17:26

Dheart
Member
From: Sofia, Bulgaria
Registered: 2006-10-26
Posts: 956

Re: Can I See Your /etc/hosts File?

[dheart@lightbringer ~]$ cat /etc/hosts
#
# /etc/hosts: static lookup table for host names
#

#<ip-address>    <hostname.domain.org>    <hostname>
127.0.0.1        lightbringer.localdomain    lightbringer

# End of file

There're many ways to set up a working /etc/hosts so no worries there, your's just fine


My victim you are meant to be
No, you cannot hide nor flee
You know what I'm looking for
Pleasure your torture, I will endure...

Offline

#3 2010-01-14 14:19:10

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Can I See Your /etc/hosts File?

You _must_ have 'localhost' in there as well - the following would suffice

127.0.0.1  localhost  mypc

Offline

#4 2010-01-14 14:42:45

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Can I See Your /etc/hosts File?

perbh wrote:

You _must_ have 'localhost' in there as well - the following would suffice

127.0.0.1  localhost  mypc

If that is the case according to your example, what is your ouput if you run 'hostname -f'?

How does Arch know what your domain is?


./

Offline

#5 2010-01-14 16:48:37

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Can I See Your /etc/hosts File?

What do you need a domain for?
I have never, ever, never needed a domain other than possibly in /etc/resolv.conf (in days of yore)
- but ...
I do use /etc/hosts as all my important machines have a static ip-addy - even when I use my laptop (which uses dhcp) - I never have to rely on dns to find any of my local machines, they are all there in my hostfile.

Many, many apps will use 'localhost' for their internal communication - so you must have localhost defined (eg. cups - http://localhost:631, swat - http://localhost:901). Well, you don't _have_ to - per ce - but it will save you from using the network adapter ...

Offline

#6 2010-01-14 16:53:11

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Can I See Your /etc/hosts File?

If your Arch server is a mail server or any important server for that matter...applications like Postfix and MySQL require you have a domain for the FQDN.


./

Offline

#7 2010-01-14 17:03:37

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Can I See Your /etc/hosts File?

Guilty as charged! I have just never had the need to use them as such - and I guess most users are 'in the same boat' (of course - I'm probably dead wrong in saying 'most' ... *lol*)

Mind you - there is no penalty for having more than 2 entries on each line in your hostfile - only ... 'localhost' _should_ be one of them eg.
127.0.0.1  mypc.mydomain  mypc  localhost

Last edited by perbh (2010-01-14 17:07:17)

Offline

#8 2010-01-14 17:11:19

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Can I See Your /etc/hosts File?

For right now unless someone can explain the correct syntac, I am using the following for my email server:

127.0.0.1          mail.iamghost.com         mail

This gives me the response I expect...

[root@mail ~]# hostname -f
mail.iamghost.com

Can someone tell me if this is dead wrong?


./

Offline

#9 2010-01-14 17:17:20

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Can I See Your /etc/hosts File?

The following excerpt is from slackware-13.0 (it has been in _all_ SW's that I've ever come across) and is the 'head' of the /etc/hosts file:

#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine.  It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#

# For loopbacking.
127.0.0.1    localhost

As far as _I_ am concerned - if you have a 'server' - it has a static ip-addy - and then you do not use the name/domain on the 'lo' i/f.

Last edited by perbh (2010-01-14 17:20:42)

Offline

#10 2010-01-14 17:22:54

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Can I See Your /etc/hosts File?

I appreciate your response...but there has to be a specific format that is expected to have a FQDN or domain appended to your workstation or server. Regardless if you use DHCP or static IP, your machine should be appended to a specific domain and my question is still confusing to me.


./

Offline

#11 2010-01-14 18:44:01

Meyithi
Member
From: Wirral, UK
Registered: 2009-06-21
Posts: 550
Website

Re: Can I See Your /etc/hosts File?

I too found the hosts file advice on the wiki confusing so went with the Slackware documentation from http://www.slackbook.org/html/network-c … tcpip.html

[meyithi@158NET ~]$ cat /etc/hosts
127.0.0.1           localhost  locahost.localdomain
192.168.1.64        158NET
[meyithi@158NET ~]$ hostname -f
158NET

Haven't had any problems with it as yet.


The mind roams more freely in empty rooms.
dwm - colours - ncmpcpp - system
irc://irc.freenode.net:meyithi

Offline

#12 2010-01-14 20:47:52

Carlwill
Member
From: Orlando, FL
Registered: 2008-10-06
Posts: 560
Website

Re: Can I See Your /etc/hosts File?

Your out put above for hostname and hostname -f are then identical. That is wrong. You have no FQDN. Any servers that run on the network like Email, Samba, MySQL, etc etc etc would fail.

I am getting the feeling many of you simply use your Arch machines on a home network or somewhere that network resources are not on a LAN level. I have several workstations and servers on a enterprise level LAN that need to be on the same domain / network.

Last edited by Carlwill (2010-01-14 20:49:24)


./

Offline

#13 2010-01-14 20:55:03

Meyithi
Member
From: Wirral, UK
Registered: 2009-06-21
Posts: 550
Website

Re: Can I See Your /etc/hosts File?

http://www.linuxquestions.org/questions … up-302189/

Edit/ Yup, I'd have to register my IP with some kind of dynamic DNS service to get a proper FQDN, but I don't need one.

Last edited by Meyithi (2010-01-14 20:56:28)


The mind roams more freely in empty rooms.
dwm - colours - ncmpcpp - system
irc://irc.freenode.net:meyithi

Offline

#14 2010-01-14 21:05:29

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: Can I See Your /etc/hosts File?

Post deleted.

Last edited by Wintervenom (2010-01-14 21:06:13)

Offline

Board footer

Powered by FluxBB