当前位置:网站首页>交换机和路由器技术-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地址的某个端口。形成的是一个·永久性对应关系。但是只能实现外网访问内网服务器,不能实现内网访问外网,访问外网时,映射的端口是随机的。
边栏推荐
- 优先级队列
- MySQL database storage engine and database creation, modification and deletion
- 如何给网页添加icon图标?
- .NET 服务注册
- [Server installation mysql] Use mysql offline installation package to install mysql5.7 under centos7
- Events and scheduled tasks in Mysql
- 堆排序 和冒泡排序
- Callable实现多线程
- Get Qt installation information: including installation directory and various macro addresses
- 《卫星界》刊评“星辰大海”计划:孙宇晨为太空旅游带来新的机遇
猜你喜欢
Three 】 【 yolov7 series of actual combat from 0 to build training data sets
findViewById返回null的问题
Which one to choose for mobile map development?
ALSA音频架构
Overview of the JVM garbage collection and mechanism
Jetson Orin平台4-16路 GMSL2/GSML1相机采集套件推荐
JVM 垃圾回收的概述与机制
「转」“搜索”的原理,架构,实现,实践,面试不用再怕了
快速使用UE4制作”大场景游戏“
ALSA音频架构 -- snd_pcm_open函数分析
随机推荐
c语言fprintf、fscanf、sscanf以及sprintf函数知识要点总结
0基础转行软件测试,自学3个月,浅拿12k*13薪offer
Apache初体验
Provincial level of Echart maps, as well as all prefecture-level download and use
【yolov7系列三】实战从0构建训练自己的数据集
堆排序 和冒泡排序
Add PRODUCT_BOOT_JARS and classes to provide jar packages to applications
Harvesting of radio frequency energy
CAN/以太网转换器 CAN与以太网互联互通
洛谷P1763 埃及分数
如何将360全景图导出高清短视频分享到视频平台上?
How to learn machine learning?machine learning process
Map中的getOrDefualt方法
"3 Longest Substring Without Repeating Characters" on the 17th day of LeetCode brushing
直播软件搭建,流式布局,支持单选、多选等
jwsManager服务接口实现类-jni实现
使用百度EasyDL实现森林火灾预警识别
"104 Maximum Depth of Binary Trees" in LeetCode's Day 12 Binary Tree Series
一种基于共识机制的数字集群终端防失控方案研究
简历里写了会代码,却依然过不了面试这一关