从香港机房引入google/bitbucket路由
首先说这种方法有一个局限性:只适用于非CDN网段的引入,比如Google自己足够大,所以用不到CDN,那在香港解析出来的就是Google在香港自己的AS number,因此不存在CDN干扰的问题。如果在香港解析出来发现是Akamai(a big CDN vendor)的地址,比如解析苹果的地址就会解析出Akamai的地址,那这种情况就不适用了。
环境是3台Juniper路由器,两台在香港hkg1-wan[1-2],一台在北京pek1-mx104-1。
topology:
|pek1-mx104-1 AS38361|--------- |AS 6623 hkg1-wan1 -------------hkg1-wan2 | ---------------| AS 10026 Pacnet router|
背景:北京办公室的DNS可以解析到www.google.com 和 www.bitbucket.org,但是路由不通,被长城firewall给屏蔽了。能解析是因为,DNS的配置文件会依赖美国的DNS服务器上的条目。
思路:
香港那边的公网出口,它在另外一个公网AS number,肯定是全部的公网路由全学过来了,真正的Internet, 那既然已经学过来了,我们要做的就是明确的去标记这些在大陆被禁的路由,然后export给北京的router, 那么在匹配流量定义行为的时候,就是匹配住被禁止的,然后定义一个打标签的行为,这个打标签将通过community:community-value的方式实现,当你的另一个跟大陆AS相连的router向大陆export的时候,使用community列表标记出这些路由,然后特定的向大陆做export。
关于community-value的应用可以参考这个链接,来自Cisco
http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/28784-bgp-community.html , 讲的炒鸡棒有木有。
香港的hkg1-wan2 是香港的公网出口,它能学到完整的公网路由,因为它和Pacnet建立的是”全穿透”的BGP邻居,也就是真正的EBGP, 顺便吐槽国内运营商。
hkg1-wan2 上
as followings
[edit protocols bgp group pacnet]
root@hkg1-wan2# show
type external;
import [ import_transit drop-cbs-routes tag-google-routes tag-bitbucket-routes default-accept ]; // 这个地方是个关键的点,学路由的时候,单独标出google和bitbucket家的路由
family inet {
unicast;
}
export default-reject;
peer-as 10026; //10026是太平洋电信的AS number
neighbor 202.147.17.121; //建邻居的点
[edit protocols bgp group pacnet]
root@hkg1-wan2#
当然这些 import后面跟的东西都是 policy-statement, policy-statement 调用“匹配流量”和“定义行为”,“匹配流量”就是 from xxx, “定义行为”就是 then xxx。
那么问题来了,用什么匹配流量呢?尝试去匹配住一个被GFW屏蔽的网站,有很多办法,比如网址、IP地址、但是网址和IP地址都存在各自的短板,网址需要涉及解析,IP地址有可能会换,那么,有一个已经简便的办法是“匹配他家的公网AS number”, 因为这个AS number是基本不会变动的。
第一步:获取到他的AS number, 这个简单,在香港的router上ping 一下他家的网址,DNS指向香港当地ISP提供给你的DNS, 找到公网地址之后,再去http://bgp.he.net/ 这类的网站去看他家的AS number.
root@hkg1-wan2# run ping inet www.google.com
PING www.google.com (74.125.239.50): 56 data bytes
64 bytes from 74.125.239.50: icmp_seq=0 ttl=56 time=153.932 ms
^C
--- www.google.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 153.932/153.932/153.932/0.000 ms
然后在router上进行抓取流量,using as-path list
as followings
在 edit policy-options下
as-path google-as-path ".* 15169 .*";
as-path bitbucket-as-path ".* 2914 .*”;
然后调用到policy-statement 下,也是在edit policy-options下
policy-statement tag-bitbucket-routes {
from as-path bitbucket-as-path;
then {
community add CBSI_BITBUCKET;
}
}
policy-statement tag-google-routes {
from as-path google-as-path;
then {
community add CBSI_GOOGLE;
}
}
定义的行为就是打标,目的是在从运营商学习的时候,和在export给大陆的时候,明确的标示出这些流量
在对运营商一端这么写,在edit protocols bgp下
group pacnet {
type external;
import [ import_transit drop-cbs-routes tag-google-routes tag-bitbucket-routes tag-github-routes default-accept ];
family inet {
unicast;
}
export default-reject;
peer-as xxxxx;
neighbor xxxxxxxx;
}
在edit policy-options下这么写
community CBSI_GOOGLE members 6623:6006;
community CBSI_BITBUCKET members 6623:6007;
然后把上面这些“tag”, 手动copy到和大陆AS相连的hkg1-wan1上。然后在export给大陆的时候用,as followings, 当然在export调用的时候,通常还是用policy-statement,所以再写两条policy-statement
hkg1-wan1上
在 edit policy-options 下
policy-statement export_bitbucket {
from community CBSI_BITBUCKET; //这个community 就是从
then accept;
}
policy-statement export_google {
from community CBSI_GOOGLE;
then accept;
}
然后调用到对大陆的那个BGP group, as followings
[edit protocols bgp group cbsi-china]
root@hkg1-wan1# show
type external;
description "CBSI Beijing";
import [ import_cbsi_china default-accept ];
family inet {
unicast;
}
export [ export_local export_internal export_corp export_google export_bitbucket default-reject ];
peer-as 38361;
neighbor xxxxxx; // 博客园牛人太多,还是隐去公网IP的好
[edit protocols bgp group cbsi-china]
root@hkg1-wan1#
这样北京的router在看Google和bitbucket的路由的时候,就可以看到明细的路由了,而不再像针对其他网站一样是走默认路由扔向联通出口,而是走移动专线通往香港机房。
在pek1-mx104-1上
hsun@cn-pek1-mx104-1> ping inet www.google.com
PING www.google.com (216.58.221.132): 56 data bytes
64 bytes from 216.58.221.132: icmp_seq=0 ttl=56 time=60.459 ms
^C
--- www.google.com ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 60.459/60.459/60.459/0.000 ms
hsun@cn-pek1-mx104-1> show route 216.58.221.132
inet.0: 18985 destinations, 27621 routes (18985 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
216.58.221.0/24 *[BGP/170] 5w3d 11:02:35, localpref 100
AS path: 6623 10026 15169 I, validation-state: unverified //
看这个地方,AS path会被更改为,先到6623的香港AS, 再到太平洋电信的10026,再到谷歌家的15169,最后的标示是origin code I 。
> to 216.239.126.244 via ge-0/1/0.0
hsun@cn-pek1-mx104-1>
对比去往其他网站, 如163.com
hsun@cn-pek1-mx104-1> ping www.163.com
PING 163.xdwscache.glb0.lxdns.com (111.202.60.47): 56 data bytes
^C
--- 163.xdwscache.glb0.lxdns.com ping statistics ---
1 packets transmitted, 0 packets received, 100% packet loss
hsun@cn-pek1-mx104-1> show route 111.202.60.47
inet.0: 18900 destinations, 27536 routes (18900 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
0.0.0.0/0 *[BGP/170] 17w5d 09:33:12, MED 0, localpref 100, from 172.22.22.19
AS path: I, validation-state: unverified
> to xxxxxxxx via xe-1/1/0.0 // 此处是联通的公网IP, 也隐去好了
去163.com就是从默认路由去联通。
然后就可以在北京开心的上google和bitbucket了。
从香港机房引入google/bitbucket路由的更多相关文章
- ArcGIS for Flex中引入google map作底图
上篇文章到在ArcGIS View中引入google map,这里讲ArcGIS for Flex中引入google map作底图. 同样道理,以google map作底图,需要编写继承自TiledM ...
- ArcGIS Viewer for Flex中引入google map作底图
在ArcGIS Viewer for Flex开发中,经常需要用到google map作为底图,我们不能通过ArcGIS Viewer for Flex - Application Builder轻易 ...
- ArcGIS Viewer for Flex中引入google map作底图 (转)
在ArcGIS Viewer for Flex开发中,经常需要用到google map作为底图,我们不能通过ArcGIS Viewer for Flex - Application Builder轻易 ...
- WEB引入Google思源黑体
通过Link标签在网页头部引用Google Web Font: 1 <link rel="stylesheet" href="https://fonts.googl ...
- Community Value再理解
其实之前写“从香港机房引入google/bitbucket路由”的时候,对community value的了解还并不深入,对Juniper default BGP export/import poli ...
- 香港,将军澳,TKO,服务器,运维,机房,云清洗
目前香港到大陆速度最快.最稳定线路之一. 线路也是唯一华南华北一样快速的线路,是100%的“双线”,不存在其他香港线路网通访问比电信慢的问题. (香港)将军澳TKO机房网络速度快捷,机房内部环境配有意 ...
- HCNP Routing&Switching之路由引入
前文我们了解了路由控制技术策略路由相关话题,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15333139.html:今天我们来聊一聊路由引入技术相关话题: 路 ...
- HCNP Routing&Switching之路由引入导致的问题及解决方案
前文我们了解了路由引入相关话题,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/15359902.html:今天我们来讨论下由于路由引入所导致的问题以及怎么避免此 ...
- linux route命令的使用详解 添加永久静态路由 tracert traceroute
linux route命令的使用详解 添加永久静态路由 tracert traceroute route -n Linuxroute print Windows traceroute ...
随机推荐
- java 命令行运行时报错:找不到或无法加载主类
源码如下: 路径目录(...\src\object) //: ch1.10/Command.java /**@author feilong * @version 1.0 */ package obje ...
- Https双向认证Android客户端配置
Https .cer证书转换为BKS证书 公式https://blog.csdn.net/zww986736788/article/details/81708967 keytool -importce ...
- kafka.common.KafkaException: Failed to acquire lock on file .lock in /tmp/kafka-logs. A Kafka instance in another process or thread is using this directory.
1.刚才未启动zookeeper集群的时候,直接启动kafka脚本程序,kafka报错了,但是进程号启动起来来,再次启动出现如下所示的问题,这里先将进程号杀死,再启动脚本程序. [hadoop@sla ...
- 使用 curses 函数库管理基于文本的屏幕
curses 函数库提供了终端无关的方式来编写全屏幕的基于字符的程序.curses 还可以管理键盘,提供了一种简单易用的非阻塞字符输入模式. curses 函数库能够优化光标的移动并最小化需要对屏幕进 ...
- poj2398
题解: 计算几何入门题 对每个二分最近的在它右边的杆子 如何判断一个杆子在它右边呢 计算机判断这些要更善于利用点积和叉积 如果叉积为正代表在顺时针方向叉积为负在逆时针 发现要在struct里面重载运算 ...
- 记JS一个错误,
在定义变量时候,如果直接定义 var obj=null;那么,在转码时候,比如转为base64,此时或出现特殊的文字(也是汉字,只是很少见少用的文字,而且,出现的文字是根据你给obj赋值决定的,) 由 ...
- HTML5漫谈(7)——如何保护HTML5应用代码
独家供稿:移动Labs HTML5应用采用的仍然是Javascript(JS).HTML.CSS 等Web语言,因而其代码保护就是这些Web代码的保护,而HTML5应用主要功能一般采用JS实现,因此J ...
- python全栈开发day99-DRF序列化组件
1.解释器组件源码分析 https://www.processon.com/view/link/5ba0a8e7e4b0534c9be0c968 2.基于CBV的接口设计 1).django循环que ...
- Flink运行在yarn上
在一个企业中,为了最大化的利用集群资源,一般都会在一个集群中同时运行多种类型的 Workload.因此 Flink 也支持在 Yarn 上面运行: flink on yarn的前提是:hdfs.yar ...
- 移动端上拉加载下拉刷新插件-mescroll.js插件
官网地址是:http://www.mescroll.com // 初始化mescroll function initMeScroll() { //创建MeScroll对象,内部已默认开启下拉刷新,自动 ...