Using HOSTS file on OS X...? Need Unix expert!

Discussion in 'Mac Apps and Mac App Store' started by Diomedes, Apr 7, 2005.

  1. Diomedes macrumors 6502

    Joined:
    Oct 5, 2004
    Location:
    San Francisco
    #1
    In my environment, I often have to access servers who are not in the common DNS server. Normally, communication between servers on my subnet and their is no problem, since they have static IP addresses and explicit configurations to allow connectivity. However, workstation access to them is another issue - their host name does not resolve (although the IP address itself returns a ping.)

    On my Windows PC, I just have a HOSTS table that maps the IP address with the host name of the server I am trying to access. However, without my WAN team assigning me a static IP address and creating static routes to those servers, I seemingly can't access them from my Mac (to do an FTP transfer, for example). Is it possible to use a HOSTS file on OS X? I would think with its Unix foundation, the answer is yes, but I haven't found any information on it. Any help would be much appreciated.
     
  2. Jalexster macrumors 6502a

    Joined:
    Jun 8, 2004
    #2
    You can. But I forgot how. Try Apple's support database. It's got a ****load of information.
     
  3. GeeYouEye macrumors 68000

    GeeYouEye

    Joined:
    Dec 9, 2001
    Location:
    State of Denial
    #3
    You can and, sadly, I don't remember how. But here's how not to do it: edit /etc/hosts, something that's atypical for a UNIX. OS X uses /etc/hosts only when booted into single-user mode. I think the file you want might be /etc/hosts.equiv, but I could be wrong.
     
  4. wrc fan macrumors 65816

    wrc fan

    Joined:
    Jan 19, 2003
    Location:
    In a world where LPs are made like pancakes
    #4
    OS X uses the /etc/hosts file as a last resort so editing it is an acceptable way. All you have to do is put the ip address on the left and the name you want to point to that ip address to the right of it. Sometimes if I change an ip address it doesn't get the change till I do a `lookupd -flushcache`, but after that it works fine.
     
  5. jim. macrumors 6502

    Joined:
    Dec 22, 2004
    Location:
    C-ville, VA
    #5
    oaklandbum is right. OSX does use the /etc/hosts file. I don't even think it is a last resort. I define custom IPs in mine for blocking ad sites, and surprisingly I see no ads or popups. By definition most UNIX and NIX systems use the hosts file as the very first resource for lookup information.

    Now for your question... It is easy to edit the hosts file. Using your favorite editor (with root access) simply add on to the end of the file:

    ip address hostname

    So if I want to define www.cnn.com as 1.2.3.4 then I would add:

    1.2.3.4 www.cnn.com

    to my hosts file. It's that easy. Just, whatever you do, do not get rid of the loopback entry: which is typically 127.0.0.1 localhost. I know in other *nix systems doing this will cause general unresponsiveness in most programs as the system tries to figure out what it is called.

    Hope this helps

    Jim
     
  6. cubist macrumors 68020

    Joined:
    Jul 4, 2002
    Location:
    Muncie, Indiana
    #6
    You are supposed to use Applications - Utilities - Netinfo Manager. It's not hard.
     
  7. emw macrumors G4

    emw

    Joined:
    Aug 2, 2004
    #7
    Then perhaps you can shed some light on this thread.

    Doctor Q and I have had some issues with system log errors that are a little confusing.
     
  8. Diomedes thread starter macrumors 6502

    Joined:
    Oct 5, 2004
    Location:
    San Francisco
    #8
    Thanks. I ws just going to use the hosts file from my PC. I guess my questin was how/where do I put it in OS X? And should applications like Transmit automatically recognize it?
     
  9. wrc fan macrumors 65816

    wrc fan

    Joined:
    Jan 19, 2003
    Location:
    In a world where LPs are made like pancakes
    #9
    The host file for you PC I don't believe contains the loopback info in the current on, so I'd suggest just editing /etc/hosts to have the same domains (you can probably just copy and paste). Then all applications will be able to use the names.
     
  10. JDar macrumors 6502a

    JDar

    Joined:
    Dec 7, 2003
    #10

Share This Page