Last active
December 20, 2022 20:01
-
-
Save rokiden/4ff0afc8de93389258e9ce6e45d961b0 to your computer and use it in GitHub Desktop.
linuxserver/wireguard custom script configuring coredns with domain zone and peers
This file contains 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
#!/usr/bin/with-contenv bash | |
CONFIG_DIR="/config" | |
if [ -z "$COREDNS_ZONE" ]; then | |
COREDNS_ZONE="wg.net" | |
fi | |
echo "**** CoreDNS hosts zone $COREDNS_ZONE ****" | |
echo "$COREDNS_ZONE {" > $CONFIG_DIR/coredns/hosts.conf | |
echo " hosts {" >> $CONFIG_DIR/coredns/hosts.conf | |
echo " " `grep Address $CONFIG_DIR/wg0.conf | awk '{print $NF}'` gate.$COREDNS_ZONE | tee -a $CONFIG_DIR/coredns/hosts.conf | |
for f in `ls $CONFIG_DIR/peer*/peer*.conf`; do | |
name=`basename $f .conf | sed 's/^peer_*//'` | |
echo " " `grep "Address" $f | awk '{print $NF}'` $name.$COREDNS_ZONE | tee -a $CONFIG_DIR/coredns/hosts.conf | |
done | |
echo " }" >> $CONFIG_DIR/coredns/hosts.conf | |
echo "}" >> $CONFIG_DIR/coredns/hosts.conf | |
if [[ -z `grep /config/coredns/hosts.conf $CONFIG_DIR/coredns/Corefile` ]]; then | |
echo "**** CoreDNS hosts patch Corefile ****" | |
echo 'import /config/coredns/hosts.conf' >> $CONFIG_DIR/coredns/Corefile | |
fi |
Author
rokiden
commented
Dec 20, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment