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

相关推荐
弓.长.1 天前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-network-info — 网络信息获取
网络·react native·harmonyos
GIS数据转换器1 天前
基于GIS的海上航路智能规划系统
网络·人工智能·安全·无人机·旅游
艾莉丝努力练剑1 天前
【Linux:文件 + 进程】进程间通信进阶(2)
linux·运维·服务器·开发语言·网络·c++·ubuntu
tang777891 天前
代理 IP 怎么用?五大主流浏览器设置代理ip教程(谷歌 / Edge / 百度 / 搜狗 / 360)
网络·网络协议·tcp/ip·edge
啊阿狸不会拉杆1 天前
《计算机网络-自顶向下方法》笔记分享:第1章-「计算机网络和因特网」-1.2 网络边缘
网络·笔记·计算机网络·接入网·光纤·网络边缘·物理媒体
志栋智能1 天前
安全超自动化的四大支柱:检测、分析、响应、恢复
运维·网络·人工智能·安全·web安全·自动化
长安11081 天前
网络基础知识----路由器私网IP与公网IP(NAT)
网络·tcp/ip·智能路由器
万象.1 天前
Linux数据链路层通信原理及报文格式
linux·网络·网络协议
victory04311 天前
Agent 面试知识树 + 高频追问答案库
网络·面试·职场和发展
Blurpath住宅代理2 天前
原生IP vs 广播IP:如何从网络层判断代理IP的“真实性”?
网络·静态ip·动态ip·代理·代理ip·住宅ip·住宅代理