Find the answer to your Linux question:
Results 1 to 5 of 5

Thread: /etc/hosts

Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1



    i'd like to know how to configure the /etc/hosts file for a server with 2 nics, 1 on LAN and 1 on WAN.

    from what i understand it should look like this : localhost localhost.localdomain.local lanserver lanserver.localdomain.local

    is this the right way ?

    i know it's very important to configure this correctly as many services depend on it.

    Thx a lot for your answers

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Nottingham, England
    It all depends on what's in your resolv.conf file. If it says 'hosts' first, then yes it's quite important. Remember that this file is really there to allow quick, local name resolution without having to go talk to the DNS system. If DNS is working correctly, then any names it supplies don't need to be repeated in this file unless you have need to talk to them frequently.

    For security purposes, you probably want to list in here any machines that your essential services use, perhaps machines where backups are run or where data is backed up to - then your services cannot be compromised by someone hijacking the DNS system.

    Apart from that, the layout you've got here is fine.
    Last edited by Roxoff; 11-14-2011 at 01:41 PM.
    Linux user #126863 - see

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    In general I would have localhost defined in there, and nothing else.
    Further DNS configuration should be done via a real DNServer,
    because you want to have that information/configuration in a central place and not scattered (and probably inconsistent) over many.

    There are two exceptions:
    1) A DNServer like dnsmasq, which directly reads from /etc/hosts to serve that info
    2) If you intentionally insert hosts in /etc/hosts to avoid dns lookups for performance reasons.
    Note, that this needs some planning and tight control over all machines, with a system management tool like puppet or cfengine.

    In your case, I would advise to use a DNServer
    You must always face the curtain with a bow.

  4. $spacer_open
  5. #4

    What if I just wanted to limit access to a site on my child's Computer


    I hear what your saying I do make edit to the host file to block or redirect some site. At least until she finds out what I am doing

  6. #5
    @jpro6363: The hosts file is a cumbersome method of implementing a content/parental filter. Have a search for "parental controls linux" or something along those lines.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts