Using NetInfo like a hosts file

paulsomm

yada yada yada ya
I've been searching the net now since installing OSX Final b/c for a way to use my hosts file in my /etc folder like I do under Linux for developing websites (i.e. in the hosts file I create "127.0.0.1 somesite.me" and then use apache and http headers so that somesite.me in a browser returns a locally created website)

Looking in the /etc/hosts file you are told that the file isn't consulted unless you change your lookupd configuration. Lookupd is handled by NetInfo. And hence my problem: I had no idea how to change the order in NetInfo to look at the flat file /etc/hosts before going to DNS

After realizing I was overcomplicating things I found a better way to achieve the exact same result in a way I actually like better than editing a /etc/hosts file: using NetInfo!

I went into the "Utilities" folder in "Applications" and double-clicked the "Netinfo Manager", then clicked the lock and provided my password. The next thing I did was I noticed that / Machines (clicking the "/" in the left pane then the "Machines" in the middle pane) showed me the same listing of 127.0.0.1 and localhost as the hosts file did. So, I clicked in the right pane the entry "Localhost" and then clicked the double-folder icon to duplicate this entry. I duplicated the entry as many times as I needed, then double-clicked the value "localhost" in the bottom window for each duplicated entry and changed it to what I wanted, i.e. "site1.me"

This has the same effect as having "127.0.0.1 site1.me" in the /etc/hosts file under linux.

Just thought I'd pass this along.
 
It's nice to hear someone actually using netinfo in a happy way. Most of the time I appreciate it as a concept, and then I get angry because I can't actually do what I intend to. There's a serious lack of netinfo documentation, all input is helpful.
 
I've tried this too by putting in new entries in the NetInfo machines directory. But... It Don't Work!

Is a reboot required? If so, why...? And also if so, can I get around this with an ifconfig down/up, or inetd restart... or... anything?

I tried "lookupd -flushcache"... Restarted all NI domains on my machine (I think there's just the one)... and a couple of other things... Nada!

Any help is appreciated.

-jab
 
I tried this trick, and it worked as expected. Immediately. Here's the trick again in different words:

<ol>
<li>Open NetInfo (in the Applications->Utilities folder).</li>
<li>"Unlock" the window by clicking on the lock icon in the lower left corner (you must be Admin, etc).</li>
<li>In the middle pane, click on <em>machines</em>.</li>
<li>You should see something like this in the right-hand pane:
<ul>
<li>-DHCP-</li>
<li>broadcasthost</li>
<li>localhost</li>
</ul>
</li>
<li>Click on <em>localhost</em> and then click the double folder icon in the toolbar area. Confirm the duplication.</li>
<li>Select <em>localhost copy</em></li>
<li>Below, you should see a table with three values:
<table border="1" cellpadding="5">
<tr><td>ip_address</td><td>127.0.0.1</td></tr>
<tr><td>name</td><td>localhost copy</td></tr>
<tr><td>serves</td><td>./local</td></tr>
</table>
</li>
<li>Edit the <em>localhost copy</em> to be whatever other name you want your computer to have, i.e., <strong>hotstuff</strong>.</li>
<li>Save and confirm all changes.</li>
</ul>
That's it. You should immediately be able to refer to your computer by its new name(s).

-Rob
 
Originally posted by theed
It's nice to hear someone actually using netinfo in a happy way. Most of the time I appreciate it as a concept, and then I get angry because I can't actually do what I intend to. There's a serious lack of netinfo documentation, all input is helpful.

...serious LACK of DOCUMENTATION:

Who´s going to turn a light on Netinfo ???

It´s a shame that apple didn´t put any docs on the CDs ....

 
Maybe the guys who makes all the cool books with the pretty animal shapes will take on NetInfo. I'm gonna go shoot them an e-mail on specifically that.

Maybe will actually say SOMETHING when they erlease their Server package in a couple of months. Of course, all things future tense are speculative / rumor.
 
Does "man netinfo" in a shell provides you with some useful info?
I have not yet looked at it, but it looks promising. My oly worry is that it is dated from 1990...

Robin
 
man netinfo gets you programming API's. niutil is the command line interface that you want to use if anything. It uses syntax like create, destroy, appendprop. The utility is rather simple itself, but the structure and responsibilities of netinfo are labyrinthine.

I'm far more interested in getting a good GUI util so that I can visualize what the directory structure really looks like, and so I can more easily pop into and out of all of the stuff. But primarily, what's it doing, what is it responsible for, what are the possible attributes I could be adding to a directory to make things go.

This stuff isn't going to come from man, it's only going to come from documentation about the OS and its implementation. I've used other people's commands doing hacks and tweaks for over 2 years now. I still just don't have a good feel for what it is that netinfo is really responsible for, where, when, and what I can do about it.

How do I create another netinfo domain? What properties does it need to have to be legitimate? Can I have a local domain on my laptop but trust another domain when I plug into a network? Big questions. Little documentation.

Sorry if I ramble, I'm a little bitter. :)
 
Originally posted by theed
I'm far more interested in getting a good GUI util so that I can visualize what the directory structure really looks like

There already is a good netinfo gui. It comes with OSX in the Applications/Utilities folder and it's called Netinfo Manager.

Shows the whole structure and does everything with a click of the button. Only thing it doesn't have is a decent help file with info on netinfo.
 
although I agree with you that there is a netinfo app that GUI displays the tree, it doesn't at all help you with avilable options, when filling in a value that has three usable choices, it'd be really nice to have a pop-up menu so that I knew what the choices were.

It'd also help if the directory structure had some sort of real meaning, comments on what things did. The apache.conf file is more helpful than the netinfo app. It also doesn't at all help me with my questions of creating a new domain.

Just because it's in a window doesn't make it a usable GUI. A GUI app allows you to understand the choices by presenting them to you in some manner. Netinfo is a Graphical app like textedit is a graphical web page layout tool.

Forgive my bitterness, my bank screwed me over, I might be failing a class, and a helf dozen other things topped off by the fact that I don't have a woman to help feel better about my currently crappy day. Please don't take my ranting personally, at least not today. I'm just wandering the posts and doing geeky things to cheer myself up because I'm in a real "People Suck" kind of mood. I'd rather think about hardware right now.
 
'man netinfo' only shows the API, but try 'man 5 netinfo' for section 5, which lists quite a bit of info on the NetInfo database as a whole.
 
I think the man 5 netinfo page has information about making the netinfo db only readable by certain people.

-Rob
 
That's only machines on the network, not users on localhost.

There is no way to prevent people on the local machine from reading the NetInfo database
 
I agree with Strobe, this is a long standing issue with netinfo, and as algorithms come up that seem to make md5 encryption weak, being able to read everyone's stuff is pretty sketchy.

On my production server that isn't physically accessible for anyone to deal with it locally, I changed the permissions on niutil so that not everyone could read everything. I see no way to impose that kind of restriction against local users.

Some of the stuff netinfo does replaces DNS and the like, and that should be public. It has too much other stuff though, and it would be nice if it were segmented. Maybe creating multiple domains with different restrictions, so localhost stuff would remain private. Still. Something more is needed. I like the netinfo abstraction, and lookupd's caching, and keeping all of this stuff together instead of scattered throughout /etc and /var - but it would seem to be a potential weak link in an otherwise industrially secure system. I hope they update it.
 
Well it is part of Darwin. If we wanted to we could implement such permissions ourselves.

If I ever want to use my OS X machine for shell accounts I would want this
 
I have entries for various hosts in my netinfo database.
I'd like the OS to try resolving hostnames in netinfo
first, rather than going to DNS. Right now,
it seems like the OS is still going to DNS
first for these hostnames.

This would be handy when reading Slashdot,
for example, because you can redirect all
the goatsex links and all that
other garbage to 127.0.0.1
 
Originally posted by marmoset
I have entries for various hosts in my netinfo database.
I'd like the OS to try resolving hostnames in netinfo
first, rather than going to DNS. Right now,
it seems like the OS is still going to DNS
first for these hostnames.

This would be handy when reading Slashdot,
for example, because you can redirect all
the goatsex links and all that
other garbage to 127.0.0.1

Actually, this is kind of a silly way to use NetInfo. You'd be better served with something like JunkBusters from http://internet.junkbuster.com Have it running, like I do, in as a daemon and have your browser set to use it as a proxy and you can filter out any advertisment or such from websites.
 
it does seem to be doing this, and it makes me angry as well. I have local machines in my NAT subnet, and I have them named on each machine so that I can go to them without having to ype in the IP. (I've since reassigned my NAT only DNS server to another task) It seems to time out, before resolving using the manually entered stuff. I know that this is a function of NetInfo, and it used to be the default order of march. I don't know why it's doing what it's doing, and I don't remember how to change it.
There doesn't seem to be anything obvious in the NetInfo configuration. If I figure it out, I'll post.
 
Back
Top