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

相关推荐
其实防守也摸鱼12 小时前
用 Claude Code 重构遗留系统:从评估到落地的完整指南
前端·网络·人工智能·chrome·安全·重构
优化Henry14 小时前
LTE 站点 S1 链路反复闪断导致小区频闪退服故障排查
运维·网络·学习·信息与通信·tdd
心之王者71614 小时前
Linux 进程信号:从产生、阻塞到捕捉与子进程回收
linux·服务器·网络
.痞老板.14 小时前
java ee--网络编程套接字
网络·java-ee·php
2401_8685347814 小时前
逻辑网络设计
网络·python
如夏倾城17 小时前
BGP(Border Gateway Protocol 边界网关协议)
运维·服务器·网络·gateway·信息与通信
小乖写代码20 小时前
帧协议(TCP) · TCP Framing
网络·网络协议·tcp/ip·tcp
如夏倾城2 天前
VRRP(虚拟路由器冗余协议Virtual Router Redundancy Protocol)
网络·python·网络协议·安全·智能路由器·负载均衡·信息与通信
张小姐的猫2 天前
【基于 WebSocket 的多用户网页五子棋】—— 认识第三方库Websocketpp
网络·websocket·网络协议
LightBreeze20022 天前
IS-IS 基本概念详解——报文类型、地址结构与网络拓扑
网络·lsp·路由协议·net·is-is