#!/bin/bash green='\033[0;32m' yellow='\033[0;33m' plain='\033[0m' red='\033[0;31m' green=[${green}OK${plain}] yellow=[${yellow}Info${plain}] red=[${red}Error${plain}] unlock(){ if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install bind-utils echo y | yum install -y dnsmasq elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then apt-get update apt-get install dnsutils apt install -y dnsmasq elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then apt-get update apt-get install dnsutils apt install -y dnsmasq else echo "This script only supports CentOS, Ubuntu and Debian." exit 1 fi if [ $? -eq 0 ]; then #下载域名列表文件 wget -O proxy-domains.txt https://raw.githubusercontent.com/myxuchangbin/dnsmasq_sniproxy_install/master/proxy-domains.txt systemctl enable dnsmasq chattr -i /etc/resolv.conf if [ ! -f '/etc/resolv.conf.bak' ];then cp -f /etc/resolv.conf /etc/resolv.conf.bak fi rm -f /etc/resolv.conf echo "nameserver 127.0.0.1" > /etc/resolv.conf chattr +i /etc/resolv.conf if [ -s "proxy-domains.txt" ]; then #调用域名列表 cat > /etc/dnsmasq.d/unlock.conf <> "/etc/dnsmasq.d/unlock.conf" done < "proxy-domains.txt" rm -f proxy-domains.txt else #使用默认列表 echo -e "${yellow} 代理域名列表获取失败,使用本地默认代理域名列表..." cat > /etc/dnsmasq.d/unlock.conf < /etc/resolv.conf <