免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: Bsdder
打印 上一主题 下一主题

如何使一个域名在内网和外网访问时分别指向内网和外网IP? [复制链接]

论坛徽章:
0
11 [报告]
发表于 2008-04-11 12:59 |只看该作者
你的路由应该是H3C SR8802。
升级到一个比较新的COMWARE版本应该就有nat dns-map命令了。

论坛徽章:
0
12 [报告]
发表于 2008-04-11 13:06 |只看该作者
是的, H3C SR8802, 我去看看新版的comware

论坛徽章:
0
13 [报告]
发表于 2008-04-11 18:06 |只看该作者
今天进行了DNS sniffer, 发现dns respond 包, 从内网取得和从外网取得的不一样, 内网取得的在以下红色标记后的都没了.


  1. 从内网执行nslookup 取得的query response 包:

  2. No.     Time        Source                Destination           Protocol Info
  3.       4 0.042612    202.103.224.68        192.168.1.210        DNS      Standard query response A 192.168.1.5[Malformed Packet]

  4. Frame 4 (175 bytes on wire, 175 bytes captured)
  5.     Arrival Time: Apr 11, 2008 16:40:31.797477000
  6.     [Time delta from previous captured frame: 0.020654000 seconds]
  7.     [Time delta from previous displayed frame: 0.020654000 seconds]
  8.     [Time since reference or first frame: 0.042612000 seconds]
  9.     Frame Number: 4
  10.     Frame Length: 175 bytes
  11.     Capture Length: 175 bytes
  12.     [Frame is marked: False]
  13.     [Protocols in frame: eth:ip:udp:dns]
  14.     [Coloring Rule Name: UDP]
  15.     [Coloring Rule String: udp]
  16. Ethernet II, Src: HuaweiTe_1c:55:2e (HuaweiTe_1c:55:2e), Dst: Dell_11:23:54  (00:15:c5:11:23:54)
  17.     Destination: Dell_11:23:54  (00:15:c5:11:23:54)
  18.         Address: Dell_11:23:54  (00:15:c5:11:23:54)
  19.         .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
  20.         .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
  21.     Source: HuaweiTe_1c:55:2e (HuaweiTe_1c:55:2e)
  22.         Address: HuaweiTe_1c:55:2e (HuaweiTe_1c:55:2e)
  23.         .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
  24.         .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
  25.     Type: IP (0x0800)
  26. Internet Protocol, Src: 202.103.224.68 (202.103.224.68), Dst: 192.168.1.210 (192.168.1.210)
  27.     Version: 4
  28.     Header length: 20 bytes
  29.     Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
  30.         0000 00.. = Differentiated Services Codepoint: Default (0x00)
  31.         .... ..0. = ECN-Capable Transport (ECT): 0
  32.         .... ...0 = ECN-CE: 0
  33.     Total Length: 161
  34.     Identification: 0x44bd (17597)
  35.     Flags: 0x04 (Don't Fragment)
  36.         0... = Reserved bit: Not set
  37.         .1.. = Don't fragment: Set
  38.         ..0. = More fragments: Not set
  39.     Fragment offset: 0
  40.     Time to live: 244
  41.     Protocol: UDP (0x11)
  42.     Header checksum: 0x07ac [correct]
  43.         [Good: True]
  44.         [Bad : False]
  45.     Source: 202.103.224.68 (202.103.224.68)
  46.     Destination: 192.168.1.210 (192.168.1.210)
  47. User Datagram Protocol, Src Port: domain (53), Dst Port: edm-mgr-sync (3464)
  48.     Source port: domain (53)
  49.     Destination port: edm-mgr-sync (3464)
  50.     Length: 141
  51.     Checksum: 0xa01e [correct]
  52.         [Good Checksum: True]
  53.         [Bad Checksum: False]
  54. Domain Name System (response)
  55.     [Request In: 3]
  56.     [Time: 0.020654000 seconds]
  57.     Transaction ID: 0x0002
  58.     Flags: 0x8180 (Standard query response, No error)
  59.         1... .... .... .... = Response: Message is a response
  60.         .000 0... .... .... = Opcode: Standard query (0)
  61.         .... .0.. .... .... = Authoritative: Server is not an authority for domain
  62.         .... ..0. .... .... = Truncated: Message is not truncated
  63.         .... ...1 .... .... = Recursion desired: Do query recursively
  64.         .... .... 1... .... = Recursion available: Server can do recursive queries
  65.         .... .... .0.. .... = Z: reserved (0)
  66.         .... .... ..0. .... = Answer authenticated: Answer/authority portion was not authenticated by the server
  67.         .... .... .... 0000 = Reply code: No error (0)
  68.     Questions: 1
  69.     Answer RRs: 1
  70.     Authority RRs: 2
  71.     Additional RRs: 2
  72.     Queries
  73.         [url]www.abc.com:[/url] type A, class IN
  74.             Name: [url]www.abc.com[/url]
  75.             Type: A (Host address)
  76.             Class: IN (0x0001)
  77.     Answers
  78.         [url]www.abc.com:[/url] type A, class IN, addr 192.168.1.5
  79.             Name: [url]www.abc.com[/url]
  80.             Type: A (Host address)
  81.             Class: IN (0x0001)
  82.             Time to live: 1 hour, 41 minutes, 46 seconds
  83.             Data length: 4
  84.             Addr: 192.168.1.5     <--------此处发现NAT已经把域名指向内网IP了, 但此后的数据就没了,
  85.     Authoritative nameservers
  86. [Malformed Packet: DNS]


  87. ADSL上网从外网取得的query response 包:

  88. No.     Time        Source                Destination           Protocol Info
  89.       7 2.962351    192.168.0.1           192.168.0.102         DNS      Standard query response A 202.104.55.18

  90. Frame 7 (175 bytes on wire, 175 bytes captured)
  91.     Arrival Time: Apr 11, 2008 16:37:41.408683000
  92.     [Time delta from previous captured frame: 0.718414000 seconds]
  93.     [Time delta from previous displayed frame: 0.718414000 seconds]
  94.     [Time since reference or first frame: 2.962351000 seconds]
  95.     Frame Number: 7
  96.     Frame Length: 175 bytes
  97.     Capture Length: 175 bytes
  98.     [Frame is marked: False]
  99.     [Protocols in frame: eth:ip:udp:dns]
  100.     [Coloring Rule Name: UDP]
  101.     [Coloring Rule String: udp]
  102. Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 80:00:60:0f:e8:00 (80:00:60:0f:e8:00)
  103.     Destination: 80:00:60:0f:e8:00 (80:00:60:0f:e8:00)
  104.         Address: 80:00:60:0f:e8:00 (80:00:60:0f:e8:00)
  105.         .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
  106.         .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
  107.     Source: 00:00:00_00:00:00 (00:00:00:00:00:00)
  108.         Address: 00:00:00_00:00:00 (00:00:00:00:00:00)
  109.         .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
  110.         .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
  111.     Type: IP (0x0800)
  112. Internet Protocol, Src: 192.168.0.1 (192.168.0.1), Dst: 192.168.0.102 (192.168.0.102)
  113.     Version: 4
  114.     Header length: 20 bytes
  115.     Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
  116.         0000 00.. = Differentiated Services Codepoint: Default (0x00)
  117.         .... ..0. = ECN-Capable Transport (ECT): 0
  118.         .... ...0 = ECN-CE: 0
  119.     Total Length: 161
  120.     Identification: 0x01ed (493)
  121.     Flags: 0x00
  122.         0... = Reserved bit: Not set
  123.         .0.. = Don't fragment: Not set
  124.         ..0. = More fragments: Not set
  125.     Fragment offset: 0
  126.     Time to live: 128
  127.     Protocol: UDP (0x11)
  128.     Header checksum: 0xb6a7 [correct]
  129.         [Good: True]
  130.         [Bad : False]
  131.     Source: 192.168.0.1 (192.168.0.1)
  132.     Destination: 192.168.0.102 (192.168.0.102)
  133. User Datagram Protocol, Src Port: domain (53), Dst Port: ndl-als (3431)
  134.     Source port: domain (53)
  135.     Destination port: ndl-als (3431)
  136.     Length: 141
  137.     Checksum: 0xb7ed [correct]
  138.         [Good Checksum: True]
  139.         [Bad Checksum: False]
  140. Domain Name System (response)
  141.     [Request In: 6]
  142.     [Time: 0.718414000 seconds]
  143.     Transaction ID: 0x0002
  144.     Flags: 0x8180 (Standard query response, No error)
  145.         1... .... .... .... = Response: Message is a response
  146.         .000 0... .... .... = Opcode: Standard query (0)
  147.         .... .0.. .... .... = Authoritative: Server is not an authority for domain
  148.         .... ..0. .... .... = Truncated: Message is not truncated
  149.         .... ...1 .... .... = Recursion desired: Do query recursively
  150.         .... .... 1... .... = Recursion available: Server can do recursive queries
  151.         .... .... .0.. .... = Z: reserved (0)
  152.         .... .... ..0. .... = Answer authenticated: Answer/authority portion was not authenticated by the server
  153.         .... .... .... 0000 = Reply code: No error (0)
  154.     Questions: 1
  155.     Answer RRs: 1
  156.     Authority RRs: 2
  157.     Additional RRs: 2
  158.     Queries
  159.         [url]www.abc.com:[/url] type A, class IN
  160.             Name: [url]www.abc.com[/url]
  161.             Type: A (Host address)
  162.             Class: IN (0x0001)
  163.     Answers
  164.         [url]www.abc.com:[/url] type A, class IN, addr 202.104.55.18
  165.             Name: [url]www.abc.com[/url]
  166.             Type: A (Host address)
  167.             Class: IN (0x0001)
  168.             Time to live: 3 hours
  169.             Data length: 4
  170.             Addr: 202.104.55.18          <----------------在外网访问, 把域名指向外网IP  
  171.     Authoritative nameservers
  172.         abc.com: type NS, class IN, ns ns.gxnnptt.net.cn
  173.             Name: abc.com
  174.             Type: NS (Authoritative name server)
  175.             Class: IN (0x0001)
  176.             Time to live: 2 hours, 43 minutes, 31 seconds
  177.             Data length: 13
  178.             Name server: ns.gxnnptt.net.cn
  179.         abc.com: type NS, class IN, ns ns.lzptt.gx.cn
  180.             Name: abc.com
  181.             Type: NS (Authoritative name server)
  182.             Class: IN (0x0001)
  183.             Time to live: 2 hours, 43 minutes, 31 seconds
  184.             Data length: 14
  185.             Name server: ns.lzptt.gx.cn
  186.     Additional records
  187.         ns.lzptt.gx.cn: type A, class IN, addr 202.103.225.70
  188.             Name: ns.lzptt.gx.cn
  189.             Type: A (Host address)
  190.             Class: IN (0x0001)
  191.             Time to live: 32 minutes, 42 seconds
  192.             Data length: 4
  193.             Addr: 202.103.225.70
  194.         ns.gxnnptt.net.cn: type A, class IN, addr 202.104.55.18
  195.             Name: ns.gxnnptt.net.cn
  196.             Type: A (Host address)
  197.             Class: IN (0x0001)
  198.             Time to live: 2 hours, 36 minutes, 21 seconds
  199.             Data length: 4
  200.             Addr: 202.104.55.18

复制代码

[ 本帖最后由 Bsdder 于 2008-4-12 12:23 编辑 ]

论坛徽章:
0
14 [报告]
发表于 2008-04-11 18:11 |只看该作者
估计内网用域名访问不了, 可能跟DNS 回应包的错误有关, 但引起该错误的原因在那里呢? 是在电信DNS SERVER, 还是在路由器进行NAT转换时产生的? 我觉得后者可能性更大, 由于我对DNS 和 PROTOCOL分析不熟悉, 那位知道的能解释下吗?

论坛徽章:
5
IT运维版块每日发帖之星
日期:2015-08-06 06:20:00IT运维版块每日发帖之星
日期:2015-08-10 06:20:00IT运维版块每日发帖之星
日期:2015-08-23 06:20:00IT运维版块每日发帖之星
日期:2015-08-24 06:20:00IT运维版块每日发帖之星
日期:2015-11-12 06:20:00
15 [报告]
发表于 2008-04-12 13:48 |只看该作者
LZ的情况我试验过了。DNS-MAP在H3C中好像不是这个功能用的。

发现在最新版本的VRP中,只要配置好了NAT server映射就自动有了DNS修正功能。

同时6楼的配置
nat dns-map www.abc.com 192.168.1.5 80 tcp
好像IP地址应该填外网的合法IP(全局外部IP),而不是内网映射后的IP。

论坛徽章:
0
16 [报告]
发表于 2008-04-12 14:23 |只看该作者
非常感谢你的试验!!!

原帖由 ssffzz1 于 2008-4-12 13:48 发表

发现在最新版本的VRP中,只要配置好了NAT server映射就自动有了DNS修正功能。
...


我感觉也应该是这样子, SR8802只做了nat server , nat outbound , 没有针对DNS进行过特殊设置, 但从昨天的sniffer 包中发现 , DNS 回应包中 SR8802已经把www.abc.com解析到服务器内部地址了. 但是估计由于转换时不正确, 导致DNS包中后面的数据错误了.

    Answers
        www.abc.com: type A, class IN, addr 192.168.1.5
            Name: www.abc.com
            Type: A (Host address)
            Class: IN (0x0001)
            Time to live: 1 hour, 41 minutes, 46 seconds
            Data length: 4
            Addr: 192.168.1.5     <--------此处发现NAT已经把域名指向内网IP了, 但此后的数据就没了,
    Authoritative nameservers
[Malformed Packet: DNS]

详见13楼

现在正折磨中,  ssffzz1兄, 你能看看是什么东西导致SR8802修改DNS包错误的吗?

[ 本帖最后由 Bsdder 于 2008-4-12 14:25 编辑 ]

论坛徽章:
5
IT运维版块每日发帖之星
日期:2015-08-06 06:20:00IT运维版块每日发帖之星
日期:2015-08-10 06:20:00IT运维版块每日发帖之星
日期:2015-08-23 06:20:00IT运维版块每日发帖之星
日期:2015-08-24 06:20:00IT运维版块每日发帖之星
日期:2015-11-12 06:20:00
17 [报告]
发表于 2008-04-12 15:05 |只看该作者
这个具体的不太清楚了。
1、你升级到最新版本的VRP。
2、如果通过路由器DNS-MAP不能解决,那么内网架自己的DNS,或者修改HOSTS文件。

论坛徽章:
0
18 [报告]
发表于 2008-04-12 20:22 |只看该作者

论坛徽章:
5
IT运维版块每日发帖之星
日期:2015-08-06 06:20:00IT运维版块每日发帖之星
日期:2015-08-10 06:20:00IT运维版块每日发帖之星
日期:2015-08-23 06:20:00IT运维版块每日发帖之星
日期:2015-08-24 06:20:00IT运维版块每日发帖之星
日期:2015-11-12 06:20:00
19 [报告]
发表于 2008-04-12 20:31 |只看该作者
您的登录已过期,需要重新登录

请刷新浏览器,以重新登录

没有H3C的用户,没用啊。把,内容转出来吧。


还有一个另外的方法,就是吧服务器和PC,放到不同的网段即可。

[ 本帖最后由 ssffzz1 于 2008-4-12 20:39 编辑 ]

论坛徽章:
0
20 [报告]
发表于 2008-04-12 20:52 |只看该作者
SR66系列路由器通过NAT实现

内网使用公网地址或域名访问内网服务器





一、组网需求:

内网用户通过路由器的NAT地址池转换来访问Internet,并且向外网用户提供www服务,同时客户要求实现

内网用户通过公网域名或地址访问内网服务器。

设备清单:SR66系列路由器1台,PC 1 台



二、组网图:


192.168.0.2/24 ---- [G0/0(192.168.0.1/24)-G0/1(202.100.1.2)] ---- OUTSIDE



三、配置步骤:

SR66 配置

#

//用户NAT的地址池

nat address-group 1 202.100.1.3 202.100.1.6

#

//配置允许进行NAT转换的内网地址段

acl number 2000

rule 0 permit source 192.168.0.0 0.0.0.255

rule 1 deny

#

//配置内网访问内网服务器的数据段

acl number 3010

description LAN-PC-->LAN-Server                                                

rule 0 permit ip source 192.168.0.0 0.0.0.255 destination 192.168.0.2 0         

#



interface GigabitEthernet0/0

port link-mode route

//在出接口上进行NAT转换

nat outbound 2000 address-group 1

//在出接口上配置内网服务器192.168.0.2的www服务

nat server protocol tcp global 202.100.1.3 www inside 192.168.0.2 www

ip address 202.100.1.2 255.255.255.0

#

interface GigabitEthernet0/1

port link-mode route

//内网网关

ip address 192.168.0.1 255.255.255.0

//对内网访问内网服务器的流量进行地址转换

nat outbound 3010

//在内网口上配置内网服务器192.168.0.2的www服务,使内网pc能够通过公网地址或域名访问

nat server protocol tcp global 202.100.1.3 www inside 192.168.0.2 www

ip address 202.100.1.2 255.255.255.0

#

//配置默认路由

ip route-static 0.0.0.0 0.0.0.0 202.100.1.1

#






四、配置关键点:

1)定义内网访问内网服务器的acl,在内网口配置内网访问内网服务器的nat转换

2) 在内网口需要配置内网服务器和外网地址的映射关系

[ 本帖最后由 puding 于 2008-4-12 20:54 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP