Difference between revisions of "OpenWRT: OLSR nameservice plugin"

From OnnoWiki
Jump to navigation Jump to search
(New page: Reference: https://github.com/servalproject/olsr/blob/master/lib/nameservice/README_NAMESERVICE --------------------------------------------------------------------- NAMESERVICE PLUGIN F...)
 
Line 2: Line 2:
  
  
---------------------------------------------------------------------
+
==NAMESERVICE PLUGIN FOR OLSRD==
NAMESERVICE PLUGIN FOR OLSRD
 
 
by Bruno Randolf <bruno.randolf@4g-systems.biz>
 
by Bruno Randolf <bruno.randolf@4g-systems.biz>
---------------------------------------------------------------------
+
 
  
 
a simple DNS replacement for OLSR networks
 
a simple DNS replacement for OLSR networks
Line 28: Line 27:
  
  
---------------------------------------------------------------------
 
PLUGIN PARAMETERS (PlParam)
 
---------------------------------------------------------------------
 
 
PlParam "name" "my-name.mesh"
 
the name of this OLSR node (main address).
 
can be specified multiple times for different names.
 
 
PlParam "IP.ADDR" "another-name.mesh"
 
a name for a specified IP address.
 
the IP address has to be either from one of the olsr
 
interfaces or within a HNA network we announce.
 
can be specified multiple times.
 
 
PlParam "hosts-file" "/path/to/hosts_file"
 
which file to write to (usually /etc/hosts).
 
(default: /var/run/hosts_olsr)
 
 
PlParam "suffix" ".olsr"
 
local suffix which is appended to all received names.
 
(default: "")
 
 
PlParam "add-hosts" "/path/to/file"
 
copy contents of this additional hosts file to output file.
 
this is practical if you alreay use your /etc/hosts file.
 
  
PlParam "dns-server" "IP.ADDR"
+
==PLUGIN PARAMETERS (PlParam)==
anounce that this IP has a full (upstream) DNS server. if
 
IP.ADDR is not specified (""), the main address is used.
 
nodes which don't know a nameserver will automatically use
 
this nameserver.
 
  
PlParam "resolv-file" "/path/to/resolv.conf"
+
PlParam "name" "my-name.mesh"
path to resolv.conf file (usually /etc/resolv.conf)
+
the name of this OLSR node (main address).
if set, the 3 nearest (best ETX) upstream nameservers annonced
+
can be specified multiple times for different names.
by other nodes in the network are written to this file
 
  
PlParam "interval" "SEC"
+
PlParam "IP.ADDR" "another-name.mesh"
interval for sending NAME messages in seconds.
+
a name for a specified IP address.
(default: 120 - 2 minutes)
+
the IP address has to be either from one of the olsr
 +
interfaces or within a HNA network we announce.
 +
can be specified multiple times.
  
PlParam "timeout" "SEC"
+
PlParam "hosts-file" "/path/to/hosts_file"
validity time for received NAME messages in seconds.
+
which file to write to (usually /etc/hosts).
(default: 3600 - 1 hour)
+
(default: /var/run/hosts_olsr)
  
PlParam "lat" "12.123"
+
PlParam "suffix" ".olsr"
Float: Decimal latitude for this node to be flooded in the mesh
+
local suffix which is appended to all received names.
 +
(default: "")
  
PlParam "lon" "12.123"
+
PlParam "add-hosts" "/path/to/file"
Float: Decimal longitude for this node to be flooded in the mesh
+
copy contents of this additional hosts file to output file.
 +
this is practical if you alreay use your /etc/hosts file.
  
PlParam "latlon-file" "/var/run/latlon.js"
+
PlParam "dns-server" "IP.ADDR"
Filename to write Javascript statements to. Default is "latlon.js"
+
anounce that this IP has a full (upstream) DNS server. if
(either /var/run or windows directory). This file is written, if
+
IP.ADDR is not specified (""), the main address is used.
the "lat" and "lon" parameters are set. It has this format:
+
nodes which don't know a nameserver will automatically use
 +
this nameserver.
  
/* One or more mid-aliases of multihomed nodes */
+
PlParam "resolv-file" "/path/to/resolv.conf"
Mid('fromip','toip');
+
path to resolv.conf file (usually /etc/resolv.conf)
 +
if set, the 3 nearest (best ETX) upstream nameservers annonced
 +
by other nodes in the network are written to this file
  
/* One special Node() entry for this node
+
PlParam "interval" "SEC"
* defhna means: This node announces hna 0.0.0.0/0
+
interval for sending NAME messages in seconds.
* defroute means: The current neighbour IP for 0.0.0.0/0
+
(default: 120 - 2 minutes)
*/
 
Self('mainip',lat,lon,defhna?1:0,'defroute','name');
 
  
/* One or more node entires for other nodes */
+
PlParam "timeout" "SEC"
Node('mainip',lat,lon,this-node-defhna?1:0,'defroute','name');
+
validity time for received NAME messages in seconds.
 +
(default: 3600 - 1 hour)
  
/* One or more links between nodes */
+
PlParam "lat" "12.123"
Link('fromip','toip',lq,nlq,etx);
+
Float: Decimal latitude for this node to be flooded in the mesh
  
PlParam "latlon-infile" "name-of-input.txt"
+
PlParam "lon" "12.123"
Filename to read lat/lon positions from. Meant to be used
+
Float: Decimal longitude for this node to be flooded in the mesh
by a walking GPS receiver. Just write comma separated decimal
 
latitude and longitude to this file. Will overwrite the
 
"lat" and "lon" parameters during runtime.
 
  
PlParam "sighup-pid-file" "/path/to/pidfile.pid"
+
PlParam "latlon-file" "/var/run/latlon.js"
        (*nix systems only) Sends a HUP signal to the process specified
+
Filename to write Javascript statements to. Default is "latlon.js"
        by the pidfile (usually /var/run/dnsmasq.pid) when the host name
+
(either /var/run or windows directory). This file is written, if
        table changes. This is useful for letting dnsmasq or bind know
+
the "lat" and "lon" parameters are set. It has this format:
        they have to reload their hosts file.
+
 +
/* One or more mid-aliases of multihomed nodes */
 +
Mid('fromip','toip');
 +
 +
/* One special Node() entry for this node
 +
* defhna means: This node announces hna 0.0.0.0/0
 +
* defroute means: The current neighbour IP for 0.0.0.0/0
 +
*/
 +
Self('mainip',lat,lon,defhna?1:0,'defroute','name');
 +
 +
/* One or more node entires for other nodes */
 +
Node('mainip',lat,lon,this-node-defhna?1:0,'defroute','name');
 +
 +
/* One or more links between nodes */
 +
Link('fromip','toip',lq,nlq,etx);
 +
 +
PlParam "latlon-infile" "name-of-input.txt"
 +
Filename to read lat/lon positions from. Meant to be used
 +
by a walking GPS receiver. Just write comma separated decimal
 +
latitude and longitude to this file. Will overwrite the
 +
"lat" and "lon" parameters during runtime.
  
PlParam "name-change-script" "/path/to/script"
+
PlParam "sighup-pid-file" "/path/to/pidfile.pid"
        Script to execute when there is a change in the hosts names
+
        (*nix systems only) Sends a HUP signal to the process specified
        table. Useful for executing a script that uses the hosts file
+
        by the pidfile (usually /var/run/dnsmasq.pid) when the host name
        to keep a website or a database updated.
+
        table changes. This is useful for letting dnsmasq or bind know
 +
        they have to reload their hosts file.
  
PlParam "service" "http://me.olsr:80|tcp|my little homepage"
+
PlParam "name-change-script" "/path/to/script"
        Add a new service announcement to be spreaded in the mesh.
+
        Script to execute when there is a change in the hosts names
 +
        table. Useful for executing a script that uses the hosts file
 +
        to keep a website or a database updated.
  
PlParam "services-file" "/path/to/services_file"
+
PlParam "service" "http://me.olsr:80|tcp|my little homepage"
File to write (default: /var/run/services_olsr)
+
        Add a new service announcement to be spreaded in the mesh.
  
PlParam "services-change-script" "/path/to/script"
+
P lParam "services-file" "/path/to/services_file"
        Similar to the previous parameter. Script to execute when there
+
File to write (default: /var/run/services_olsr)
        is a change in the services list propagated by the nameserver
 
        plugin. Useful for executing a script that uses the services file
 
        to keep a website or a database updated.
 
  
PlParam "mac" "xx:xx:xx:xx:xx:xx[,0-255]"
+
PlParam "services-change-script" "/path/to/script"
        Add a new MAC addr to be spreaded in the mesh. This MAC addr
+
        Similar to the previous parameter. Script to execute when there
        may be used to fine control nerve-wreck-page solutions based
+
        is a change in the services list propagated by the nameserver
        on MAC adresses. The optional dec. number designates a class.
+
        plugin. Useful for executing a script that uses the services file
 +
        to keep a website or a database updated.
  
PlParam "macs-file" "/path/to/macs_file"
+
PlParam "mac" "xx:xx:xx:xx:xx:xx[,0-255]"
File to write (default: /var/run/macs_olsr)
+
        Add a new MAC addr to be spreaded in the mesh. This MAC addr
 +
        may be used to fine control nerve-wreck-page solutions based
 +
        on MAC adresses. The optional dec. number designates a class.
 +
 +
PlParam "macs-file" "/path/to/macs_file"
 +
File to write (default: /var/run/macs_olsr)
  
PlParam "macs-change-script" "/path/to/script"
+
PlParam "macs-change-script" "/path/to/script"
        Similar to the previous parameter. Script to execute when there
+
        Similar to the previous parameter. Script to execute when there
        is a change in the macs list propagated by the nameserver
+
        is a change in the macs list propagated by the nameserver
        plugin. Useful for executing a script that uses the services file
+
        plugin. Useful for executing a script that uses the services file
        to keep a website or a database updated.
+
        to keep a website or a database updated.
  
---------------------------------------------------------------------
+
==SAMPLE CONFIG==
SAMPLE CONFIG
 
---------------------------------------------------------------------
 
  
 
add in /etc/olsrd.conf:
 
add in /etc/olsrd.conf:
Line 155: Line 151:
 
  }
 
  }
  
 
