This chapter tells you how the Erlang runtime system is configured for IP communication. It also explains how you may configure it for your own particular needs by means of a configuration file. The information here is mainly intended for users with special configuration needs or problems. There should normally be no need for specific settings for Erlang to function properly on a correctly IP configured platform.
When Erlang starts up it will read the kernel variable
inetrc
which, if defined, should specify the location and
name of a user configuration file. Example:
% erl -kernel inetrc '"./cfg_files/erl_inetrc"'
Note that the usage of a .inetrc
file, which was
supported in earlier Erlang versions, is now obsolete.
A second way to specify the configuration file is to set the
environment variable ERL_INETRC
to the full name of the file. Example (bash):
% export ERL_INETRC=./cfg_files/erl_inetrc
Note that the kernel variable inetrc
overrides this environment variable.
If no user configuration file is specified and Erlang is started in non-distributed or short name distributed mode, Erlang will use default configuration settings and a native lookup method that should work correctly under most circumstances. Erlang will not read any information from system inet configuration files (like /etc/hosts, /etc/resolv.conf, etc) in these modes.
If Erlang is started in long name distributed mode, it needs to
get the domain name from somewhere and will read system inet
configuration files for this information. Any hosts and resolver
information found then is also recorded, but not
used as long as Erlang is configured for native lookups. (The
information becomes useful if the lookup method is changed to
'file'
or 'dns'
, see below).
Native lookup (system calls) is always the default resolver method. This
is true for all platforms except VxWorks and OSE Delta where 'file'
or 'dns'
is used (in that order of priority).
On Windows platforms, Erlang will search the system registry rather than look for configuration files when started in long name distributed mode.
Erlang records the following data in a local database if found in system inet configuration files (or system registry):
This data may also be specified explicitly in the user
configuration file. The configuration file should contain lines
of configuration parameters (each terminated with a full
stop). Some parameters add data to the configuration (e.g. host
and nameserver), others overwrite any previous settings
(e.g. domain and lookup). The user configuration file is always
examined last in the configuration process, making it possible
for the user to override any default values or previously made
settings. Call inet:get_rc()
to view the state of the
inet configuration database.
These are the valid configuration parameters:
{file, Format, File}.
Format = atom()
File = string()
Format
tells the parser how the file should be
interpreted: resolv
(Unix resolv.conf), host_conf_freebsd
(FreeBSD host.conf), host_conf_bsdos
(BSDOS host.conf),
host_conf_linux
(Linux host.conf), nsswitch_conf
(Unix nsswitch.conf) or hosts
(Unix hosts). File
should
specify the name of the file with full path.{registry, Type}.
Type = atom()
win32
is the only valid option.{host, IP, Aliases}.
IP = tuple()
Aliases = [string()]
{domain, Domain}.
Domain = string()
{nameserver, IP [,Port]}.
IP = tuple()
Port = integer()
{alt_nameserver, IP [,Port]}.
IP = tuple()
Port = integer()
{search, Domains}.
Domains = [string()]
{lookup, Methods}.
Methods = [atom()]
native
(use system calls),
file
(use data retrieved from system configuration files and/or
the user configuration file) or dns
(use the Erlang DNS client for
nameserver queries).{cache_size, Size}.
Size = integer()
{cache_refresh, Time}.
Time = integer()
{timeout, Time}.
Time = integer()
{retry, N}.
N = integer()
{inet6, Bool}.
Bool = true | false
{udp, Module}.
Module = atom()
{tcp, Module}.
Module = atom()
clear_hosts.
clear_ns.
clear_search.
Here follows a user configuration example.
Assume a user does not want Erlang to use the native lookup method,
but wants Erlang to read all information necessary from start and use
that for resolving names and addresses. In case lookup fails, Erlang
should request the data from a nameserver (using the Erlang
DNS client). Furthermore, DNS records should never be cached. The user
configuration file (in this example named erl_inetrc
, stored
in directory ./cfg_files
) could then look like this
(Unix):
%% -- ERLANG INET CONFIGURATION FILE -- %% read the hosts file {file, hosts, "/etc/hosts"}. %% add a particular host {host, {134,138,177,105}, ["finwe"]}. %% read nameserver info from here {file, resolv, "/etc/resolv.conf"}. %% disable caching {cache_size, 0}. %% specify lookup method {lookup, [file, dns]}.
And Erlang could, for example, be started like this:
% erl -sname my_node -kernel inetrc '"./cfg_files/erl_inetrc"'