思科——NAT的應用

  • 今天初次接觸到NAT,瞭解不是特別全面,在學習的同時我也查閱了一些對應資料,接下來我就爲大家簡單說一下我對NAT的理解及應用,有什麼欠缺請大家及時指正。
  • NAT英文全稱是“Network Address Translation”,中文意思是“網絡地址轉換”, 它是一種把內部私有網絡地址解釋爲合法網絡IP地址的技術,所以在一定程度可以解決ip地址不夠用的問題。同時NAT分爲三種類型:靜態NAT、動態NAT、網絡地址端口轉換NAPT,今天我主要通過一個小實驗爲大家講解一下NAT三種類型中的靜態NAT。
    實驗名稱:配置靜態NAT實現內外網通信
    實驗拓撲:
    思科——NAT的應用
    如圖所示,現有一臺PC機,想要訪問到ISP的服務,該如何操做呢?
    實驗目的:使內網PC機可以訪問到ISP服務
    實驗步驟:
    1. 配置內外網設備的IP地址
      PC機:
      思科——NAT的應用

Gw:
Router>en
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname gw
gw(config)#interface fastEthernet 0/0
gw(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
ip ad
gw(config-if)#ip address 192.168.10.254 255.255.255.0
gw(config-if)#exit
gw(config)#interface fastEthernet 0/1
gw(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
gw(config-if)#ip address 100.1.1.1 255.255.255.0
gw(config-if)#exit
gw(config)#


SLP-1:
Router>EN
Router#CONFigure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router SLP-1 (config)#hostname SLP-1
SLP-1 (config)#interface fastEthernet 0/0
SLP-1 (config-if)#no shutdown

SLP-1 (config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
SLP-1 (config-if)#ip address 100.1.1.2 255.255.255.0
SLP-1 (config-if)#exit
SLP-1 (config)#interface fastEthernet 0/1
SLP-1 (config-if)#no shutdown

SLP-1 (config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
SLP-1 (config-if)#ip address 200.1.1.1 255.255.255.0
SLP-1 (config)#exit
SLP-1#


SLP-2:
Router>EN
Router#CONFigure
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router SLP-1 (config)#hostname SLP-2
SLP-2 (config)#interface fastEthernet 0/0
SLP-2 (config-if)#no shutdown

SLP-2 (config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
SLP-2 (config-if)#ip address 200.1.1.2 255.255.255.0
SLP-2 (config-if)#exit

  1. 配置網關設備上的默認路由
    gw(config)#ip route 0.0.0.0 0.0.0.0 100.1.1.2
    gw(config)#exit
    gw#
    %SYS-5-CONFIG_I: Configured from console by console
  2. 配置ISP邊的網絡(啓用IGP-RIP)
    SLP-1:
    SLP-1(config)#router rip \開啓rip
    SLP-1(config-router)#version 2\選擇rip版本2
    SLP-1(config-router)#no auto-summary \關閉自動彙總
    SLP-1(config-router)#passive-interface fastEthernet 0/0
    SLP-1(config-router)#network 100.1.1.0
    SLP-1(config-router)#network 200.1.1.0
    SLP-1(config-router)#exit
    SLP-1(config)#

SLP-2:
SLP-2(config)#router rip \開啓rip
SLP-2(config-router)#version 2\選擇rip版本2
SLP-2(config-router)#no auto-summary \關閉自動彙總
SLP-2(config-router)#network 200.1.1.0
SLP-2(config-router)#exit
SLP-2(config)#

  1. 在網關設備上配置NAT邊界
    Gw:
    gw(config)#interface fastEthernet 0/0
    gw(config-if)#ip nat inside \標記此爲NAT的內部端口
    gw(config-if)#exit
    gw(config)#interface fastEthernet 0/1
    gw(config-if)#ip nat outside \標記此爲NAT的外部端口
    gw(config-if)#exit
    gw(config)#
  2. 配置NAT轉換條目
    Gw:
    gw(config)#ip nat inside source static 192.168.10.1 100.1.1.1
    gw(config)#exit
    gw#
  3. 驗證、測試、保存
    Gw:

    show ip nat translation:
    思科——NAT的應用

    debug ip nat :
    思科——NAT的應用

    PC-1:
    ping 200.1.1.2
    思科——NAT的應用

Gw:

思科——NAT的應用
根據此圖可以看出,NAT將一個私有地址轉換爲公有地址,從而實現了訪問的服務。

今天就暫時先簡單說這些,關於NAT的其他類型會在後面爲大家呈現,請大家多多關注!!!!!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章