+
==USING THE NAME INFORMATION==
---------------------------------------------------------------------
 
USING THE NAME INFORMATION
 
---------------------------------------------------------------------
 
  
 
to use the name information distributed by the plugin actually for
 
to use the name information distributed by the plugin actually for
Line 165: Line 158:
 
UNIX VARIANTS:
 
UNIX VARIANTS:
  
* overwrite /etc/hosts
+
* overwrite /etc/hosts
be sure you have nothing in /etc/hosts which you still need and
+
be sure you have nothing in /etc/hosts which you still need and
configure the plugin with PlParam "host-file" "/etc/hosts"
+
configure the plugin with PlParam "host-file" "/etc/hosts"
  
* link /etc/hosts
+
* link /etc/hosts
ln -s /var/run/hosts_olsr /etc/hosts
+
ln -s /var/run/hosts_olsr /etc/hosts
  
* use dnsmasq
+
* use dnsmasq
if you want to make the names available via ordinary DNS
+
if you want to make the names available via ordinary DNS
you can use dnsmasq to read the hosts file and serve it to
+
you can use dnsmasq to read the hosts file and serve it to
users. add "addn-hosts=/var/run/hosts_olsr" to dnsmasq.conf  
+
users. add "addn-hosts=/var/run/hosts_olsr" to dnsmasq.conf  
        and:
