shell脚本更新github的ip地址达到提速的目的

第一步

添加github 地址条目到hosts文件里面

修改/etc/hosts文件

140.82.113.4 github.com
140.82.113.4 gist.github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.111.153 assets-cdn.github.com
199.232.68.133 raw.githubusercontent.com
199.232.68.133 cloud.githubusercontent.com
199.232.68.133 camo.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com

第二步

#!/bin/sh
for ii in $(awk '/github/{print $2}' /etc/hosts)
do
getip="$(wget -qO- --post-data="host=$ii" https://www.ipaddress.com/ip-lookup -Uuosbox|grep -Eo '<a href="https://www.ipaddress.com/ipv4/\<[0-9]*(\.[0-9]*){3}\>'|awk -F'/' '{print $5;exit}')"
[ "$getip" ]&&sed -i '/ '$ii'/s$\(.*\) \(.*\)$'$getip' \2$g' /etc/hosts
done


内容版权声明:除非注明,否则皆为本站原创文章。

评论

精彩评论