NAT动态网络地址转换(实践)
admin
2023-03-04 05:21:27
0

拓扑结构图

NAT动态网络地址转换(实践)



第一步:配置交换机SW

sw#conf t 
sw(config)#no ip routing        //关闭路由功能
sw(config)#int f1/0
sw(config-if)#speed 100         //配置速率  
sw(config-if)#dup full          //配置全双工模式

第二步:配置路由器R1,并设定NAT

1.配置路由器双臂路由

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

2.设定NAT地址转换

R1(config)#access-list 1 permit 192.168.100.0 0.0.0.255         //设定内部地址转化范围
R1(config)#ip nat pool test 12.0.0.10 12.0.0.100 netmask 255.255.255.0          ////设定外部地址转化范围
R1(config)#ip nat inside source list 1 pool test            //调用ip地址池
R1(config)#int f0/0
R1(config-if)#ip nat inside                 //将NAT应用于内部端口
R1(config-if)#int f0/1
R1(config-if)#ip nat outside                //将NAT应用于外部端口
R1(config-if)#end 

第三步:配置客户机ip地址

PC1> ip 192.168.100.10 192.168.100.1
Checking for duplicate address...
PC1 : 192.168.100.10 255.255.255.0 gateway 192.168.100.1

PC2> ip 192.168.100.20 192.168.100.1 
Checking for duplicate address...
PC1 : 192.168.100.20 255.255.255.0 gateway 192.168.100.1

PC3> ip 12.0.0.12 12.0.0.1
Checking for duplicate address...
PC1 : 12.0.0.12 255.255.255.0 gateway 12.0.0.1

第四步:测试全网互通性,并使用debug功能

1.测试互通性

PC1> ping 12.0.0.12
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=31.244 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=31.282 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=46.897 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=46.834 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.210 ms

PC2> ping 12.0.0.12
84 bytes from 12.0.0.12 icmp_seq=1 ttl=63 time=46.864 ms
84 bytes from 12.0.0.12 icmp_seq=2 ttl=63 time=46.864 ms
84 bytes from 12.0.0.12 icmp_seq=3 ttl=63 time=31.242 ms
84 bytes from 12.0.0.12 icmp_seq=4 ttl=63 time=31.273 ms
84 bytes from 12.0.0.12 icmp_seq=5 ttl=63 time=31.208 ms

2.debug功能查看地址转换过程

R1#debug ip nat
IP NAT debugging is on
R1#
*Mar  1 00:15:21.287: NAT*: s=192.168.100.10->12.0.0.10, d=12.0.0.12 [55463]
*Mar  1 00:15:21.295: NAT*: s=12.0.0.12, d=12.0.0.10->192.168.100.10 [55463]

//PC1 地址转换成功

R1#
*Mar  1 00:19:12.139: NAT*: s=192.168.100.20->12.0.0.11, d=12.0.0.12 [55693]
*Mar  1 00:19:12.159: NAT*: s=12.0.0.12, d=12.0.0.11->192.168.100.20 [55693]

//PC2 地址转换成功

相关内容

热门资讯

马斯克官宣:解散xAI! 最新官宣。 当地时间5月6日,埃隆・马斯克在社交平台X正式宣布,xAI将解散并停止作为独立公司运营,...
低端PC的革命来了!Windo... 快科技5月8日消息,Windows Latest对Win11正在内部测试的"低延迟配置"(Low L...
原创 新... ## 933图片插入失败: 'NoneType' object has no attribute '...
荣获“国机杯”卓越奖!安世亚太... 2026年4月30日,在第九届数字中国建设峰会期间,“国机杯”首届工业智能体大赛颁奖典礼于福州海峡国...
曝全球科技巨头争相投资SK海力... IT之家 5 月 8 日消息,据路透社今天报道,消息人士透露,全球各大科技公司争相向 SK 海力士抛...
中国人的AI焦虑,又领先了 《极限审判》 一场AI大辩论正在越演越烈,公众讨论AI的时候,显然已经呈现出了多个派别:降临派积极拥...
上海汇正财经服务费能退吗?看懂...   近期出现部分关于“上海汇正财经服务费能退吗”的讨论,一些投资者将关注点放在费用争议上,可能会忽略...
美军,突然“反击” 当地时间5月7日深夜至8日凌晨,霍尔木兹海峡再度成为世界最危险的水道。美军“特拉克斯顿”号、“佩拉尔...
古镇民宿贴出“艳遇秘诀”等标牌... 近日,网友称在云南丽江束河古镇发现一店铺门口挂出多块标语牌子:“艳遇秘诀,把自己灌醉,给别人机会”…...