【技术分享】密码认证协议PAT怎么配置?

实验目的

  1. 理解PAT的转换原理

  2. 掌握PAT的配置方法

实验拓扑

实验需求

  1. 根据实验拓扑图,完成设备的基本配置;

  2. 在R2上创建Loopback0接口,IP地址是9.2.6.7/32,模拟公网上的一台服务器;

  3. 在R1上配置PAT,使得PC1和PC2能够复用E0/1接口地址访问公网服务器。

实验步骤

步骤1:设备的基本配置

配置P C1

复制代码
Router>enable
Router#configure terminal
Router(config)#hostname PC1
PC1(config)#no ip routing
PC1(config)#ip default-gateway 192.168.1.254
PC1(config)#interface ethernet0/0
PC1(config-if)#ip address 192.168.1.1 255.255.255.0
PC1(config-if)#no shutdown
PC1(config-if)#end
PC1#
复制代码

配置PC2:

复制代码
Router>enable
Router#configure terminal
Router(config)#hostname PC2
PC2(config)#no ip routing
PC2(config)#ip default-gateway 192.168.1.254
PC2(config)#interface ethernet0/0
PC2(config-if)#ip address 192.168.1.2 255.255.255.0
PC2(config-if)#no shutdown
PC2(config-if)#end
PC2#

配置SW 1

复制代码
Switch>ena
Switch#conf t
Switch(config)#no ip domain-lookup
Switch(config)#line console 0
Switch(config-line)# logging s
Switch(config-line)# exec-t 0 0
Switch(config-line)# exit
Switch(config)#hostname SW1
SW1(config)#end
SW1#

配置R1:

复制代码
Router>enable
Router#configure terminal
Router(config)#hostname R1
R1(config)#no ip domain-lookup
R1(config)#line console 0
R1(config-line)#exec-timeout 0 0
R1(config-line)#logging synchronous
R1(config-line)#exit
R1(config)#interface ethernet0/0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface ethernet0/1
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#end
R1#

配置R2:

复制代码
Router>enable
Router#configure terminal
Router(config)#hostname R2
R2(config)#no ip domain-lookup
R2(config)#line console 0
R2(config-line)#exec-timeout 0 0
R2(config-line)#logging synchronous
R2(config-line)#exit
R2(config)#interface loopback0
R2(config-if)#ip address 9.2.6.7 255.255.255.255
R2(config-if)#exit
R2(config)#interface ethernet0/0
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#end
R2#

步骤2:配置P AT

配置R 1

复制代码
R1(config)#access-list 1 permit 192.168.1.0 0.0.0.255   //定义ACL
R1(config)#ip nat inside source list 1 interface ethernet 0/1 overload   //关联ACL和outside接口
R1(config)#interface ethernet 0/0
R1(config-if)#ip nat inside   //指定inside接口
R1(config-if)#exit
R1(config)#interface ethernet 0/1
R1(config-if)#ip nat outside   //指定outside接口
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.2   //配置到达公网的默认路由测试

P C1 访问服务器:

复制代码
PC1#ping 9.2.6.7
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 9.2.6.7, timeout is2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 1/1/1 ms

测试P C2 访问服务器:

复制代码
PC2#ping 9.2.6.7
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 9.2.6.7, timeout is2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
复制代码

检查R1的NAT表项:

复制代码
R1#showipnattranslations
ProInsideglobalInsidelocalOutsidelocalOutsideglobal
icmp 12.1.1.1:7        192.168.1.1:7      9.2.6.7:7          9.2.6.7:7
icmp 12.1.1.1:5        192.168.1.2:5      9.2.6.7:5          9.2.6.7:5
Insideglobal都是12.1.1.1,通过端口号区分不同的主机。

--- 年度热文 ---

新生代网工必看:华为模拟器eNSP安装教程(附下载链接)

【超详细】思科模拟器EVE的安装与使用,附下载链接

2025年IT行业哪些认证值得考

收藏!超详细的Oracle 19c安装步骤!

超强linux学习笔记,值得一看(附PDF下载)

DeepSeek 的组网方案介绍

《鸟哥Linux私房菜》全新完整中文版PDF

相关推荐
DianSan_ERP2 天前
电商API接口全链路监控:构建坚不可摧的线上运维防线
大数据·运维·网络·人工智能·git·servlet
呉師傅2 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
2501_946205523 天前
晶圆机器人双臂怎么选型?适配2-12寸晶圆的末端效应器有哪些?
服务器·网络·机器人
linux kernel3 天前
第七部分:高级IO
服务器·网络
数字护盾(和中)3 天前
BAS+ATT&CK:企业主动防御的黄金组合
服务器·网络·数据库
~远在太平洋~3 天前
Debian系统如何删除多余的kernel
linux·网络·debian
unfeeling_3 天前
Keepalived实验
linux·服务器·网络
坐吃山猪3 天前
OpenClaw04_Gateway常见问题
网络·gateway·openclaw
上海云盾商务经理杨杨3 天前
2025年重大网络安全事件回顾与趋势分析
网络·安全·web安全
kylezhao20193 天前
C# 的开闭原则(OCP)在工控上位机开发中的具体应用
网络·c#·开闭原则