Syntax of .inetrc?

Raimo Niskanen raimo@REDACTED
Fri Oct 17 15:27:28 CEST 2003

It is NOT documented, but frequently used.

It is designed exactly for your purpose - not having root access but 
reluctant sysadmins.

For your problem there are two tricks:
1) Set an environmet variable ERL_INET_ETC_DIR to an alternate /etc
directory e.g /home/nils. Then Erlang will read /etc/hosts, 
/etc/resolv.conf, and (/etc/host.conf or /etc/nsswitc.conf) from that
3) Use an .inetrc like:
{host,{127,0,0,1}, ["localhost","hostalias"]}.

That's right. You can specify hosts in the .inetrc file. It is however 
only read at startup of the node.

Or use a combination. Write the /home/nils/hosts file and set
{lookup,["file","native"]} in .inetrc and that hosts file
will also be read once at startup and preceed the native lookup.

The .inetrc syntax is normal Erlang term syntax. Note the dot at the end 
of every line.

Example lines are, besides the above:

There are more. Read the source starting at 

Inspect the result of your experiments with inet_db:get_rc/0, or 
ets:i(inet_db) and ets:i(inet_hosts) if that does not give enough.

Oh, and the .inetrc file can be put in several locations:
1) the user's home directory.
2) the erlang installation root (with the {erts-VSN lib man ...} dirs)
3) in a directory specified by the Erlang kernel configuration variable
inetrc_dir. And that can be specified when you build your own boot 
script or on the command line with "-kernel inetrc_dir /path/to/dir".

Have fun.

WARNING. This is a mess and we would really like to straighten it up 
some day, so details may change.

/ Raimo Niskanen, Erlang/OTP, Ericsson AB

Anders Fluur LN/EAB wrote:
> In a previous posting there was a reference to .inetrc
> Where is this file documented?
> I'm developing an application, which is to be run on a machine where we 
> do not have root access.
> Is it possible to configure .inetrc so that host lookup uses 
> an arbitrary file like /home/nils/hosts ?
> Best Regards,
> Anders

More information about the erlang-questions mailing list