Skip to content

Instantly share code, notes, and snippets.

@antonlindstrom
Created July 22, 2011 10:13
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save antonlindstrom/1099202 to your computer and use it in GitHub Desktop.
Save antonlindstrom/1099202 to your computer and use it in GitHub Desktop.
keepalived for DNS
#!/bin/bash
#$Id: keepalivepin,v 1.2 2006/02/27 07:30:41 hmy Exp hmy $
#use dig check the powerdns's status.
#in the dns database,have a IN TXT RR keepalivepin.vmmatrix.net,content is "AaBbCcDdEeFf"
# Source: http://puppet-manifest-share.googlecode.com/svn/trunk/vmx-puppet/modules/lvs/files/keepalived.dns-pin
#
RR=keepalivepin.vmmatrix.net
[ $# -le 1 ]&&{ echo "usage: ${0} -h <ip>"; exit 126;}
while getopts "h:" OPT;do
case $OPT in
h)host=$OPTARG;;
*)echo "usage: $0 -h <ip>"&&exit 1;;
esac
done
dig @${host} txt ${RR}|grep "\<AaBbCcDdEeFf\>" >/dev/null
exit $?
vrrp_instance dns_test {
interface eth0
state MASTER
virtual_router_id 51
priority 100
authentication {
auth_type PASS
auth_pass p4ssw0rd
}
virtual_ipaddress {
10.0.2.16/24 dev eth0
}
}
# Check for UDP
virtual_server 10.0.2.16 53 {
delay_loop 6
lb_algo wlc
protocol UDP
real_server 10.0.2.20 53 {
weight 100
MISC_CHECK {
connect_timeout 6
misc_path "/etc/keepalived/dnscheck -h 10.0.2.20"
}
}
real_server 10.0.2.21 53 {
weight 100
MISC_CHECK {
connect_timeout 6
misc_path "/etc/keepalived/dnscheck -h 10.0.2.21"
}
}
}
# Check for TCP
virtual_server 10.0.2.16 53 {
delay_loop 6
lb_algo wlc
protocol TCP
real_server 10.0.2.20 53 {
weight 100
TCP_CHECK {
connect_timeout 6
}
}
real_server 10.0.2.21 53 {
weight 100
TCP_CHECK {
connect_timeout 6
}
}
}
@adilmf
Copy link

adilmf commented Mar 13, 2013

can i run this configuration without vrrp ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment