diff --git a/README.md b/README.md index d9d606b..67c0cd0 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,16 @@ The wildcard format shall be defined as per the below If you are using these files within a squid dst_domain acl you will need to reformat the wildcard entries to be compliant with the squid acl format. The following regex should suffice `s/*\./\./` +### Multiple IP Addresses + +unbound supports assigning multiple IP addresses to a record (can be used if using multiple caches). Example config formatting: +```json +"ips": { + "steam": [ "10.10.3.11", "10.10.3.12", "10.10.3.13" ], + "generic": "10.10.3.16" +}, +``` + ## Updates Please fork this repository and submit pull requests if you have any extra hostnames or services to add. We want this list to be definitive and collaborative! diff --git a/scripts/create-unbound.sh b/scripts/create-unbound.sh index c0d4c0e..e0ec366 100755 --- a/scripts/create-unbound.sh +++ b/scripts/create-unbound.sh @@ -15,8 +15,13 @@ fi cachenamedefault="disabled" -while read line; do - ip=$(jq -r ".ips[\"${line}\"]" config.json) +while read line; do + linecount=$(jq -r ".ips[\"${line}\"]" config.json |wc -l) + if [[ $linecount -eq 1 ]]; then + ip=$(jq -r ".ips[\"${line}\"]" config.json) + else + ip=$(jq -r ".ips[\"${line}\"][]" config.json |tr '\n' ' ') + fi declare "cacheip$line"="$ip" done <<< $(jq -r '.ips | to_entries[] | .key' config.json) @@ -56,7 +61,10 @@ while read entry; do continue fi echo " local-zone: \"${parsed}\" redirect" >> $outputfile - echo " local-data: \"${parsed} 30 IN A ${cacheip}\"" >> $outputfile + cacheiplist=($cacheip) + for i in "${cacheiplist[@]}"; do + echo " local-data: \"${parsed} 30 IN A ${i}\"" >> $outputfile + done done <<< $(cat ${basedir}/$filename); done <<< $(jq -r ".cache_domains[$entry].domain_files[$fileid]" $path) done <<< $(jq -r ".cache_domains[$entry].domain_files | to_entries[] | .key" $path)