OpenWRT: OLSR nameservice plugin
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.3" { 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?