+
        and:
 
               PlParam "sighup-pid-file" "/var/run/dnsmasq.pid"
 
               PlParam "sighup-pid-file" "/var/run/dnsmasq.pid"
  
        to your nameservice plugin configuration.
+
        to your nameservice plugin configuration.
  
        This is especially usefull for infrastructure mesh networks that
+
        This is especially usefull for infrastructure mesh networks that
        can't afford to run olsrd on all the clients but wish to provide
+
        can't afford to run olsrd on all the clients but wish to provide
        DNS to them. This is solved by running dnsmasq and olsrd with
+
        DNS to them. This is solved by running dnsmasq and olsrd with
        this setup on "edge" nodes that provide connectivity.
+
        this setup on "edge" nodes that provide connectivity.
  
 
WINDOWS:
 
WINDOWS:
  
* overwrite C:\WINDOWS\system32\drivers\etc\hosts
+
* overwrite C:\WINDOWS\system32\drivers\etc\hosts
be sure you have nothing in the file which you still need  
+
be sure you have nothing in the file which you still need  
and configure the plugin with
+
and configure the plugin with
        PlParam "hosts-file" "C:\WINDOWS\system32\drivers\etc\hosts"
+
        PlParam "hosts-file" "C:\WINDOWS\system32\drivers\etc\hosts"
  
