NAT 端口映射tcp
1. 實驗拓撲ide
使用GNS3模擬器版本 0.8.5spa
2.實驗需求3d
1實現R2路由器上的C2 可以經過NAT端口映射上公網router
2實現R1路由器上的C1可以經過NAT端口映射上公網blog
3.實驗配置:圖片
IP規劃ip
C1路由
C2get
R1(config)#int f0/0
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f
R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.10.1 255.255.255.0
R1(config-if)#no sh
R2#conf t
R2(config)#int f0/0
R2(config-if)#ip add 12.0.0.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
R2(config)#int f0/1
R2(config-if)#ip add 192.168.20.1 255.255.255.0
R2(config-if)#no sh
配置腳本
R1(config)#int f0/0
R1(config-if)#ip nat outside
R1(config-if)#int f0/1
R1(config-if)#ip nat inside
R1(config-if)#exit
R1(config)#ip nat inside source static tcp 192.168.10.100 80 12.0.0.1 8080 extendable 80 端口映射到8080端口
R2(config)#int f0/0
R2(config-if)#ip nat outside 配置外網口
R2(config-if)#int f0/1
R2(config-if)#ip nat inside 配置內網口
R2(config-if)#exit
R2(config)#ip nat inside source static tcp 192.168.20.100 80 12.0.0.2 80 extendable 80端口映射到80端口
R2(config)#ip nat inside source static tcp 192.168.20.100 25 12.0.0.2 25 extendable 25端口映射到25端口
R1(config)#router ospf 1 作OSPF動態路由
R1(config-router)#network 12.0.0.0 0.0.0.255 area 0
R1(config-router)#network 192.168.10.0 0.0.0.255 area 0
R1(config-router)#end
R2(config)#router ospf 1
R2(config-router)#network 12.0.0.0 0.0.0.255 area 0
R2(config-router)#network 192.168.20.0 0.0.0.255 area 0
R2(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.1
4.結果驗證:
映射成功 實驗結束