设为首页 收藏本站
查看: 1580|回复: 0

[经验分享] 利用两种不同的NAT配置实现两个接口的双向静态NAT测试

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-6 08:40:09 | 显示全部楼层 |阅读模式
一.测试拓扑:
spacer.jpg wKiom1Xqu-fSJK1NAADmqScmYXY158.jpg
二.测试需求
1.ServerA已经配置静态一对一的地址实现从Interternet的访问
2.RouterA和RouterB为专线
3.需要ServerA访问ServerB的源地址映射为193.170.3.200

三.测试思路
1.利用nat和route-map实现按照需要进行NAT转换
---实际测试,不能满足要求
2.分2组nat,一组传统方式ip nat inside、ip nat outside,另一组为ip nat enable

四.基本配置
1.服务器ServerA:
interface Ethernet0/0
     ip address 172.16.10.200 255.255.255.0
     no shut
ip route 0.0.0.0 0.0.0.0 172.16.10.254
2.路由器RouterC:
interface Ethernet0/0
     ip address 172.16.10.254 255.255.255.0   
     no shut
interface Ethernet0/1
     ip address 10.1.1.2 255.255.255.0
     no shut
ip route 0.0.0.0 0.0.0.0 10.1.1.1
3.路由器RouterA:
interface Ethernet0/0
     ip address 202.100.1.1 255.255.255.0
     no shut  
interface Ethernet0/1
     ip address 192.169.2.105 255.255.255.0
     no shut  
interface Ethernet0/2
     ip address 10.1.1.1 255.255.255.0
     no shut  
ip route 0.0.0.0 0.0.0.0 202.100.1.2
ip route 172.16.10.0 255.255.255.0 10.1.1.2
ip route 192.168.92.0 255.255.255.0 192.169.2.106
interface Ethernet0/0
     ip nat outside
interface Ethernet0/2
     ip nat inside
ip access-list extended PAT
     deny   ip host 172.16.10.200 192.168.92.0 0.0.0.255
     permit ip 172.16.10.0 0.0.0.255 any
ip nat inside source list PAT interface Ethernet0/0 overload
ip nat inside source static 172.16.10.200 202.100.1.200
---验证:
ServerA#ping 202.100.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.100.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 60/75/108 ms
Internet#debug ip icmp
ICMP packet debugging is on
Internet#
*Mar  1 06:28:08.946: ICMP: echo reply sent, src 202.100.1.2, dst 202.100.1.200
Internet#
*Mar  1 06:28:10.942: ICMP: echo reply sent, src 202.100.1.2, dst 202.100.1.200
*Mar  1 06:28:11.038: ICMP: echo reply sent, src 202.100.1.2, dst 202.100.1.200
*Mar  1 06:28:11.138: ICMP: echo reply sent, src 202.100.1.2, dst 202.100.1.200
*Mar  1 06:28:11.198: ICMP: echo reply sent, src 202.100.1.2, dst 202.100.1.200

4.路由器Internet:
interface Ethernet0/0
     ip address 202.100.1.2 255.255.255.0
     no shut  
5.路由器RouterB:
interface Ethernet0/0
     ip address 192.169.2.106 255.255.255.0
     no shut  
interface Ethernet0/1
     ip address 192.168.92.254 255.255.255.0
     no shut  
ip route 172.16.10.0 255.255.255.0 192.169.2.105
五.NAT加route-map测试
A.路由器RouterA
1.定义ACL
ip access-list extended Inside
     permit ip host 172.16.10.200 host 192.168.92.64
ip access-list extended Outside
     permit ip host 172.16.10.200 any
2.配置route-map
route-map Inside permit 10
     match ip address Inside
route-map Outside permit 10
     match ip address Outside
3.删除原有的静态NAT
no ip nat inside source static 172.16.10.200 202.100.1.200
no ip nat inside source list PAT interface Ethernet0/0 overload
4.配置带 route-map的静态NAT
ip nat inside source static 172.16.10.200 202.100.1.200 route-map Outside
ip nat inside source static 172.16.10.200 193.170.3.200 route-map Inside
interface Ethernet0/1
     ip nat outside
B.路由器RouterB
ip route 193.170.3.0 255.255.255.0 192.169.2.105
C.测试:
ServerA#ping 202.100.1.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 202.100.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
ServerA#
Internet#
*Mar  1 06:59:10.862: ICMP: echo reply sent, src 202.100.1.2, dst 172.16.10.200
Internet#
*Mar  1 06:59:12.870: ICMP: echo reply sent, src 202.100.1.2, dst 172.16.10.200
Internet#
*Mar  1 06:59:14.890: ICMP: echo reply sent, src 202.100.1.2, dst 172.16.10.200
Internet#
*Mar  1 06:59:16.846: ICMP: echo reply sent, src 202.100.1.2, dst 172.16.10.200
Internet#
*Mar  1 06:59:18.846: ICMP: echo reply sent, src 202.100.1.2, dst 172.16.10.200
Internet#
ServerA#ping 192.168.92.64

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.92.64, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 84/121/160 ms
ServerA#
ServerB#debug ip icmp
ICMP packet debugging is on
ServerB#
*Mar  1 00:55:06.027: ICMP: echo reply sent, src 192.168.92.64, dst 172.16.10.200
*Mar  1 00:55:06.187: ICMP: echo reply sent, src 192.168.92.64, dst 172.16.10.200
*Mar  1 00:55:06.339: ICMP: echo reply sent, src 192.168.92.64, dst 172.16.10.200
*Mar  1 00:55:06.427: ICMP: echo reply sent, src 192.168.92.64, dst 172.16.10.200
*Mar  1 00:55:06.495: ICMP: echo reply sent, src 192.168.92.64, dst 172.16.10.200
ServerB#
-----出去的时候没有做源地址转换
Internet#telnet 202.100.1.200
Trying 202.100.1.200 ... Open


