Two Different Formats for hosts File?

Discussion in 'Linux Networking' started by W. Watson, Dec 6, 2004.

  1. W. Watson

    W. Watson Guest

    I can find two descriptions on the web for the hosts file that appear to be
    different. Here's one:

    #
    # Hosts file for Virtual Brewery/Virtual Winery
    #
    # IP local fully qualified domain name
    #
    127.0.0.1 localhost
    #
    191.72.1.1 vlager vlager.vbrew.com
    191.72.1.1 vlager-if1

    and another:

    # For loopbacking.
    127.0.0.1 localhost
    #
    129.6.15.28 time-a.nist.gov synctime
    44.56.26.10 ka1fsb.ampr.org ka1fsb
    44.56.26.11 ka1fsb-3.ampr.org ka1fsb-3

    Can someone explain this? Is there another file that controls the order?

    My man page for hosts shows: ip-address canonical_hostname aliases

    but gives no explanation of canonical_hostname
    --
    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
    (Formerly Homo habilis, erectus, heidelbergensis and now sapiens)

    "The free market is a great thing--we should try it sometime."
    -- Jim Hightower

    Web Page: <home.earthlink.net/~mtnviews>
     
    W. Watson, Dec 6, 2004
    #1
    1. Advertisements

  2. W. Watson

    Bit Twister Guest

    Think about it a minute, why would you want an aliases longer than the
    canonical_hostname. The canonical_hostname is the Fully Qualified
    Domain Name (FQDN) . Looking at the man page on Mandrakelinux the examples
    should prove it to you.

    EXAMPLE
    127.0.0.1 localhost
    192.168.1.10 foo.mydomain.org foo
    192.168.1.13 bar.mydomain.org bar
    216.234.231.5 master.debian.org master
    205.230.163.103 www.opensource.org
     
    Bit Twister, Dec 6, 2004
    #2
    1. Advertisements

  3. W. Watson

    W. Watson Guest

    So you're saying that if the FQDN appears, then the aliases follow it, and if there
    is no FQDN all names are aliases? Or more likely from the two examples above, both
    aliases and one FQDN can follow the IP, but in any order. I'm a RHL 9 user.

    --
    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet
    (Formerly Homo habilis, erectus, heidelbergensis and now sapiens)

    "The free market is a great thing--we should try it sometime."
    -- Jim Hightower

    Web Page: <home.earthlink.net/~mtnviews>
     
    W. Watson, Dec 6, 2004
    #3
  4. W. Watson

    Bill Unruh Guest

    ]I can find two descriptions on the web for the hosts file that appear to be
    ]different. Here's one:

    ]#
    ]# Hosts file for Virtual Brewery/Virtual Winery
    ]#
    ]# IP local fully qualified domain name
    ]#
    ]127.0.0.1 localhost
    ]#
    ]191.72.1.1 vlager vlager.vbrew.com
    ]191.72.1.1 vlager-if1

    ]and another:

    ]# For loopbacking.
    ]127.0.0.1 localhost
    ]#
    ]129.6.15.28 time-a.nist.gov synctime
    ]44.56.26.10 ka1fsb.ampr.org ka1fsb
    ]44.56.26.11 ka1fsb-3.ampr.org ka1fsb-3

    ]Can someone explain this? Is there another file that controls the order?

    What is there to explain? The first name is the one delivered if hosts is
    queried for the name .
     
    Bill Unruh, Dec 6, 2004
    #4
  5. W. Watson

    Bill Unruh Guest

    ]So you're saying that if the FQDN appears, then the aliases follow it, and if there
    ]is no FQDN all names are aliases? Or more likely from the two examples above, both
    ]aliases and one FQDN can follow the IP, but in any order. I'm a RHL 9 user.

    Yes. any order. If the host file is queried with a name, the address is
    delivered if that name appears anywhere in the line before a #.
    If the hosts file is queried with an address, then the first name is
    delivered.
     
    Bill Unruh, Dec 6, 2004
    #5
  6. | I can find two descriptions on the web for the hosts file that appear to be
    | different. Here's one:
    |
    | #
    | # Hosts file for Virtual Brewery/Virtual Winery
    | #
    | # IP local fully qualified domain name
    | #
    | 127.0.0.1 localhost
    | #
    | 191.72.1.1 vlager vlager.vbrew.com
    | 191.72.1.1 vlager-if1
    |
    | and another:
    |
    | # For loopbacking.
    | 127.0.0.1 localhost
    | #
    | 129.6.15.28 time-a.nist.gov synctime
    | 44.56.26.10 ka1fsb.ampr.org ka1fsb
    | 44.56.26.11 ka1fsb-3.ampr.org ka1fsb-3
    |
    | Can someone explain this? Is there another file that controls the order?
    |
    | My man page for hosts shows: ip-address canonical_hostname aliases
    |
    | but gives no explanation of canonical_hostname


    What you actually have is:

    ip-address list-of-host-names

    When you do a lookup on a name, it will match on any name in the list,
    and return the IP address. This search will only return an *exact* match
    for a full name.

    When you do a lookup on an IP address it
    will only return the first name from the list.

    Most applications work best when the IP to name request returns the
    fully-qualified domain name (ie, the full name with all the domain
    information). The remaining names in the list are available for shortcut
    and abreviations so you don't have to type the full name every time.
     
    Paul Colquhoun, Dec 6, 2004
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.