-
Notifications
You must be signed in to change notification settings - Fork 35
using ona with dnsmasq running on a debian system
robfantini edited this page Aug 29, 2015
·
13 revisions
there is more to do on the server later in the page.
mkdir -p /fbc/dns mkdir -p /fbc/bin # save original hosts file. as we recreate /etc/hosts later . see below. cp /etc/hosts /etc/hosts-`hostname`
fbc is a vulcan abbreviation for federated business computing ;-)
you'll need to change the IP address on the scp and ssh lines.
we run from /etc/cron.d/ona-local every 2 minutes
#!/bin/bash # # if runnning from cli, this forces update to pfsense # also needed if we change subnet info as hosts will be same. # tty > /dev/null && > /root/hosts-ona # # 1- make a new hosts file. # # added set -e as had dcm fail - due to a msql backup in prpgress. , then script created a bad hosts at dns servers 2015-08-27 . # so make sure we exit if this line fails! # set -e /opt/ona/bin/dcm.pl -r ona_sql sql=simplehosts.sql|sed -e "s/\:/ /" -e "s/://g" > /root/hosts-ona.new # # 2- if new hosts file is different then the old one then update dns # if ! cmp -s /root/hosts-ona.new /root/hosts-ona ; then # save file for next compare /bin/cp -f /root/hosts-ona.new /root/hosts-ona # # make host file to be used by dnsmasq # # use sed eliminate header line # cat /root/hosts-ona | sed /"ip fqdn"/d > /root/hosts.extra ### *** change the IP on the following lines *** tty > /dev/null && echo " 10.1.10.8 " scp /root/hosts.extra 10.1.10.8:/fbc/dns/ # # the following script is below. ssh 10.1.10.8 /fbc/bin/hosts-create
I have never been able to get debian dnsnmasq to have the addn-hosts work. if you figure that out let me know. to get around the issue i recreate /etc/hosts when ona updates /fbc/dns/hosts.extra
We use the program monit to monitor /fbc/dbs/hosts.extra . when the file changes a script runs.
- install
apt-get install monit
- monit config :
include /etc/monit/conf.d/*
- make the config file. put this to /etc/monit/conf.d/dnsmasq-ona-fbc :
check file hosts.extra with path /fbc/dns/hosts.extra if changed timestamp then exec "/fbc/bin/hosts-create"
- put this to /fbc/bin/hosts-create
#!/bin/bash # /fbc/bin/hosts-create if [ ! -e /fbc/dns/hosts.extra ]; then echo /fbc/dns/hosts.extra does not exist. so will not procede. exit 1 fi tty > /dev/null && echo ' will run hosts-create ' savelog -l -c 3 /etc/hosts >/dev/null 2>/dev/null HOST=`hostname` # # initialize /etc/hosts # if [ -e /etc/hosts-$HOST ]; then cat /etc/hosts-$HOST > /etc/hosts else echo "127.0.1.1 $HOST.fantinibakery.com $HOST # this line made by $0" > /etc/hosts fi if [ ! -e /fbc/dns/hosts.extra ]; then echo /fbc/dns/hosts.extra does not exist. so will not procede. exit 1 fi tty > /dev/null && echo ' will run hosts-create ' savelog -l -c 3 /etc/hosts >/dev/null 2>/dev/null HOST=`hostname` # # initialize /etc/hosts # if [ -e /etc/hosts-$HOST ]; then cat /etc/hosts-$HOST > /etc/hosts else echo "127.0.1.1 $HOST.fantinibakery.com $HOST # this line made by $0" > /etc/hosts fi # # remainder is from /fbc/dns/hosts.extra # which was created by ona. # " >> /etc/hosts # 2015-05-20 so sed delete at ona cat /fbc/dns/hosts.extra >> /etc/hosts [ -f /etc/init.d/dnsmasq ] && /usr/bin/killall -s 1 dnsmasq >/dev/null