1.大家最关注的,翻墙,防止DNS被劫持。( q# U1 ?+ [" U' ^: y0 |4 @' x$ a
资深不资深的玩家肯定都知道某墙的事情。用了OpenDNS之类后,真的能防止被某墙劫持域名吗?恐怕太小看某墙了吧。只要是DNS的UDP包经过旁路设备,直接就会被篡改。不信?看看结果0 M* f$ B3 ]* a1 Y' F
正常请求一个被劫持的域名,当然是劫持没商量了
7 m o; x0 t% N: l# i: [. ]8 E5 E9 Q
Sam@Bra:~$ dig hen.bao.li9 |/ x* f E. a1 y3 ? U
; <<>> DiG 9.6.0-APPLE-P2 <<>> hen.bao.li
; s2 W: i" o. @ t& o! y;; global options: +cmd; h/ ~! p) y" l0 Z
;; Got answer:
T3 a: j+ F! A- O/ Y. _;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50859: i T6 ^( F# N8 I/ O. |* l
;; flags: qr rd ra
6 W4 \$ m3 D% P; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
( m5 v5 h; x6 T. k6 m;; QUESTION SECTION: ;hen.bao.li. IN A& F( \) k. x4 O8 c4 b2 `
;; ANSWER SECTION: hen.bao.li. 85697 IN A 78.16.49.15" p' Y8 k9 K: B; `
;; Query time: 0 msec4 q4 g1 s; j" B3 K: d5 p! U% ]; y5 F
;; SERVER: 127.0.0.1#53(127.0.0.1)& {: Y6 E# s1 [8 }
;; WHEN: Mon Dec 7 23:18:48 2009# w H6 r# ?9 u8 i6 n4 p' p( F
;; MSG SIZE rcvd: 44( ?' ]8 e9 i' i. ~" I
1 B; [# _$ j9 b" s6 eSam@Bra:~$ dig hen.bao.li, I; {$ F: N# ?( T$ z: |/ Y" x/ v; l
; <<>> DiG 9.6.0-APPLE-P2 <<>> hen.bao.li
( s2 {# R$ d) e- I- @;; global options: +cmd m) y! \2 @# |/ O/ W! t, J1 i
;; Got answer:" H1 m6 t5 r6 e6 Z" ?2 U4 A5 {$ Y
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50859* g. E' s+ W" p' _! x
;; flags: qr rd ra* {- _8 Z6 j2 M9 }; |3 g
; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 08 r! w0 K4 d" b$ {: o
;; QUESTION SECTION:
) O) P8 I3 {; C! P& |) x;hen.bao.li. IN A
3 x8 ^" J {1 o;; ANSWER SECTION:2 A# z: Y0 k9 Q3 a
hen.bao.li. 85697 IN A 78.16.49.150 X$ x7 \, \! k w ~
;; Query time: 0 msec
7 F3 Y3 y! u: ~ E- o;; SERVER: 127.0.0.1#53(127.0.0.1)
# E; g; E6 u" j7 W, J;; WHEN: Mon Dec 7 23:18:48 2009' l' M W# C& s( |! k+ F) g+ ^
;; MSG SIZE rcvd: 44
9 r$ K* T7 ]% i8 r; V% J
$ F& ?' l( ?2 d) P, s8 Z然后再看用了Google Public DNS后,照样劫持你没商量4 ?# s( O) R4 G' u' ]
' @6 f8 i4 ~9 C( H4 f( zSam@Bra:~$ dig @8.8.8.8 hen.bao.li% e( R V0 m4 @$ k6 D* Q" l
; <<>> DiG 9.6.0-APPLE-P2 <<>> @8.8.8.8 hen.bao.li7 k S: {3 a6 g. n
; (1 server found)6 }$ N7 s/ r# h5 L8 Q7 l6 a
;; global options: +cmd
* u( j# m$ u2 `9 V. u6 S. z! t/ B# J;; Got answer:3 ~: _. U+ t/ i$ w! F/ k- L
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15485
! Y+ a! V: ^. V( _;; flags: qr aa rd ra1 m4 \3 a2 E" i7 q+ y0 `
; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
" Y) y( M/ p+ T5 H7 V/ A' t; n" W; @;; QUESTION SECTION: ;hen.bao.li. IN A
, W7 K" i; p; u4 i;; ANSWER SECTION: hen.bao.li. 86400 IN A 78.16.49.15; Z3 b- z; ]4 b4 r" g
;; Query time: 75 msec
4 U: s V; }$ q% r;; SERVER: 8.8.8.8#53(8.8.8.8)& ~' G2 n+ H( k0 j% f
;; WHEN: Mon Dec 7 23:20:58 2009! q3 ?1 L' x$ w5 c3 @/ d3 C
;; MSG SIZE rcvd: 54. V' ]! J- g K \3 B* _3 H6 ]+ {
/ S' p6 c1 ^0 X/ ~4 T
我们看看国外机器得出的真实结果
5 J" @ _2 O3 \0 [( A" f4 d' P6 N7 {% Y8 x+ Z5 C$ H
[root@WS-10267 ~]# dig @8.8.8.8 hen.bao.li
$ S* w+ J0 k9 m# c; <<>> DiG 9.3.4-P1 <<>> @8.8.8.8 hen.bao.li: p2 }& Z" w$ ~( f9 g) [7 b
; (1 server found)6 T# X5 D1 w! O; u+ O
;; global options: printcmd5 v8 F4 D: J# I& o3 z# t( \3 S3 w' W
;; Got answer:; u6 W6 p/ F9 g1 h
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20845
" m5 E' X+ j$ F6 N7 e8 P5 n;; flags: qr rd ra
1 A5 O- m7 m+ a; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0+ B/ f8 G6 c# u: z# G& r$ y! X$ j
;; QUESTION SECTION: ;hen.bao.li. IN A0 p! R5 @5 E6 D
;; ANSWER SECTION: hen.bao.li. 14400 IN A 69.163.142.44
* {( Z; ~/ o: z, f6 P5 T;; Query time: 252 msec/ {! m: m1 b% j& ]0 n6 t2 N7 m+ ?
;; SERVER: 8.8.8.8#53(8.8.8.8) \+ @. W) E, k' D
;; WHEN: Mon Dec 7 23:25:12 2009
% y& r) T$ X4 l' ?% Y# h) |7 ~* L;; MSG SIZE rcvd: 44
6 Y7 A; N, k* s X, v4 Q" |) r4 _
可以看到,此路不通。想靠换国外DNS来翻墙的可以醒醒了。
- K! J8 v% ]9 l8 c# j" l+ ]0 Y4 U; X. I ]' P5 v. ?
2.解析速度快
! v `! P& p; w& r5 K% X b
4 L5 r8 M5 e$ l: l; n; \; k! RGoogle Public DNS解析速度是挺快的,但OpenDNS就未必了1 u0 z% u( {5 g8 L
( n' ^$ w G0 X/ hSam@Bra:~$ dig @208.67.222.222 http://www.dnspod.com
/ K& e3 j- b" v* z6 o( c; <<>> DiG 9.6.0-APPLE-P2 <<>> @208.67.222.222 http://www.dnspod.com: B4 n5 [+ k' \: L& F3 x
; (1 server found)( c- j- G# @0 q( `* C0 L- C
;; global options: +cmd) w( B, I. ?) H
;; Got answer:: w- R1 g# P% f& I3 I
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 174041 S: N) _1 J* m5 {5 L C; C
;; flags: qr rd ra6 {$ V/ i6 l( a
; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 06 c' @% J7 Q7 w* f# `
;; QUESTION SECTION: ;www.dnspod.com. IN A5 i0 W* X6 @/ K- Z4 r9 w
;; 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
/ W8 Y' p3 J9 F;; Query time: 608 msec
; y4 M1 Y2 c" `, s% C;; SERVER: 208.67.222.222#53(208.67.222.222)
: z! x! w$ `* ~% E;; WHEN: Mon Dec 7 23:29:01 20090 s y, B. @( b* V$ j& n" r5 t
;; MSG SIZE rcvd: 101, y; W2 T5 _3 z
/ x: Z) m( c1 P1 t' r* }
3.最重要的问题,访问网站真的快吗?
2 ?; s' D8 L; G2 U3 C* i* f( ~
V5 L! X9 b! l! i9 ~2 L4 c R相信不少人一定记得之前QQ用户出现过一次“免费出国”,当然,现在这个情况也会出现在用了OpenDNS和Google Public DNS用户的身上。
4 z l' ~$ w: p6 }1 O
9 }7 n" E8 @) d7 z6 ]) T大家都知道中国特色的互联网,南北分家,互访速度巨慢无比,网站的维护人员绞尽脑汁的想办法解决互联互通的问题,加速大家的网站访问速度。* ~+ O. |5 L7 q0 W# D4 V- [
1 ?7 _: X7 k+ j$ I
网站加速访问有好几种办法,有钱的大公司就用BGP AnyCast,但并不是人人都做得起(有自己的IP段,做一次BGP广播X-XX万,要达到最佳访问效果必须要做N次BGP广播,最后费用有可能达到 XXX万)。没钱的公司就只能用智能DNS了,包括自建的DNS,或者直接用DNSPod这样的现成方案,其实原理都一样。2 W! Q; a2 l+ | X4 V4 g( r* w
1 W- S! R- d6 ^3 a7 T智能DNS其实并不是太智能,它靠的预先分配好几个区域,然后根据用户请求的IP来判断用户属于哪个区域,之后返回对应区域的服务器IP。正常情况下,用户在国内上网,用的是ISP自动分配的DNS,用户域名解析请求发给ISP的DNS,ISP的DNS又发给DNSPod这样的域名授权DNS。 DNSPod这时候拿到的IP地址基本是ISP的DNS地址,所以很方便的就能判断出用户所在的区域,并把结果返回给用户。4 D* a# | w. |4 ^7 L' `" C1 A
' o" O- ?& P4 _6 O! a0 d+ L& s8 m但如果这个时候,用户用的是OpenDNS或者Google Public DNS,因为这些服务器的IP地址是在国外,并且N多老外都在用,智能DNS就不好判断该怎么返回了。返回国外的IP,影响国内用户的访问速度。; k! M- y7 w! A" Y
# a! ?4 N7 [5 h% G如果返回国内的IP,影响到其他老外的访问速度。并且如果返回国内的IP,那么该到底返回电信还是网通的IP呢?用户属于哪个省份?无从判断。那么最后只能人多决定人少,返回国外的服务器IP。
: T' g0 T; X: W" x
K5 n h5 S6 a5 l返回国外IP的结果是,用户被指向网站在国外的服务器,访问网站巨慢。* ^$ B" x; l& U! u8 T% L
$ d0 l: `) b3 x; ^5 a @本来想找几个典型例子的,但找了一圈回来,发现国内的大公司在这上面烧钱可是一点都不心痛,全部是BGP。要么就是不搭理国外用户,没针对国外用户单独进行解析,一概解析到电信的服务器去。, r/ g) J: U M) q
# q4 l7 X* ]3 v
拿Google来当例子吧。我是网通用户,使用网通自带的DNS,解析www.google.com得到以下结果
7 X3 j) K9 h9 _0 B6 I$ x. ^# C# d5 u" m0 O4 `9 ?, c
Sam@Bra:~$ dig http://www.google.com
p, j; c: M Z7 t! ]......) u8 o# O, ]8 t* @$ Z
;; ANSWER SECTION:5 x$ w, t |; ^3 j$ N) a
http://www.google.com. 48102 IN CNAME http://www.l.google.com.
; i+ U g- h3 x9 g D+ `8 fhttp://www.l.google.com. 300 IN A 216.239.61.104' T6 {! w4 @, M- K0 q7 }% m3 g1 E
) o; x. U& u& R; s, ^如果我用了OpenDNS的话,那么我得到下面的结果8 `: v" z, g) j$ B
+ G) m* m* x) Y' g% ?, D- w
Sam@Bra:~$ dig @208.67.222.222 http://www.google.com+ v) g S& ] S F+ l4 \
......2 l! G3 ?& U8 c1 M7 {, k0 L3 [
;; ANSWER SECTION:
! E) P. S7 {. l& \- Y" \http://www.google.com. 30 IN CNAME google.navigation.opendns.com.
/ ?9 I" y3 }; ?* I$ T9 Egoogle.navigation.opendns.com. 30 IN A 208.67.219.2303 ` {4 d# v% a' A
google.navigation.opendns.com. 30 IN A 208.67.219.231# @9 o- b* F8 a
- |- a% {5 Q9 \' c$ l! X0 N7 Jping一下得出的IP地址,看看速度,其实并不快
1 q. q4 k9 G% W9 v6 M$ W! g
" X! Z/ ~, h$ b" }+ j$ j; |Sam@Bra:~$ ping 208.67.219.230 PING 208.67.219.230 (208.67.219.230): 56 data bytes& ^# a+ Y9 z. c% I4 X" Z& p7 D
64 bytes from 208.67.219.230: icmp_seq=0 ttl=51 time=213.828 ms( ~* a) b* B: b" U" M
64 bytes from 208.67.219.230: icmp_seq=1 ttl=51 time=213.779 ms& d4 B7 r+ u/ w( [1 C+ n
64 bytes from 208.67.219.230: icmp_seq=2 ttl=51 time=214.716 ms
; V5 _+ d6 n6 N$ @( x^C
# h" g. [& ?( Z5 G9 S$ Q) G6 @! l--- 208.67.219.230 ping statistics ---
# k& v4 V" z& d& ^$ W! v6 I" E3 packets transmitted, 3 packets received, 0.0% packet loss
9 J/ R) D' M$ L3 \% Zround-trip min/avg/max/stddev = 213.779/214.108/214.716/0.431 ms
* @( h8 R$ ?; N. i
( u0 s- p R0 `1 _我们可以再看看kaixin001.com的,如果我是网通用户,用了OpenDNS或者Google Public DNS,那么我会被解析到kaixin001的电信IP去。当然,kaixin001的电信机房线路很好,网通用户访问其实影响不大。- o0 U6 X1 Z$ x. ?
* P1 d7 q6 ?' W4 k+ U4 c我网通DNS直接解析
$ f4 ]" |% ^; l# |+ x/ K1 ?* C6 b0 r
Sam@Bra:~$ dig kaixin001.com
$ T0 q/ F- M! l......* A6 T2 Q J* t' Q- R- r7 g0 ^: {: x
;; ANSWER SECTION:: F3 `- D9 K8 }/ F& S
kaixin001.com. 120 IN A 220.181.100.31: ]+ W* H2 G2 ^$ v" P4 S* k
kaixin001.com. 120 IN A 220.181.100.32
/ Q) J7 p0 N3 k: h) }' A9 Ckaixin001.com. 120 IN A 220.181.100.33" V% A' O: T k* A. R3 r! [
kaixin001.com. 120 IN A 220.181.100.34. s' \. O' b& q' B' b" F; U* w
kaixin001.com. 120 IN A 220.181.100.35% \" G' Y3 ]+ n6 M# y+ n! [. e( k
kaixin001.com. 120 IN A 220.181.100.302 a% r5 @4 w: R q; B
: t# Z1 u4 d8 `6 G7 Q. M* D如果我换用了OpenDNS,我得到的是kaixin001在电信服务器的IP9 R# _8 W( e+ ?3 j3 v
' | Z* l; [* B% @9 m
Sam@Bra:~$ dig @208.67.222.222 kaixin001.com ......
% C0 Q5 r. a& D6 V( I" C;; ANSWER SECTION:
/ ]5 Y {7 C: v5 o$ K; Xkaixin001.com. 60 IN A 123.125.58.247
3 G' {% R4 A& f l. Rkaixin001.com. 60 IN A 123.125.56.246
! a9 `! J& o$ G+ ~kaixin001.com. 60 IN A 123.125.56.247
, u4 C, d2 X9 a& @/ K6 z7 {0 |: @! [kaixin001.com. 60 IN A 123.125.56.245: F: ?# [0 U" k5 e+ d/ ]- a: t! X+ Q
kaixin001.com. 60 IN A 123.125.56.248
/ g1 ^6 T( ~* T8 n3 {' J" Ekaixin001.com. 60 IN A 123.125.59.20
+ y, L$ n1 |% z6 p ~kaixin001.com. 60 IN A 123.125.59.16
/ X; _% o4 j% z' Wkaixin001.com. 60 IN A 123.125.58.248
9 k% G# N5 p' p e1 tkaixin001.com. 60 IN A 123.125.58.246
/ s9 A+ l# b$ {+ v, Kkaixin001.com. 60 IN A 123.125.58.245 M$ M' {( u- f7 {
' J. ]0 B9 u" C/ g( e( `中小网站就没这么幸运了。中小网站没有太多的钱去买昂贵的BGP线路,只能用很低廉的智能DNS方案,比如我们经常去找字幕的射手网: V( T& `" B# R& u- d
1 z$ A" C5 e+ f# h5 ]; l7 g
网通直接查询,可以得到网通服务器的IP
8 x, B! h. P7 J% ]7 o% V% ~
+ p, r/ C8 a" r- ]Sam@Bra:~$ dig shooter.cn ......* c- C' ] g6 H) w
;; ANSWER SECTION:
- O. v* ~8 Z% g* B7 ^% \+ \shooter.cn. 800 IN A 218.21.130.429 w( x, a: ?# t k& J
1 y7 l' _; |5 B0 T- z3 U网通套用OpenDNS进行查询,得到的是射手在国外服务器的IP
2 m4 X3 E) t2 U" l
6 c0 y2 T) @& J4 E3 ^$ p d. USam@Bra:~$ dig @208.67.222.222 shooter.cn ......& }5 ?/ P2 e3 K P! A, D- r
;; ANSWER SECTION:
% p% _' |3 m; i% u/ @shooter.cn. 750 IN A 74.207.252.170( L" `1 O& Y+ i% U. {
; n! b; W7 C# B$ U" T) w5 V: Y9 b
这样,你就“被出国”了。用了OpenDNS或者Google Public DNS后,你访问的将是一个速度并不快的射手网。6 Y H8 q1 g: J2 W( x* g1 W2 u: N
6 k' k. D8 o& x; d3 }国内类似射手网这样的中小网站有几十万甚至上百万,不少游戏运营商也采用这样的方案。虽然他们不一定有国外的服务器,但如果你被解析到并不属于自己网络的服务器上,访问速度或多或少都会受到影响。所以,如果你最近访问网站速度有所下降,或者玩游戏的时候经常掉线,那么你就该把DNS给换回来了。 |