文章作者:姜南(Slyar) 文章来源:Slyar Home (www.slyar.com) 转载请注明,谢谢合作。
实验拓扑图如下,网段及IP地址不做多余介绍,配置模式及基本命令不做多余介绍
实验环境及实验目的:
0、每个网段上,左侧端口为F0/0,右侧端口为F0/1
1、3台路由器作为ISP路由器,丢弃一切私有IP地址,只路由公网IP地址。实验中只在路由器之间的网段上启用EIGRP路由协议
2、ISP给左边的公司/29大小的公网IP地址,由于左边公司内主机数量大于10K台,要求使用所有可用IP地址进行动态NAPT转换
3、ISP给右边公司/30大小的公网IP地址,即右侧公司只有1个可用公网IP地址,要求使用NAPT技术使得右边公司内主机可以上网,并且要求映射服务器的80端口到外部网络供其他人访问
主要实验过程:
1、配置各个设备的IP地址,保证各个设备的连通性,不说。
2、在3台路由器上启用EIGRP路由协议
ISP1:
router eigrp 100
network 100.100.100.0 0.0.0.7
no auto-summary
ISP2:
router eigrp 100
network 100.100.100.0 0.0.0.7
network 200.200.200.0 0.0.0.3
no auto-summary
ISP3:
router eigrp 100
network 200.200.200.0 0.0.0.3
no auto-summary
3、在ISP1上配置允许通过NAPT技术转换的主机范围
access-list 1 permit 192.168.1.0 0.0.0.255
4、在ISP1上配置可以进行转换的公网IP地址池,名字为cisco
ip nat pool cisco 100.100.100.3 100.100.100.6 netmask 255.255.255.248
/29为8个地址,刨去网络号和广播地址,以及线缆两端占用的2个地址,还剩4个可用地址
5、在ISP1上基于地址池配置NAPT
ip nat inside source list 1 pool cisco overload
overload表示端口多路复用
6、在ISP1的相应端口上启用NAT
interface FastEthernet0/0
ip nat outside
interface FastEthernet0/1
ip nat inside
至此左边公司内的主机即可通过NAPT技术访问外部网络了。
7、在ISP3上配置允许通过NAPT技术转换的主机范围
access-list 1 permit 172.16.1.0 0.0.0.255
8、在ISP3上基于单个IP地址(即单个接口)配置NAPT
ip nat inside source list 1 interface FastEthernet0/1 overload
9、在ISP3上使用静态绑定映射服务器的80端口
ip nat inside source static tcp 172.16.1.1 80 200.200.200.2 80
10、在ISP3的相应端口上启用NAT
interface FastEthernet0/0
ip nat inside
interface FastEthernet0/1
ip nat outside
至此右边公司内的主机即可通过NAPT技术访问外部网络了,并且外部主机访问ISP3的80端口时,数据包会自动转发到内部web服务器上。
实验效果:
使用PC0(192.168.1.1)访问右边公司的Web服务器(200.200.200.2)的80端口
ISP1:
IP NAT debugging is on
NAT: s=192.168.1.1->100.100.100.3, d=200.200.200.2 [19]
NAT*: s=200.200.200.2, d=100.100.100.3->192.168.1.1 [8]
NAT*: s=192.168.1.1->100.100.100.3, d=200.200.200.2 [20]
NAT*: s=192.168.1.1->100.100.100.3, d=200.200.200.2 [21]
NAT*: s=200.200.200.2, d=100.100.100.3->192.168.1.1 [9]
NAT*: s=192.168.1.1->100.100.100.3, d=200.200.200.2 [22]
NAT*: s=200.200.200.2, d=100.100.100.3->192.168.1.1 [10]
NAT*: s=192.168.1.1->100.100.100.3, d=200.200.200.2 [23]
Router#sh ip nat tra
Pro Inside global Inside local Outside local Outside global
tcp 100.100.100.3:1025 192.168.1.1:1025 200.200.200.2:80 200.200.200.2:80
tcp 100.100.100.3:1026 192.168.1.1:1026 200.200.200.2:80 200.200.200.2:80
tcp 100.100.100.3:1027 192.168.1.1:1027 200.200.200.2:80 200.200.200.2:80
ISP3:
IP NAT debugging is on
NAT: s=100.100.100.3, d=200.200.200.2->172.16.1.1 [19]
NAT*: s=172.16.1.1->200.200.200.2, d=100.100.100.3 [8]
NAT*: s=100.100.100.3, d=200.200.200.2->172.16.1.1 [20]
NAT*: s=100.100.100.3, d=200.200.200.2->172.16.1.1 [21]
NAT*: s=172.16.1.1->200.200.200.2, d=100.100.100.3 [9]
NAT*: s=100.100.100.3, d=200.200.200.2->172.16.1.1 [22]
NAT*: s=172.16.1.1->200.200.200.2, d=100.100.100.3 [10]
NAT*: s=100.100.100.3, d=200.200.200.2->172.16.1.1 [23]
Router#sh ip nat tra
Pro Inside global Inside local Outside local Outside global
tcp 200.200.200.2:80 172.16.1.1:80 --- ---
tcp 200.200.200.2:80 172.16.1.1:80 100.100.100.3:1025 100.100.100.3:1025
tcp 200.200.200.2:80 172.16.1.1:80 100.100.100.3:1026 100.100.100.3:1026
tcp 200.200.200.2:80 172.16.1.1:80 100.100.100.3:1027 100.100.100.3:1027
给出了debug信息及NAT转换表,过程应该很清晰了。还可以看到ISP3的NAT转换表中静态保存了服务器80端口与ISP3的映射关系。
