温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PAT端口多路复用(实践)

发布时间:2020-07-04 16:25:22 来源:网络 阅读:444 作者:caozhengtao1213 栏目:系统运维

拓扑结构图

PAT端口多路复用(实践)



第一步:配置交换机SW

sw#conf t
sw(config)#no ip routing            //关闭路由功能
sw(config)#int f1/0 
sw(config-if)#speed 100             //配置速率
sw(config-if)#dup full              //配置全双工模式
sw(config-if)#ex

第二步:配置路由器R1,并设定PAT

R1#conf t
R1(config)#int f0/0
R1(config-if)#ip add 192.168.100.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int f0/1
R1(config-if)#ip add 12.0.0.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#ex
R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255
//定义内部访问列表
R1(config)#ip nat inside source list 1 interface fastEthernet 0/1 overload 
//设置复用动态IP地址转换于外部接口
R1(config)#int f0/0
R1(config-if)#ip nat inside     
R1(config-if)#int f0/1
R1(config-if)#ip nat outside
R1(config-if)#end

第三步:配置客户机IP地址

PC1> ip 192.168.100.10 192.168.100.1
Checking for duplicate address...
PC1 : 192.168.100.10 255.255.255.0 gateway 192.168.100.1

PC2> ip 192.168.100.20 192.168.100.1
Checking for duplicate address...
PC1 : 192.168.100.20 255.255.255.0 gateway 192.168.100.1

PC3> ip 12.0.0.12 12.0.0.1
Checking for duplicate address...
PC1 : 12.0.0.12 255.255.255.0 gateway 12.0.0.1

第四步:测试全网互通,并使用debug 功能查看PAT过程

PC1> ping 12.0.0.12
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.242 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=46.864 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.280 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.241 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.241 ms

R1#debug ip nat
IP NAT debugging is on
R1#
*Mar  1 00:32:57.215: NAT*: s=192.168.100.10->12.0.0.1, d=12.0.0.12 [59174]
*Mar  1 00:32:57.219: NAT*: s=12.0.0.12, d=12.0.0.1->192.168.100.10 [59174]
...
//私网地址192.168.100.10已转换成功公网地址12.0.0.1,并接收到来自公网主机的回复信息

PC2> ping 12.0.0.12
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.242 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=31.245 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.244 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.213 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.246 ms

R1#
*Mar  1 00:35:15.595: NAT*: s=192.168.100.20->12.0.0.1, d=12.0.0.12 [59312]
*Mar  1 00:35:15.607: NAT*: s=12.0.0.12, d=12.0.0.1->192.168.100.20 [59312]
...
////私网地址192.168.100.20已转换成功公网地址12.0.0.1,并接收到来自公网主机的回复信息

小结

内部地址 外部地址
内部局部地址 (端口) 内部全局地址(端口)
外部局部地址 外部全局地址(端口)

PAT存在的意义

1.动静态NAT无法解决ip地址匮乏问题 (默认一个私网IP地址对一个公网IP地址)
2.PAT却可以解决ip地址匮乏(多个私网IP地址对一个公网IP地址)

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI