MAC DNS配置小脚本

#!/bin/bash

 

declare -a desc=(\

["0"]="原始环境"\ 

["1"]="alta1"\

["2"]="altb1"\

["3"]="稳定dns"\ 

); 

declare -a ds=(\

["0"]="empty"\ 

["1"]="139.224.7.36"\

["2"]="139.224.241.41"\

["3"]="172.16.6.217"\

); 

for key in ${!desc[@]}

do

echo $key '、' ${desc[$key]}

done

printf '请选择环境:'

read dn

ip=${ds[$dn]}

if [ -n "$ip"  ]; then

sudo networksetup -setdnsservers Wi-Fi $ip

echo 'dns:' $ip

else 

echo '莫瞎选'

posted @ 2017-03-10 10:59  余为国  阅读(471)  评论(0编辑  收藏  举报