Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Networking > what's the Mac equivalent of the "hosts" file in Windows?

what's the Mac equivalent of the "hosts" file in Windows?
Thread Tools
chasg
Grizzled Veteran
Join Date: Mar 2000
Location: London
Status: Offline
Reply With Quote
Aug 30, 2002, 02:29 PM
 
Hi All,

I've received some advice from some well meaning gurus in another forum that will solve a problem of mine, but it requires me to edit my "hosts" file, in Windows. They don't know I'm running Macs (and I'd prefer to keep it that way).

The problem: I'm running a LAN behind a firewall, have just registered a domain name pointing at the router (which forwards http requests to the webserver which is also behind the firewall on the LAN) and want to be able to enter my domain name in my web browsers/email clients/etc instead of having to enter the internal LAN IP address (which I have to do now).

Problem: this isn't working (firewall probs), and my guru friends have pointed out that I can remap requests to this domain name by adding a line to my "hosts" file that will point to the internal server on the LAN.

So, what's the equivalent of the "hosts" file on the Mac? (one machine is running OSX 10.15, the other OS9.2.2). Help?

Chas
     
tooki
Admin Emeritus
Join Date: Oct 1999
Location: Zurich, Switzerland
Status: Offline
Reply With Quote
Aug 31, 2002, 12:29 AM
 
I don't know for OS X, off the top of my head, but in Mac OS 9, you can create a standard UNIX-format hosts file and save it somewhere on your hard drive. Then open the TCP/IP control panel, set it to Advanced user mode, after which a "Select Hosts File..." button will appear. Click it and choose your hosts file. Voila!

tooki
     
dobby
Fresh-Faced Recruit
Join Date: Aug 2002
Location: here and there
Status: Offline
Reply With Quote
Aug 31, 2002, 08:36 AM
 
Just edit /etc/hosts using an admin user.
This problably won't help though as your name resolution is done through netinfo.
You need to add the hosts file to you netinfo db.
If your hosts file is in the format
xxx.xxx.xxx.xxx some_machine_name
Then you can login as root (not admin but root)
$ niload hosts / < your_hosts_file
You have now added you hosts file to the netinfo db.
you can use things like nicl to look around it.
You can take a backup by copying /var/db/netinfo/*.nidb to another dir.

Hope this has helped.

Dobby.
     
chasg  (op)
Grizzled Veteran
Join Date: Mar 2000
Location: London
Status: Offline
Reply With Quote
Sep 2, 2002, 05:32 PM
 
dobby and tooki,

just the replies I was looking for guys, thanks! How'd you know I was running some machines on 9 and some on X?

btw tooki, I've wondered what that "select hosts" button was for _ages_, mystery now solved!

Can always trust the MacNN community to come through :-)

Chas
     
yuriwho
Dedicated MacNNer
Join Date: Oct 2000
Location: WI, USA
Status: Offline
Reply With Quote
Sep 3, 2002, 04:05 AM
 
No need to load them into netinfo in 10.2. As I understand it, lookupd will now search for your hosts files before searching netinfo and other data sources. It's BSD-like now, just edit your hosts files and they will function properly.

Y

Originally posted by dobby:
Just edit /etc/hosts using an admin user.
This problably won't help though as your name resolution is done through netinfo.
You need to add the hosts file to you netinfo db....(snip)

Dobby.
     
Gene Jockey
Mac Elite
Join Date: Mar 2001
Location: Houston, TX
Status: Offline
Reply With Quote
Sep 3, 2002, 02:08 PM
 
Originally posted by yuriwho:
No need to load them into netinfo in 10.2. As I understand it, lookupd will now search for your hosts files before searching netinfo and other data sources. It's BSD-like now, just edit your hosts files and they will function properly.

Y

Only if you run /Utilities/Directory Access and enable BSD Configuration Files. Then /etc/hosts is consulted. Solved some problems for my LAN...

--Josh
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:38 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,