---------------------------------------------------------------------
+
==TODO==
TODO
 
---------------------------------------------------------------------
 
 
    
 
    
  * implement a small DNS server into the plugin?
+
* implement a small DNS server into the plugin?
  * or make dynamic DNS updates for bind?
+
* or make dynamic DNS updates for bind?
 
 
---------------------------------------------------------------------
 
EOF / 30.06.2007
 
  
  

Revision as of 12:06, 22 December 2013

Reference: https://github.com/servalproject/olsr/blob/master/lib/nameservice/README_NAMESERVICE


NAMESERVICE PLUGIN FOR OLSRD

by Bruno Randolf <bruno.randolf@4g-systems.biz>


a simple DNS replacement for OLSR networks

this plugin distributes host name (DNS) information over OLSR. every node which runs the olsr daemon can announce it's own name, names for other IP adresses it is associated with (HNAs) and if it is running a "real" nameserver which can resolve other (internet) names (upstream dns server).

the nodes in the network collect this information and write the host names to a file (possibly /etc/hosts), and the 3 nearest upstream nameservers to another file (possibly /etc/resolv.conf).

these files can be used to resolve hostnames on the local system and/or be read by a DNS server like "dnsmasq", to make the names available via the ordinary DNS protocol to other clients as well.

the default location of the hosts file is "/var/run/hosts_olsr" on unixes "C:\WINDOWS\hosts_olsr" on windows


PLUGIN PARAMETERS (PlParam)

PlParam "name" "my-name.mesh"
	the name of this OLSR node (main address).
	can be specified multiple times for different names.
PlParam "IP.ADDR" "another-name.mesh"
	a name for a specified IP address.
	the IP address has to be either from one of the olsr 
	interfaces or within a HNA network we announce.
	can be specified multiple times.
PlParam "hosts-file" "/path/to/hosts_file"
	which file to write to (usually /etc/hosts).
	(default: /var/run/hosts_olsr)
PlParam "suffix" ".olsr"
	local suffix which is appended to all received names.
	(default: "")
PlParam "add-hosts" "/path/to/file"
	copy contents of this additional hosts file to output file.
	this is practical if you alreay use your /etc/hosts file.
PlParam "dns-server" "IP.ADDR"
	anounce that this IP has a full (upstream) DNS server. if 
	IP.ADDR is not specified (""), the main address is used.
	nodes which don't know a nameserver will automatically use
	this nameserver.
PlParam "resolv-file" "/path/to/resolv.conf"
	path to resolv.conf file (usually /etc/resolv.conf)
	if set, the 3 nearest (best ETX) upstream nameservers annonced 
	by other nodes in the network are written to this file
PlParam "interval" "SEC"
	interval for sending NAME messages in seconds.
	(default: 120 - 2 minutes)
PlParam "timeout" "SEC"
	validity time for received NAME messages in seconds.
	(default: 3600 - 1 hour)
PlParam "lat" "12.123"
	Float: Decimal latitude for this node to be flooded in the mesh
PlParam "lon" "12.123"
	Float: Decimal longitude for this node to be flooded in the mesh
