当前位置:网站首页>交换机和路由器技术-35-NAT转PAT
交换机和路由器技术-35-NAT转PAT
2022-08-11 04:44:00 【w辣条小王子】
PAT:多对一转换
(端口多路复用)企业中最常用的方式。源地址转换、NAT代理上网
目的:
主要是将内网的多个地址转化为外网的一个IP地址,将端口一起进行转换,从而进行区分
例如:192.168.1.2:5252-6423.54.99:6625 根据端口区分是哪个地址在上网
将内网的多个地址,转为为路由器外网的接口地址

端口映射(服务器映射)
将内网的某一台服务器的某个服务(服务会使用到协议例如TCP 就会有端口),映射到外网的某个IP地址的某个端口,外网就可以访问内部服务器的服务
192.168.1.100:80----------23.34.56.100:80
注意点:
因为内网的端口标识了服务器的服务类型所以不能更改,映射出去的外网端口可以更改,但是会影响外网客户端访问时的端口号。如果映射的外网端口不是80,例如8088,这时外网客户机访问内网服务器时,访问的是映射出去的ip地址和端口号 8088 http://23.34.56.100:8088
解决内网服务器对外提供服务时使用。目的地址转换。
PAT实验
实验一:PAT之使用公网IP
搭建拓扑,划分网段,配置IP和网关,PC2只配IP

第一步:在路由器上定义内外网接口
Router(config)#int g0/0
Router(config-if)#ip nat inside
Router(config-if)#exit
Router(config)#int g0/1
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#
第二步:定义内网的范围使用的是标准ACL
Router(config)#access-list 11 permit any
第三步:定义外网(公网地址范围)
//外网只有一个ip地址,所有起始和结尾的ip一样
Router(config)#ip nat pool pat 23.34.56.80 23.34.56.80 netmask 255.255.255.0
第四步:应用:因为使用的是PAT,所有结尾添加overload 携带端口转换
Router(config)#ip nat inside source list 11 pool pat overload
所有主机都能ping通

查看NAT转换表

实验二:PAT之使用路由器接口公网地址
实验前先删除原来的配置
Router(config)#no ip nat inside source list 11 pool pat overload
Router(config)#no ip nat pool pat 23.34.56.80 23.34.56.80 netmask
第一步:定义内网范围
Router(config)#access-list 13 permit any
第二步:应用
Router(config)#ip nat ?
inside Inside address translation
outside Outside address translation
pool Define pool of addresses
Router(config)#ip nat inside ?
source Source address translation
Router(config)#ip nat inside source ?
list Specify access list describing local addresses
static Specify static local->global mapping
Router(config)#ip nat inside source list 13 ?
interface Specify interface for global address
pool Name pool of global addresses
Router(config)#ip nat inside source list 13 interface ?
Ethernet IEEE 802.3
FastEthernet FastEthernet IEEE 802.3
GigabitEthernet GigabitEthernet IEEE 802.3z
Serial Serial
//直接引用的路由器外网接口,不需要配置外网地址,直接引用
Router(config)#ip nat inside source list 13 interface g0/1 overload
Router(config)#
查看转换表
公网地址变为路由器g0/1接口的ip地址

端口映射
配置;
http协议是基于tcp的80端口
PC2想要访问内网服务器的web服务,那么通过流量来分析,它需要经过路由器g0/1口,那么将23.34.56.78的80端口映射到192.168.1.100的80端口

路由器配置命令
Router(config)#ip nat inside source ?
list Specify access list describing local addresses
static Specify static local->global mapping
Router(config)#ip nat inside source static ?
A.B.C.D Inside local IP address
tcp Transmission Control Protocol
udp User Datagram Protocol
Router(config)#ip nat inside source static tcp ?
A.B.C.D Inside local IP address
Router(config)#ip nat inside source static tcp 192.168.1.100 ?
<1-65535> Local UDP/TCP port
Router(config)#ip nat inside source static tcp 192.168.1.100 80 ?
A.B.C.D Inside global IP address
Router(config)#ip nat inside source static tcp 192.168.1.100 80 23.34.56.90 ?
<1-65535> Global UDP/TCP port
Router(config)#ip nat inside source static tcp 192.168.1.100 80 23.34.56.78 80
总结:
Router(config)#ip nat inside source static (协议tcp/udp)内网地址 端口号 外网地址 端口号
静态转换NAT 1对1 一个内网地址转换为一个外网地址,形成永久性对应关系,可以根据外网地址,定位到内网地址,可以实现内网访问外网,也可以实现外网访问内网。
动态转换NAT 多对多 一个内网地址转换为一个外网地址,形成永久性对应关系,当内网主机数量多余外网IP地址个数时,无法实现所有主机同时上网。动态对应关系,无法根据外网地址锁定内网地址,只能实现内网访问外网
端口多路复用PAT 多对一转换,又叫(源地址转换、NAT代理上网)内网多个IP地址转换为一个外网地址、(外网接口地址)使用不同的端口号进行区分,形成的也是动态对应关系,只能实现内网访问外网。
端口映射(服务器映射)目的地址转换
将内网的某一台服务器(服务器上的某个服务)映射到外网的某个IP地址的某个端口。形成的是一个·永久性对应关系。但是只能实现外网访问内网服务器,不能实现内网访问外网,访问外网时,映射的端口是随机的。
边栏推荐
- findViewById返回null的问题
- 使用百度EasyDL实现施工人员安全装备检测
- "3 Longest Substring Without Repeating Characters" on the 17th day of LeetCode brushing
- Solve the problem of multi-thread calling sql stored procedure
- Map中的getOrDefualt方法
- 一种基于共识机制的数字集群终端防失控方案研究
- Redis: Solve the problem of modifying the same key with distributed high concurrency
- 快速使用UE4制作”大场景游戏“
- How to add icons to web pages?
- Use jackson to parse json data in detail
猜你喜欢

"3 Longest Substring Without Repeating Characters" on the 17th day of LeetCode brushing

JVM 垃圾回收的概述与机制

Word2021 中的图片保存后就变模糊了

LeetCode814 Math Question Day 15 Binary Tree Series Value "814 Binary Tree Pruning"

The sword refers to offer_abstract modeling capabilities

Jetson Orin平台4-16路 GMSL2/GSML1相机采集套件推荐

What is machine learning?Explain machine learning concepts in detail

Harvesting of radio frequency energy

Where can machine learning be applied?What is machine learning useful for?

如何给网页添加icon图标?
随机推荐
Listen to pull out U disk inserted into the message, U disk drive
洛谷P4324 扭动的回文串
Australia cyberspace security system construction
Map中的getOrDefualt方法
剑指offer_抽象建模能力
JwsManager service interface implementation class - the jni implementation
Clang Code Model: Error: The clangbackend executable “X:/clangbackend.exe“ could not be started
Common layout effect realization scheme
.NET Custom Middleware
Events and scheduled tasks in Mysql
洛谷P4032 火锅盛宴
洛谷P5139 z小f的函数
WPF DataGrid 使用数据模板(2)
源代码加密技术浅析
「转」“搜索”的原理,架构,实现,实践,面试不用再怕了
蹭个热度-请勿打开
破解事务性工作瓶颈,君子签电子合同释放HR“源动力”!
What is machine learning?Explain machine learning concepts in detail
Introduction to c # a week of high-level programming c # - LINQ Day Four
Provincial level of Echart maps, as well as all prefecture-level download and use