【實驗名稱】
利用動態NAPT實現局域網訪問互聯網
【實驗目的】
掌握內網中所有的主機連接到Internet網時,通過端口號區分的複用內部全局地址轉換
【實驗功能】
允許內部所有主機在公網地址缺乏的情況下可以訪問外部網絡
【實驗設備】
實驗步驟】
路由器左邊 代表內網 右邊 代表外網! 二層交換機不給配置 純屬匯聚作用!
218.1.1.10 爲外網申請到的IP
外網PC2 IP:218.1.1.2 255.255.255.0
Router1
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.1.254 255.255.255.0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#interface fastEthernet 1/0
Router(config-if)#no shutdown
Router(config-if)#ip address 218.1.1.10 255.255.255.0
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255
Router(config)#ip nat inside source list 1 interface fastEthernet 1/0 overload
(不用創建地址池,直接借用F1/0的IP地址,F1/0獲取什麼地址就使用什麼地址。
這樣配置NAT超載就從5步驟變成4步驟,該方法同樣適用於靜態接入)
結果!
server1 ping外網主機
PC>ping 218.1.1.2
Pinging 218.1.1.2 with 32 bytes of data:
Reply from 218.1.1.2: bytes=32 time=78ms TTL=127
Reply from 218.1.1.2: bytes=32 time=94ms TTL=127
Reply from 218.1.1.2: bytes=32 time=78ms TTL=127
Reply from 218.1.1.2: bytes=32 time=93ms TTL=127
Ping statistics for 218.1.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 78ms, Maximum = 94ms, Average = 85ms
PC1 ping 外網主機
PC>ping 218.1.1.2
Pinging 218.1.1.2 with 32 bytes of data:
Reply from 218.1.1.2: bytes=32 time=141ms TTL=127
Reply from 218.1.1.2: bytes=32 time=79ms TTL=127
Reply from 218.1.1.2: bytes=32 time=94ms TTL=127
Reply from 218.1.1.2: bytes=32 time=93ms TTL=127
Ping statistics for 218.1.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 79ms, Maximum = 141ms, Average = 101ms
Router#show ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 218.1.1.10:10 192.168.1.1:10 218.1.1.2:10 218.1.1.2:10
icmp 218.1.1.10:11 192.168.1.1:11 218.1.1.2:11 218.1.1.2:11
icmp 218.1.1.10:12 192.168.1.1:12 218.1.1.2:12 218.1.1.2:12
icmp 218.1.1.10:1024 192.168.1.1:13 218.1.1.2:13 218.1.1.2:1024
icmp 218.1.1.10:13 192.168.1.2:13 218.1.1.2:13 218.1.1.2:13
icmp 218.1.1.10:14 192.168.1.2:14 218.1.1.2:14 218.1.1.2:14
原創:胡斌
我會從簡單到難的發表一些我學過的知識,希望能給一些想入門的朋友幫助,也希望找一些志同道合的朋友、老師 給我些指教。 QQ 276200261!