PlParam "latlon-file" "/var/run/latlon.js"
	Filename to write Javascript statements to. Default is "latlon.js"
	(either /var/run or windows directory). This file is written, if
	the "lat" and "lon" parameters are set. It has this format:

	/* One or more mid-aliases of multihomed nodes */
	Mid('fromip','toip');

	/* One special Node() entry for this node
	 * defhna means: This node announces hna 0.0.0.0/0
	 * defroute means: The current neighbour IP for 0.0.0.0/0
	 */
	Self('mainip',lat,lon,defhna?1:0,'defroute','name');

	/* One or more node entires for other nodes */
	Node('mainip',lat,lon,this-node-defhna?1:0,'defroute','name');

	/* One or more links between nodes */
	Link('fromip','toip',lq,nlq,etx);

PlParam "latlon-infile" "name-of-input.txt"
	Filename to read lat/lon positions from. Meant to be used
	by a walking GPS receiver. Just write comma separated decimal
	latitude and longitude to this file. Will overwrite the
	"lat" and "lon" parameters during runtime.
PlParam "sighup-pid-file" "/path/to/pidfile.pid"
        (*nix systems only) Sends a HUP signal to the process specified
        by the pidfile (usually /var/run/dnsmasq.pid) when the host name
        table changes. This is useful for letting dnsmasq or bind know
        they have to reload their hosts file.
PlParam "name-change-script" "/path/to/script"
        Script to execute when there is a change in the hosts names
        table. Useful for executing a script that uses the hosts file
        to keep a website or a database updated.
PlParam "service" "http://me.olsr:80%7Ctcp%7Cmy little homepage"
        Add a new service announcement to be spreaded in the mesh.

P lParam "services-file" "/path/to/services_file"

	File to write (default: /var/run/services_olsr)
PlParam "services-change-script" "/path/to/script"
        Similar to the previous parameter. Script to execute when there
        is a change in the services list propagated by the nameserver
        plugin. Useful for executing a script that uses the services file
        to keep a website or a database updated.
PlParam "mac" "xx:xx:xx:xx:xx:xx[,0-255]"
        Add a new MAC addr to be spreaded in the mesh. This MAC addr
        may be used to fine control nerve-wreck-page solutions based
        on MAC adresses. The optional dec. number designates a class.

PlParam "macs-file" "/path/to/macs_file"
	File to write (default: /var/run/macs_olsr)
PlParam "macs-change-script" "/path/to/script"
        Similar to the previous parameter. Script to execute when there
        is a change in the macs list propagated by the nameserver
        plugin. Useful for executing a script that uses the services file
        to keep a website or a database updated.

SAMPLE CONFIG

add in /etc/olsrd.conf:

LoadPlugin "olsrd_nameservice.so.0.2"
{
	PlParam "name" "thisismyname"
	PlParam "hosts-file" "/etc/hosts"
	PlParam "resolv-file" "/etc/resolv.conf"
}

USING THE NAME INFORMATION

to use the name information distributed by the plugin actually for name resolution you can do one of the following.

UNIX VARIANTS:

* overwrite /etc/hosts
	be sure you have nothing in /etc/hosts which you still need and
	configure the plugin with PlParam "host-file" "/etc/hosts"
* link /etc/hosts
	ln -s /var/run/hosts_olsr /etc/hosts
* use dnsmasq
	if you want to make the names available via ordinary DNS
	you can use dnsmasq to read the hosts file and serve it to
	users. add "addn-hosts=/var/run/hosts_olsr" to dnsmasq.conf 
        and:
              PlParam "sighup-pid-file" "/var/run/dnsmasq.pid"
        to your nameservice plugin configuration.
        This is especially usefull for infrastructure mesh networks that
        can't afford to run olsrd on all the clients but wish to provide
        DNS to them. This is solved by running dnsmasq and olsrd with
        this setup on "edge" nodes that provide connectivity.

WINDOWS:

* overwrite C:\WINDOWS\system32\drivers\etc\hosts
	be sure you have nothing in the file which you still need 
	and configure the plugin with
        PlParam "hosts-file" "C:\WINDOWS\system32\drivers\etc\hosts"

TODO

  • implement a small DNS server into the plugin?
  • or make dynamic DNS updates for bind?



Referensi