Find the answer to your Linux question:
Results 1 to 5 of 5
Hi 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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2011
    Posts
    1

    /etc/hosts


    Hi

    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 :

    127.0.0.1 localhost localhost.localdomain.local
    192.168.0.1 lanserver lanserver.localdomain.local
    123.123.123.123 publicdomain.net

    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
    Location
    Nottingham, England
    Posts
    3,807
    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 http://linuxcounter.net/

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,221
    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. #4
    Just Joined!
    Join Date
    Apr 2011
    Posts
    4

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

    Irithori

    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

  5. #5
    Guest
    Join Date
    Feb 2005
    Posts
    312
    @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
  •