1.大家最关注的,翻墙,防止DNS被劫持。, [9 c: r. X2 n) F* C
资深不资深的玩家肯定都知道某墙的事情。用了OpenDNS之类后,真的能防止被某墙劫持域名吗?恐怕太小看某墙了吧。只要是DNS的UDP包经过旁路设备,直接就会被篡改。不信?看看结果
% d& N& ]6 O, J; J/ {正常请求一个被劫持的域名,当然是劫持没商量了
5 k! A; P- J2 ]9 l/ f2 P8 g; G+ V& q* K6 i, \ \
Sam@Bra:~$ dig hen.bao.li
6 {( ^0 S. i5 l ]; ]# ?1 k/ `; s; <<>> DiG 9.6.0-APPLE-P2 <<>> hen.bao.li" c6 @* M8 Y1 H% `- D5 i# T" H* }: w0 g
;; global options: +cmd( ]: o' O0 h5 P0 {0 }+ J
;; Got answer:8 x2 c5 [9 v; M! R
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50859! a1 }9 ?+ M8 k4 u8 n. H
;; flags: qr rd ra! _3 e% P' e5 d/ \$ B
; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 06 p% w3 I) D8 [7 F' Z( {2 U3 H
;; QUESTION SECTION: ;hen.bao.li. IN A8 @( U2 d7 f5 v/ f" h1 H
;; ANSWER SECTION: hen.bao.li. 85697 IN A 78.16.49.15
. q+ T3 |! e& n;; Query time: 0 msec" q" j6 O8 b. N, k4 F& x* R! f0 ?7 @
;; SERVER: 127.0.0.1#53(127.0.0.1)
3 o5 J6 J1 [& |9 G;; WHEN: Mon Dec 7 23:18:48 2009
3 ?8 r0 s- Q( o2 y;; MSG SIZE rcvd: 44
' n |6 Y' G# L5 w& [4 @0 X3 `4 F! H4 H, j% R
Sam@Bra:~$ dig hen.bao.li. K+ I. ~2 q4 |- }! {. b
; <<>> DiG 9.6.0-APPLE-P2 <<>> hen.bao.li
8 W& f6 W1 `+ s, t/ x- u. H;; global options: +cmd5 M! C. H. K) v/ t) k, |# Q
;; Got answer:! S0 m' ^! |# Y+ W0 R; Y: C. t
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50859
( _5 i% A5 `, x& N; N1 j" _;; flags: qr rd ra4 d7 I1 s" j* e
; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
|2 g- Y# B$ b" L" H" m;; QUESTION SECTION:8 U2 I- ^ L; v# t' x! y0 `4 I
;hen.bao.li. IN A
# P8 f- }/ ^& o/ };; ANSWER SECTION:' L4 U: |2 ^- W: }; K" }3 w9 P
hen.bao.li. 85697 IN A 78.16.49.15
. C, A8 B2 {" l t" R2 g;; Query time: 0 msec
+ G- N' @, d; P; S9 z* @9 `$ ~;; SERVER: 127.0.0.1#53(127.0.0.1)) U( ?1 }& f+ o- }& ^8 w1 w
;; WHEN: Mon Dec 7 23:18:48 2009
6 H8 L. J7 h q& };; MSG SIZE rcvd: 442 ]" S& B% Q3 q; m
$ R7 d/ z* d U9 z0 f
然后再看用了Google Public DNS后,照样劫持你没商量
6 ^3 `0 p) |/ M# K/ k2 R: B" {
5 g4 T% B% {! Y& @# L- JSam@Bra:~$ dig @8.8.8.8 hen.bao.li
8 F9 u% I) f% G" }; @3 A2 N; <<>> DiG 9.6.0-APPLE-P2 <<>> @8.8.8.8 hen.bao.li
$ Y: y6 h1 p+ z) ~* W3 l' @; (1 server found)
) ^" ~- L9 A1 g% G8 t9 m5 k6 D9 w;; global options: +cmd
5 O) `1 J2 m: G1 o, n;; Got answer:$ l1 W) K0 R: [5 q$ T
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15485
0 p; S, B# K1 I) Q5 R+ a;; flags: qr aa rd ra+ s# W$ f0 m+ f: a7 n& n$ A. c
; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0/ ^ c5 \6 I" L% ~) Q, J! a
;; QUESTION SECTION: ;hen.bao.li. IN A: ~' v" _% @% z! N; b. {
;; ANSWER SECTION: hen.bao.li. 86400 IN A 78.16.49.15
0 x/ ^- U. V% O3 g: o# {! \; e;; Query time: 75 msec' o8 M! v8 b$ h' t8 W% r0 c; P
;; SERVER: 8.8.8.8#53(8.8.8.8)
' M( {. T- ]/ T7 q; h5 q;; WHEN: Mon Dec 7 23:20:58 2009; B9 v) C% m& c! w8 b4 R/ X
;; MSG SIZE rcvd: 54& f& Q' N( x, w3 }# X1 `
2 E' h% E: W) q# Y6 ^我们看看国外机器得出的真实结果
- u( x! \; c. c) v: G
! ?8 W; O/ b: K: J: Z9 u ^% x[root@WS-10267 ~]# dig @8.8.8.8 hen.bao.li. |, ]4 R3 ~+ j/ ~9 w! p
; <<>> DiG 9.3.4-P1 <<>> @8.8.8.8 hen.bao.li9 C& [' T0 @6 {9 n
; (1 server found)
, U) M/ V, M" \5 m;; global options: printcmd, }/ C( e; B6 n2 S: A4 m
;; Got answer:
7 s/ Q) q& y% {) h4 W( c! y;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20845
6 j7 w2 [+ q1 @, Z; r0 g& L;; flags: qr rd ra
& V$ p0 I: o& n, W! s. z* d c; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0( v/ n& K$ u, c) S" d
;; QUESTION SECTION: ;hen.bao.li. IN A$ I3 j$ @. p4 R8 R; X
;; ANSWER SECTION: hen.bao.li. 14400 IN A 69.163.142.445 y5 {: W/ k0 f1 N
;; Query time: 252 msec
( [4 i, z$ i3 t8 ^* f;; SERVER: 8.8.8.8#53(8.8.8.8)
; G! s: r3 x/ J% _8 G2 ~;; WHEN: Mon Dec 7 23:25:12 2009
( W! j+ f; h2 i7 |' c' A6 W+ M. ^/ Z4 D;; MSG SIZE rcvd: 44
7 U! j9 s, A# m5 p/ j5 D
) n# ^! A5 ^' C0 ?; u可以看到,此路不通。想靠换国外DNS来翻墙的可以醒醒了。
0 o2 K2 a: ^8 D' m, j2 F6 ~0 m0 V( q; h( S" v; r6 L; a# H
2.解析速度快6 s* L/ L# x, j: a( T/ R9 s- D
3 F/ U/ u2 [4 J8 ^Google Public DNS解析速度是挺快的,但OpenDNS就未必了" i( w/ u; D# g( g
, K3 |, A3 E! a5 ~7 O: [Sam@Bra:~$ dig @208.67.222.222 http://www.dnspod.com
( J* G2 I2 }* ?2 `' D: K1 B, N; <<>> DiG 9.6.0-APPLE-P2 <<>> @208.67.222.222 http://www.dnspod.com
0 H1 M& ]# \7 P I; ^. u; (1 server found), O4 ^) p4 d, a
;; global options: +cmd
7 k: ^" }* g0 D# v4 ~;; Got answer:$ V8 U) g5 r$ f! K/ z
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17404
% C; K. v# _; U;; flags: qr rd ra# ?! G, {* C. h& n: a! Y) k
; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0* ^0 e7 J: D+ Y1 T
;; QUESTION SECTION: ;www.dnspod.com. IN A
$ a9 P4 q! N! c2 a6 i2 K;; ANSWER SECTION: http://www.dnspod.com. 600 IN CNAME http://www.dnspod.com.cdnudns.com. http://www.dnspod.com.cdnudns.com. 300 IN A 61.172.249.96 http://www.dnspod.com.cdnudns.com. 300 IN A 218.244.147.137, N' ^) L9 y1 }, w0 `& O. s4 f
;; Query time: 608 msec& T' w/ V1 ?8 p% z
;; SERVER: 208.67.222.222#53(208.67.222.222)
$ {% k6 J3 O) w4 }0 {8 u2 J;; WHEN: Mon Dec 7 23:29:01 2009" _! u, M* u2 d! h( j1 r
;; MSG SIZE rcvd: 101
; l) N" N, _* X8 F6 H' f m
- s: @" Q9 |/ C3.最重要的问题,访问网站真的快吗?
$ L* a: @% D6 r9 ?9 S$ I6 A
+ P! }" K, [% I! f) e1 T相信不少人一定记得之前QQ用户出现过一次“免费出国”,当然,现在这个情况也会出现在用了OpenDNS和Google Public DNS用户的身上。
. I \( t! P8 ]) Z& Y& U; k9 F" S# }# _; n; r) t4 h
大家都知道中国特色的互联网,南北分家,互访速度巨慢无比,网站的维护人员绞尽脑汁的想办法解决互联互通的问题,加速大家的网站访问速度。. F1 ]7 p3 p: K* k6 Q
; m8 ` N, o1 Y( g/ v/ q
网站加速访问有好几种办法,有钱的大公司就用BGP AnyCast,但并不是人人都做得起(有自己的IP段,做一次BGP广播X-XX万,要达到最佳访问效果必须要做N次BGP广播,最后费用有可能达到 XXX万)。没钱的公司就只能用智能DNS了,包括自建的DNS,或者直接用DNSPod这样的现成方案,其实原理都一样。0 L+ Y1 u! A \0 P' i; _& n
& p- t; y4 O% U1 }9 ~
智能DNS其实并不是太智能,它靠的预先分配好几个区域,然后根据用户请求的IP来判断用户属于哪个区域,之后返回对应区域的服务器IP。正常情况下,用户在国内上网,用的是ISP自动分配的DNS,用户域名解析请求发给ISP的DNS,ISP的DNS又发给DNSPod这样的域名授权DNS。 DNSPod这时候拿到的IP地址基本是ISP的DNS地址,所以很方便的就能判断出用户所在的区域,并把结果返回给用户。. `3 }( k: S8 ?7 F% D; i! q' _
8 ], f2 w; M* B( e W* }' D: M
但如果这个时候,用户用的是OpenDNS或者Google Public DNS,因为这些服务器的IP地址是在国外,并且N多老外都在用,智能DNS就不好判断该怎么返回了。返回国外的IP,影响国内用户的访问速度。
, F# `; m' t) Z, ^& k
V% J6 @" H: W9 d w3 F如果返回国内的IP,影响到其他老外的访问速度。并且如果返回国内的IP,那么该到底返回电信还是网通的IP呢?用户属于哪个省份?无从判断。那么最后只能人多决定人少,返回国外的服务器IP。1 S9 R4 ^5 Q5 j2 \
d* m2 A8 G0 d. q7 Q9 y0 P
返回国外IP的结果是,用户被指向网站在国外的服务器,访问网站巨慢。
( x$ c! r4 J' k" c M% ?! x j( Z) \" s8 s, C3 Z; ^
本来想找几个典型例子的,但找了一圈回来,发现国内的大公司在这上面烧钱可是一点都不心痛,全部是BGP。要么就是不搭理国外用户,没针对国外用户单独进行解析,一概解析到电信的服务器去。6 @$ z$ s8 s7 r* f% s
" F% D; o: {1 _ z4 t6 S
拿Google来当例子吧。我是网通用户,使用网通自带的DNS,解析www.google.com得到以下结果( u1 ?: F& L; w# Z+ [5 [
: }5 o0 ]) Q! @- }$ j0 P0 ?. G' ]Sam@Bra:~$ dig http://www.google.com0 a* W+ s' W3 z3 K: N& p- M' ]
......
# b8 y9 i2 u y# @;; ANSWER SECTION:/ [; q# x% ]* }# |( t
http://www.google.com. 48102 IN CNAME http://www.l.google.com.
) ]) P: N: ~/ o. U4 B. Qhttp://www.l.google.com. 300 IN A 216.239.61.1040 j4 B1 [0 ]* s2 f4 ~3 y; B% Y" B: U
: m7 [% B- q" w; U9 Q, E如果我用了OpenDNS的话,那么我得到下面的结果( I7 E% R: }/ \4 v9 h" {7 T
5 P- l8 r! }' x" [7 uSam@Bra:~$ dig @208.67.222.222 http://www.google.com E$ s; R6 p7 u
......
/ i2 ~9 }9 W {6 y;; ANSWER SECTION:! R& y3 v# c0 ?) e5 U
http://www.google.com. 30 IN CNAME google.navigation.opendns.com.
+ m. Z9 |) K& R1 rgoogle.navigation.opendns.com. 30 IN A 208.67.219.230
" d# g$ J. ?* ?3 Kgoogle.navigation.opendns.com. 30 IN A 208.67.219.231
: S$ d" P2 M/ l$ S* z E% m# x! I( m: q% d. y% R0 w" X7 l1 l8 U# ^
ping一下得出的IP地址,看看速度,其实并不快3 q/ g W6 {7 {
/ c5 S5 N2 @6 B' b( }4 g' wSam@Bra:~$ ping 208.67.219.230 PING 208.67.219.230 (208.67.219.230): 56 data bytes2 H4 \1 h; i1 t' a
64 bytes from 208.67.219.230: icmp_seq=0 ttl=51 time=213.828 ms4 P! j& G! ^2 [. P+ R
64 bytes from 208.67.219.230: icmp_seq=1 ttl=51 time=213.779 ms Q. P& v$ Z& @- b& }9 B8 @
64 bytes from 208.67.219.230: icmp_seq=2 ttl=51 time=214.716 ms
5 Y1 {" S1 c }+ `^C
4 }, K0 _3 p* ~' \1 p$ ]/ Q--- 208.67.219.230 ping statistics ---, D1 X$ N' l7 y" [
3 packets transmitted, 3 packets received, 0.0% packet loss
" |; k5 J" V6 F; P" eround-trip min/avg/max/stddev = 213.779/214.108/214.716/0.431 ms3 o, c$ v1 `# f, n0 I
( X" @6 n2 ~1 S4 {& G3 Q, }; Z/ t我们可以再看看kaixin001.com的,如果我是网通用户,用了OpenDNS或者Google Public DNS,那么我会被解析到kaixin001的电信IP去。当然,kaixin001的电信机房线路很好,网通用户访问其实影响不大。
: J) v6 f4 h6 j# z! G# K7 o
6 M9 W" |% U5 O6 {2 \$ W我网通DNS直接解析 d& V1 A0 g& N, y1 J
/ S4 z( t# H! Z5 jSam@Bra:~$ dig kaixin001.com
& r. O z5 b$ Y# g0 [- J, e# S( ?......# i& V h. M" D
;; ANSWER SECTION:- c& }& I+ k$ ~7 J' }
kaixin001.com. 120 IN A 220.181.100.31$ Q7 M1 |- l" C( N p7 F
kaixin001.com. 120 IN A 220.181.100.328 f- W. @+ y7 n3 N; H7 |
kaixin001.com. 120 IN A 220.181.100.33+ Z" E4 H" f) F5 a
kaixin001.com. 120 IN A 220.181.100.34
) h* n" j) e- [kaixin001.com. 120 IN A 220.181.100.35
3 V0 \1 Y3 v7 `8 skaixin001.com. 120 IN A 220.181.100.30
' {3 E9 Q5 V9 v! {5 |& M n' E. M9 ]& p: W( o& j @
如果我换用了OpenDNS,我得到的是kaixin001在电信服务器的IP
' o8 C' q% N6 W! W8 Q
! e- S1 P% U: P2 ]Sam@Bra:~$ dig @208.67.222.222 kaixin001.com ......
- M6 n% Q! O2 s; a3 x;; ANSWER SECTION:- k. Q6 R' e2 G0 }7 K) F
kaixin001.com. 60 IN A 123.125.58.247' d2 z q3 {# l( f7 z3 q' D
kaixin001.com. 60 IN A 123.125.56.246) w3 `8 S# F0 G2 e9 J9 @( p1 T! p/ u
kaixin001.com. 60 IN A 123.125.56.247
( q) H! j ? x+ w3 k; S6 hkaixin001.com. 60 IN A 123.125.56.245
9 e8 Q- B L9 j& m/ H2 [# bkaixin001.com. 60 IN A 123.125.56.248
$ ?5 l" M2 h6 k, M# l6 c: l7 i9 wkaixin001.com. 60 IN A 123.125.59.20, j) o& u- C& t: L9 K
kaixin001.com. 60 IN A 123.125.59.16
" w* v* q0 J0 a8 V* [0 Lkaixin001.com. 60 IN A 123.125.58.2483 _, H: F, ^+ H0 ^
kaixin001.com. 60 IN A 123.125.58.246! w/ v' O8 \) P: R2 G
kaixin001.com. 60 IN A 123.125.58.2459 P% ^8 |6 [1 k+ G& @
5 M+ v9 N. R3 U中小网站就没这么幸运了。中小网站没有太多的钱去买昂贵的BGP线路,只能用很低廉的智能DNS方案,比如我们经常去找字幕的射手网
; p' v) G6 [0 E! c% J' U; @- h
8 q! h2 h: |; l3 U' U0 J网通直接查询,可以得到网通服务器的IP
9 d. V I+ ~8 Q: Y: ?- {5 I8 L# M# R9 A
Sam@Bra:~$ dig shooter.cn ......' V1 u' [, O8 c% y2 `3 v
;; ANSWER SECTION:- g: T2 r: a( \+ W+ k+ L
shooter.cn. 800 IN A 218.21.130.428 q" O& w9 ?# m3 ^
) M8 d2 U9 _4 O: [0 r6 x' l网通套用OpenDNS进行查询,得到的是射手在国外服务器的IP3 k$ D( Y6 {- b& L7 s# |
3 n9 `0 d5 y S1 t
Sam@Bra:~$ dig @208.67.222.222 shooter.cn ......7 S4 V; `: ?- z6 C
;; ANSWER SECTION:
' W+ T$ s$ ^0 A! \6 `. P( s, n# Pshooter.cn. 750 IN A 74.207.252.1701 t: l% W1 e1 a! {* [9 O+ x& Q
7 k7 n" ^( |; _4 B8 m. X5 z; u6 [
这样,你就“被出国”了。用了OpenDNS或者Google Public DNS后,你访问的将是一个速度并不快的射手网。( K8 H* V! n1 K* I& h+ p4 p
* {6 ]2 S; t6 Z$ E国内类似射手网这样的中小网站有几十万甚至上百万,不少游戏运营商也采用这样的方案。虽然他们不一定有国外的服务器,但如果你被解析到并不属于自己网络的服务器上,访问速度或多或少都会受到影响。所以,如果你最近访问网站速度有所下降,或者玩游戏的时候经常掉线,那么你就该把DNS给换回来了。 |