Skip to content

Instantly share code, notes, and snippets.

@quchao
Last active July 28, 2016 08:49
Show Gist options
  • Save quchao/8d82310c358854ffdc3030c3fdf57280 to your computer and use it in GitHub Desktop.
Save quchao/8d82310c358854ffdc3030c3fdf57280 to your computer and use it in GitHub Desktop.
Convert .conf files in dnsmasq format to unbound format
#!/bin/bash
CN_DNS="182.254.116.116" # DNSPod Shenzhen
CN_DNS_2="114.114.114.114" # 114DNS
cat dnsmasq.conf | grep -v '^#' | sed -e "s|^server=/\([^0-9].*\)/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}$|forward-zone:\n\tname: \"\1\"\n\tforward-addr: ${CN_DNS}\n\tforward-addr: ${CN_DNS_2}\n\tforward-first: yes|g" -e "s|^address=/\([^0-9].*\)/\([0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}\)$|local-zone: \"\1 A \2\"|g" > unbound.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment