【技术分享】密码认证协议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

相关推荐
网络研究院9 天前
2026年网络安全
网络·安全·法律·法规·趋势·发展
酣大智9 天前
ARP代理--工作原理
运维·网络·arp·arp代理
treesforest9 天前
AI安全系统如何识别异常访问?IP风险识别正在成为关键能力
网络·人工智能·tcp/ip·安全·web安全
shushangyun_9 天前
2026年快消品B2B系统推荐:支持终端门店订货、促销政策自动化的工具?
java·运维·网络·数据库·人工智能·spring·自动化
2601_961845159 天前
粉笔行测题库|系统班|刷题
网络·百度·微信·微信公众平台·facebook·新浪微博
程序猿阿伟9 天前
《Chrome离线扩展安装的底层逻辑与场景落地指南》
服务器·网络·chrome
InHand云飞小白9 天前
无人值守站点网络困境?工业级路由器IR315破解连接难题
网络·物联网·4g·工业路由器·4g路由器·iiot·蜂窝路由器
森G9 天前
75、服务器源码解析---------云视频服务项目
linux·服务器·网络·c++·qt
江华森9 天前
TCP/IP 协议栈实战 — 7 个实验详解
网络·tcp/ip·智能路由器
酉鬼女又兒9 天前
零基础入门计算机网络运输层:端到端通信核心作用、端口号分类规则、复用分用工作机制及UDP与TCP协议全方位对比详解
网络·网络协议·tcp/ip·计算机网络·考研·udp·php