mac上, 直接从V2EX DNS(178.79.131.110)获取app store的ip并向hosts更新 v0.1


cat ~/Scripts/changeAppStoreHost
#!/bin/sh
NewIP=`nslookup a1.phobos.apple.com 178.79.131.110 | tail -n 2 | head -n 1 | sed 's/Address\: //g'`
OldHosts=`cat /etc/hosts`

if [[ $OldHosts =~ phobos\.apple\.com ]]
then
 OldIP=`grep "phobos" /etc/hosts | head -n 1 | sed "s/[ ]//g" | sed "s/a[0-9]*.phobos.apple.com//g"`
 sed "s/${OldIP}/${NewIP}/g" /etc/hosts > /tmp/tmpHosts
 sudo mv /tmp/tmpHosts /etc/hosts
else
 for (( i = 1; i <= 2000 ; i ++ ))
 do
 echo "${NewIP} a$i.phobos.apple.com" >> /etc/hosts
 done
fi

One thought on “mac上, 直接从V2EX DNS(178.79.131.110)获取app store的ip并向hosts更新 v0.1”

发表评论

邮箱地址不会被公开。 必填项已用*标注