User Access Verification

Password:
ServerA>show users
    Line       User       Host(s)              Idle       Location
   0 con 0                idle                 00:00:49   
*130 vty 0                idle                 00:00:00 202.100.1.2

  Interface    User               Mode         Idle     Peer Address

ServerA>quit
ServerB#telnet 193.170.3.200
Trying 193.170.3.200 ... Open


User Access Verification

Password:
ServerA>show users
    Line       User       Host(s)              Idle       Location
   0 con 0                idle                 00:01:52   
*130 vty 0                idle                 00:00:00 192.168.92.64

  Interface    User               Mode         Idle     Peer Address

ServerA>quit
-----从外面进来时做聊目标地址转换

六.两种NAT配合使用测试
A.RouterA删除前面配置的nat并恢复原始配置中的NAT配置
no ip nat inside source static 172.16.10.200 202.100.1.200 route-map Outside
no ip nat inside source static 172.16.10.200 193.170.3.200 route-map Inside
interface Ethernet0/1
     no ip nat outside
no route-map Inside permit 10
no route-map Outside permit 10
no ip access-list extended Inside
no ip access-list extended Outside

ip nat inside source static 172.16.10.200 202.100.1.200
ip nat inside source list PAT interface Ethernet0/0 overload
B.RouterA配置ip nat enable
interface Ethernet0/2
     ip nat enable
interface Ethernet0/1
     ip nat enable
C.配置静态NAT:
ip nat source static 172.16.10.200 193.170.3.200
D.测试:
ServerA#ping 192.168.92.64

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.92.64, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
ServerA#
ServerB#
*Mar  1 01:18:22.823: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
*Mar  1 01:18:24.807: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
*Mar  1 01:18:26.819: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
*Mar  1 01:18:28.779: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
*Mar  1 01:18:30.779: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
Internet#
*Mar  1 07:24:07.350: ICMP: dst (193.170.3.200) host unreachable sent to 192.168.92.64
Internet#
*Mar  1 07:24:09.342: ICMP: dst (193.170.3.200) host unreachable sent to 192.168.92.64
Internet#
*Mar  1 07:24:11.334: ICMP: dst (193.170.3.200) host unreachable sent to 192.168.92.64
Internet#
*Mar  1 07:24:13.286: ICMP: dst (193.170.3.200) host unreachable sent to 192.168.92.64
Internet#
*Mar  1 07:24:15.314: ICMP: dst (193.170.3.200) host unreachable sent to 192.168.92.64
Internet#
----发现此时RouterA对回包没有做目标地址转换,把包丢给了Internet路由器
D.路由器RouterA增加secondary地址并测试:
interface Ethernet0/1
ip address 193.170.3.1 255.255.255.0 secondary
ServerA#ping 192.168.92.64

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.92.64, timeout is 2 seconds:
!.!.!
Success rate is 60 percent (3/5), round-trip min/avg/max = 128/153/168 ms
ServerB#
*Mar  1 01:31:28.219: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
*Mar  1 01:31:28.399: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
*Mar  1 01:31:30.379: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
*Mar  1 01:31:30.531: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
*Mar  1 01:31:32.515: ICMP: echo reply sent, src 192.168.92.64, dst 193.170.3.200
ServerB#
----通了,但是很有规律的丢包,并且比较严重
ServerA#ping 192.168.92.64 repeat 100

Type escape sequence to abort.
Sending 100, 100-byte ICMP Echos to 192.168.92.64, timeout is 2 seconds:
!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.
!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.
Success rate is 50 percent (50/100), round-trip min/avg/max = 56/128/204 ms

七.使用loopback口和两种NAT配合使用测试
---经过上面配置后,有50%的丢包,测试可能是e0/2同时配置了两种NAT,所以增加loopback口,取消原先e0/2的ip nat enable
A.路由器RouterA增加loopback0,配置ip nat enable
interface Loopback0
     ip address 1.1.1.1 255.255.255.252
     ip nat enable
B.路由器RouterA配置route-map并在e0/2接口应用
ip access-list extended ToServerB
     permit ip host 172.16.10.200 host 192.168.92.64
route-map ToServerB permit 10
     match ip address ToServerB
     set interface Loopback0
interface Ethernet0/2
     no  ip nat enable
     ip policy route-map ToServerB
C.经过上述配置后仍然还有50%的丢包,于是保存配置,重启RouterA,此时没有丢包
-----这时采用第六步的配置也是正常的,说明可能是模拟器的缘故导致


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-109893-1-1.html 上篇帖子: cisco 设备配置ACL访问控制列表 下篇帖子: 误删flash,利用xmodem给cisco3550交换机装系统 接口
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表