千家信息网

NAT静态和端口映射配置实验

发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,一、静态NAT配置图1、配置主机地址:PC1> ip 192.168.100.10 192.168.100.1Checking for duplicate address...PC1 : 192.16
千家信息网最后更新 2025年02月02日NAT静态和端口映射配置实验

一、静态NAT配置图


1、配置主机地址:

PC1> ip 192.168.100.10 192.168.100.1Checking for duplicate address...PC1 : 192.168.100.10 255.255.255.0 gateway 192.168.100.1PC2> ip 192.168.100.20 192.168.100.1Checking for duplicate address...PC1 : 192.168.100.20 255.255.255.0 gateway 192.168.100.1PC3> ip 12.0.0.12 12.0.0.1Checking for duplicate address...PC1 : 13.0.0.13 255.255.255.0 gateway 13.0.0.1

2、配置R1路由

R1#conf tR1(config)#int f0/0R1(config-if)#ip add 192.168.100.1 255.255.255.0R1(config-if)#no shutR1(config)#int f0/1R1(config-if)#ip add 12.0.0.1 255.255.255.0R1(config-if)#no shut

3、关闭sw路由功能

no  ip  routing

4、配置主机地址

PC1> ip  192.168.100.10  192.168.100.1Checking for duplicate address...PC1 : 192.168.100.10 255.255.255.0 gateway 192.168.100.1PC2> ip  192.168.100.20  192.168.100.1Checking for duplicate address...PC1 : 192.168.100.20 255.255.255.0 gateway 192.168.100.1PC3> ip  12.0.0.12  12.0.0.1Checking for duplicate address...PC1 : 12.0.0.12 255.255.255.0 gateway 12.0.0.1

5、互联互通测试

PC1> ping 192.168.100.2084 bytes from 192.168.100.20 icmp_seq=1 ttl=64 time=0.000 ms84 bytes from 192.168.100.20 icmp_seq=2 ttl=64 time=0.000 ms84 bytes from 192.168.100.20 icmp_seq=3 ttl=64 time=0.000 ms84 bytes from 192.168.100.20 icmp_seq=4 ttl=64 time=0.000 ms84 bytes from 192.168.100.20 icmp_seq=5 ttl=64 time=0.000 msPC1> ping 12.0.0.12     13.0.0.13 icmp_seq=1 timeout13.0.0.13 icmp_seq=2 timeout84 bytes from 12.0.0.12 icmp_seq=3 ttl=62 time=62.485 ms84 bytes from 12.0.0.12 icmp_seq=4 ttl=62 time=69.039 ms84 bytes from 12.0.0.12 icmp_seq=5 ttl=62 time=69.046 ms

6、配置静态NAT列表

R1(config)#ip nat inside source static 192.168.100.10 12.0.0.10R1(config)#ip nat inside source static 192.168.100.20 12.0.0.20R1(config)#int f0/0R1(config-if)#ip nat insideR1(config-if)#int f0/1R1(config-if)#ip nat outsideR1(config-if)#endR1#debug ip nat     IP NAT debugging is on

7、测试连通性

PC1> ping 12.0.0.1213.0.0.13 icmp_seq=1 timeout13.0.0.13 icmp_seq=2 timeout84 bytes from 12.0.0.12 icmp_seq=3 ttl=62 time=84.698 ms84 bytes from 12.0.0.12 icmp_seq=4 ttl=62 time=85.265 ms84 bytes from 12.0.0.12 icmp_seq=5 ttl=62 time=69.205 ms*Mar  1 00:23:50.619: NAT*: s=192.168.100.10 -> 12.0.0.10,d=12.0.0.12[5464]*Mar  1 00:23:51.831: NAT*: s=192.168.100.10->12.0.0.10, d=12.0.0.12 [5465]  #将目标地址12.0.0.10转换成192.168.100.10,这个就是静态地址转换的过程

二、NAT静态端口映射配置

1、实验环境
Linux搭建的一台Web服务器,局域网地址为192.168.100.100,默认端口号80。局域网的网关192.168.100.1,映射地址:192.168.100.100:80->12.0.0.100:8080。
别人只能看到公网IP地址,私网地址不能被直接访问。
2、实验目的
广域网的客户机无法直接访问100.100地址,如果想访问的话就需要做端口映射。
3、实验图

4、在Linux中安装httpd的服务软件包,并开启httpd服务,写测试网页等

[root@localhost ~]# yum install httpd -y[root@localhost ~]# vim /var/www/html/index.html        //写测试网页

this is inside web

[root@localhost ~]# systemctl start httpd[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0

5、配置网关地址

R1#conf t R1(config)#int f0/0R1(config-if)#ip add 192.168.100.1 255.255.255.0R1(config-if)#no shutR1(config-if)#exR1(config)#int f0/1  R1(config-if)#ip add 12.0.0.1 255.255.255.0R1(config-if)#no shutR1(config-if)#ex

6、通过centos中的浏览器可看到测试页面(ping 192.168.100.100或127.0.0.1都行)

7、给Linux绑定VMnet1网卡,给Host绑定VMnet2网卡,配置静态地址
8、访问对方192.168.100.100,此时是可以访问的,但是真实情况下是无法直接访问对方私有地址的


9、静态端口映射配置

R1(config)# ip  nat  inside  source  static  tcp  192.168.100.100  80  12.0.0.100  8080  extendable R1(config)#int f0/0R1(config-if)#ip nat insideR1(config-if)#int f0/1R1(config-if)#ip nat outsidR1(config-if)#endR1#debug ip natIP NAT debugging is on*Mar  1 00:36:59.327: NAT*: TCP s=49160, d=8080->80*Mar  1 00:36:59.327: NAT*: s=12.0.0.12, d=12.0.0.100->192.168.100.100 [364]   # 端口和地址都进行了转换

10、再次尝试使用公网地址在win7进行访问,此时可以成功,实验成功!

地址 配置 静态 测试 端口 实验 服务 成功 主机 对方 局域 局域网 网关 网卡 网页 路由 公网 再次 功能 口号 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 怎样复制下拉菜单的数据库 计算机网络技术强的大专 顺安利网络技术有限公司 系统软件开发公司称呼 天水懒淘网络技术有限公司 数据库中连接运算例题分析 湖南优旅通网络技术有限公司 应用商场哪些服务器可以搜索答案 网络安全法侵犯公民 热部署什么时候需要重启服务器 数据库设计与实践架构 关于网络安全的政策支持 网络技术总监不能开视频吗 魔力象限网络安全2020 数据库 ftp 长期在北京从事软件开发 众成科技共享是什么互联网公司 全国网络安全周 成都 经典日漫小伙子是个软件开发师 配置数据库还原数据库 蚂蚁笔记服务器部署 软件开发兴趣 网络安全信息课程介绍 国内免费vps服务器 远程服务器返回错误417 软件开发设计什么时候发展的 网络安全公众号漫画 服务器共享文件如何添加密码 企业服务器软件慢是什么原因 热血江湖有哪些服务器
0