Created
July 22, 2011 10:13
-
-
Save antonlindstrom/1099202 to your computer and use it in GitHub Desktop.
keepalived for DNS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 $? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can i run this configuration without vrrp ?