2025年12月19日 星期五

開源 GSLB ?


開源 GSLB ?   OpenSource  GSLB  (Global Server Load Balancing

URL

https://gdnsd.org/

https://github.com/gdnsd/gdnsd/

亂測記錄如下:

Demo 按權重分配 


監控目標主機異常測試


設定問題排查


message log 


亂測使用的設定 (gdnsd/config)


cat /etc/gdnsd/gdnsd/config

options => {

    dns_port => 53

    listen => any

};

service_types => {

    www_check_tcp => {

        plugin => tcp_connect,

        port => 80,

        interval => 10,

        timeout => 3

    }

};


plugins => {

    weighted => {

        www_weighted => {

            service_types => [ "www_check_tcp" ],

            www1 => [ "192.168.100.2", 30 ],

            www2 => [ "192.168.100.1", 70 ]

        }

    }

};


=============================

亂測使用的設定 (gdnsd/zone)


cat /etc/gdnsd/gdnsd/zones/vlab.tw 

$TTL 300


@   IN SOA ns1.vlab.tw. admin.vlab.tw. (

        2024122001  ; serial

        3600        ; refresh

        900         ; retry

        604800      ; expire

        300         ; minimum

)


    IN NS  ns1.vlab.tw.

ns1 IN A   192.168.100.200

@   IN A   192.168.100.200

mail IN A  192.168.100.101

vlab.tw.       IN MX 10 mail.vlab.tw.


www IN DYNA weighted!www_weighted

=============================

隨便安裝的參考步驟

dnf install libev-devel 

dnf install gcc make libev-devel libsodium-devel libmaxminddb-devel perl-Pod-Parser autoconf automake ragel

 dnf install userspace-rcu.x86_64 userspace-rcu-devel.x86_64

 dnf install perl-Test-Simple perl-JSON-PP perl-Socket6 perl-Net-DNS perl-HTTP-Daemon


mkdir /usr/local/src/tmp

cd /usr/local/src/tmp

wget https://github.com/gdnsd/gdnsd/archive/refs/tags/v3.8.3.tar.gz 

tar -zvxf v3.8.3.tar.gz 

cd gdnsd-3.8.3

autoreconf -fi

./configure   --sysconfdir=/etc/gdnsd   --localstatedir=/var   --with-systemdsystemunitdir=/usr/lib/systemd/system

make 

make install

 vi /usr/lib/systemd/system/gdnsd.service

sudo systemctl daemon-reload

sudo systemctl enable --now gdnsd



===========================

隨便設定成系統服務的參考設定

cat /usr/lib/systemd/system/gdnsd.service

[Unit]

Description=gdnsd Authoritative DNS Server

After=network.target


[Service]

Type=simple

ExecStart=/usr/local/sbin/gdnsd -c /etc/gdnsd/gdnsd start



[Install]

WantedBy=multi-user.target