〖Linux〗穿越城牆之後,直接連接國內網站的路由配置

來源:互聯網
上載者:User

標籤:des   android   style   blog   http   color   io   使用   ar   

因為有需要做Android相關的開發工作,很多時候要穿越之後才能做事情;

如Android檔案加密預研、Android NDK/SDK的下載,都需要使用得到Google;

但是穿越之後,訪問國內網站就不是那麼方便了,所以,寫一指令碼,在需要的時候直接調用下就可以直達國內網站了;

 1 #!/bin/bash -  2 #=============================================================================== 3 # 4 #          FILE: direct_conn.sh 5 #  6 #         USAGE: ./direct_conn.sh 7 #  8 #   DESCRIPTION:  9 # 10 #       OPTIONS: ---11 #  REQUIREMENTS: ---12 #          BUGS: ---13 #         NOTES: ---14 #        AUTHOR: linkscue (scue), [email protected]15 #  ORGANIZATION: 16 #       CREATED: 2014年09月07日 17時11分00秒 CST17 #      REVISION:  ---18 #===============================================================================19 20 test -n $1 || exit                              # get param21 sudo echo -n                                    # get route22 23 act=add                                         # 預設是添加郵件操作24 gw=192.168.1.1                                  # 預設閘道,未穿越城牆之前25 26 # function27 get_addr(){28     curl -sL http://www.ip138.com/ips1388.asp\?ip\=$1\&action\=1 |\29         grep -i $1 |grep -o ‘[0-9.]\+<‘|awk -F‘<‘ ‘{print $1}‘30 }31 32 case $1 in33     d|del|delete)34         act=del35         shift36         ;;37     a|add)38         act=add39         shift40         ;;41 esac42 43 # do44 for i in [email protected]; do45     ip=$i46     echo $i | grep -q ‘[a-zA-Z]\+‘ &&47         ip=$(get_addr $(echo ${i##http://}|grep -o ‘[a-zA-Z0-9.-]\+‘))48     echo "route: $act $ip"49     case $act in50         add )51             route -n|grep -q $ip ||52             sudo route $act -net $ip netmask 255.255.255.255 gw $gw metric 053             ;;54         del )55             route -n|grep -q $i &&56             sudo route $act -net $ip netmask 255.255.255.255 gw $gw metric 057             ;;58     esac59 done

使用方法:

  可大量操作

  1) 添加路由: ./direct_conn.sh add 203.130.61.21  pan.baidu.com  http://www.baidu.com/  

  2) 刪除路由: ./direct_conn.sh del 203.130.61.21  pan.baidu.com  http://www.baidu.com/  

〖Linux〗穿越城牆之後,直接連接國內網站的路由配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.