[Up]常用資訊

[重點文章] 重點文章 [重點文章] 重點文章

2020年3月15日 星期日

[DNS] DNS 檢查 for BIG-IP

DNS 檢查 for BIG-IP

#!/bin/bash

## DNSMONITOR
##
## Purpose: to periodically query a remote DNS server for a given name to keep
##          a local internal data group populated with current IP information.
##


## define DNS server
DNS_SERVER=10.80.0.200

## define server name
DNS_NAME=tester.mydomain.com

## define dns hash file
DNS_HASH=dns.hash

## define internal data group
DATAGROUP=my_dns_datagroup


## perform the DNS query
lookup=( $(dig @$DNS_SERVER $DNS_NAME +short +time=3|sort) )

## verify that the DNS query returned a response
if [ $lookup == ";" ]
then
    logger -p local0.info -t DNSMONITOR "DNS monitor is unable to query the DNS server $DNS_SERVER for the name '$DNS_NAME'"
    exit
fi

## create a flat list of IPs
iplist=`printf -- '%s ' "${lookup[@]}"`

## create a hash of the results
hash=`echo $iplist | md5sum |sed 's/ //' |sed 's/-//'`


## if the hash file doesn't exist or hash file value is different - update the datagroup
if [ ! -f $DNS_HASH ] || [ "$(cat $DNS_HASH)" != $hash ]
then
    ## overwrite the datagroup
    tmsh modify ltm data-group internal $DATAGROUP records replace-all-with { $iplist }

    ## log that the datagroup changed
    logger -p local0.info -t DNSMONITOR "DNS datagroup was updated with the following values: { $iplist }"

    ## create/overwrite hash file
    echo $hash > $DNS_HASH
fi
public class HelloWorld {

    public static void main (String[] args) {
        System.out.println("Hello, world!");
    }
}

沒有留言:

張貼留言