ROS Dst-Nat 後內網不能通過公網IP訪問內網伺服器解決方案

來源:互聯網
上載者:User

標籤:伺服器   互連網   使用者   


通常企業內部會有很多伺服器需要互連網使用者訪問,這時就需要做Dst-Nat. 但是我們配置完後會

發現內網使用者不能通過公網IP訪問對應的伺服器。其實這時我們再添加一條策略即可搞定.


執行個體說明:


內網伺服器:172.16.0.101  

路由器LAN口: 172.16.254.2

公網IP: 106.37.xxx.xxx      

 

外網訪問IP假設為 1.1.1.1    內網訪問的PC 假設IP為172.16.3.100


 

配置NAT:

 650) this.width=650;" title="1.png" alt="wKioL1U-BS3gbFH1AAGdi95P430438.jpg" src="http://s3.51cto.com/wyfs02/M02/6C/07/wKioL1U-BS3gbFH1AAGdi95P430438.jpg" width="597" height="371" />

650) this.width=650;" title="2.png" alt="wKiom1U-A93DNexbAAEC5bgxDx8333.jpg" src="http://s3.51cto.com/wyfs02/M02/6C/0B/wKiom1U-A93DNexbAAEC5bgxDx8333.jpg" width="598" height="338" />

 

配置完後,外網可以正常訪問了.但是內網通過公網IP不可訪問.

 

究其原因:

     外網訪問流程:  1. soureIP 1.1.1.1   destinationIP 106.37.xxx.xxx 

                                2. soureIP 1.1.1.1  destinationIP 172.16.0.101(dst-nat後)

                                3. soureIP 172.16.0.101     destinationIP  1.1.1.1

                                4. soureIP 106.37.xxx.xxx     destinationIP  1.1.1.1 (src-nat 後)

     這時,第一步驟和第四步驟請求和響應一致,因此沒有任何問題.

     但是當內網通過公網IP訪問內網伺服器時:

                                1.  soureIP 172.16.3.100   destinationIP 106.37.xxx.xxx 

                                2.  soureIP 172.16.3.100   destinationIP 172.16.0.101(dst-nat後)

                                3.  soureIP 172.16.0.101   destinationIP  172.16.3.100 

       在第三 步驟中, 因為伺服器和訪問的PC是在一個子網網路,因此伺服器響應包直接響應給客戶PC。 但是由於PC請求包的目的地址是  106.37.xxx.xxx ,而響應包的確是   172.16.0.101,所以

PC會決絕掉響應。 因此造成不能訪問的現象。

       在防火牆添NAT鏈中加一條如下策略,即可解決問題:

  

650) this.width=650;" style="float:none;" title="3.png" src="http://s3.51cto.com/wyfs02/M00/6C/07/wKioL1U-C-bjH1u_AAIsljZgsSc704.jpg" width="597" height="520" alt="wKioL1U-C-bjH1u_AAIsljZgsSc704.jpg" />

650) this.width=650;" style="float:none;" title="4.png" src="http://s3.51cto.com/wyfs02/M00/6C/0B/wKiom1U-CoLSy1l6AAB3YlBDQHo327.jpg" alt="wKiom1U-CoLSy1l6AAB3YlBDQHo327.jpg" />

 

添加之後內網的訪問流程如下:

                                1. soureIP 172.16.3.100  destinationIP 106.37.xxx.xxx 

                                2. soureIP 172.16.254.2  destinationIP 172.16.0.101

                                3. soureIP 172.16.0.101     destinationIP  172.16.254.2 

                                4. soureIP 106.37.xxx.xxx    destinationIP  172.16.3.100

     

 

問題解決。詳情請參考:http://wiki.mikrotik.com/wiki/Hairpin_NAT          




本文出自 “史振寧的技術部落格” 部落格,請務必保留此出處http://magic3.blog.51cto.com/1146917/1639383

ROS Dst-Nat 後內網不能通過公網IP訪問內網伺服器解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.