Creating some cool DNS based load balancing and geo aware server selection.
gdnsd is an opensource alternative to commercial products.
Setup will monitor the Service (SQUID) and remove non responsive services.
Install on FreeBSD
pkg install gdnsd3
Config for gdnsd
/usr/local/etc/gdnsd/config
options => {
tcp_timeout => 15 ; zonefile-style comment
listen => [ 10.55.82.253 ]
}
service_types => {
squidsvc = {
plugin => "extmon",
cmd => ["/usr/local/bin/curl", "-o", "/dev/null", "-s", "http://%%ITEM%%:3128" ],
up_thresh => 1,
ok_thresh => 1,
down_thresh => 1,
interval => 2,
timeout => 1,
}
}
plugins => {
squid-lb => {
service_types = [ squidsvc ]
multi = true
squid01 = [ 10.55.82.24, 10]
squid02 = [ 10.55.83.24, 10]
}
}
}
Zone configuration
/usr/local/etc/gdnsd/zones/gdnsd.example.com
$TTL 5
@ SOA gdnsd01.svc.example.com. hostmaster (
1 ; serial
7200 ; refresh
30M ; retry
3D ; expire
5 ; ncache
)
@ NS gdnsd01.svc.example.com.
@ NS gdnsd02.svc.example.com.
squid-lb 5 IN DYNC weighted!squid-lb
Tests
dig squid.svc.example.com
; <<>> DiG 9.18.20 <<>> squid.svc.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29231
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: bd66eab0264e08000100000065f21c78b73dd234cd4d8324 (good)
;; QUESTION SECTION:
;squid.svc.example.com. IN A
;; ANSWER SECTION:
squid.svc.example.com. 600 IN CNAME squid.gdnsd.example.com.
squid.gdnsd.example.com. 5 IN CNAME squid-lb.gdnsd.example.com.
squid-lb.gdnsd.example.com. 5 IN A 10.55.82.24
squid-lb.gdnsd.example.com. 5 IN A 10.55.83.24
;; Query time: 2 msec
;; SERVER: 10.55.82.254#53(10.255.82.254) (UDP)
;; WHEN: Wed Mar 13 21:36:56 UTC 2024
;; MSG SIZE rcvd: 164

