温馨提示:欢迎对技术感兴趣的新手朋友们,希望这些知识点能对大家有帮助。如果有什么不解或疑惑或建议,可留言小编或邮件2355331040@qq.com,我将尽快给予解决。感谢大家的支持和关注,谢谢!!!
学习目标
· 掌握动态NAT的配置方法
· 掌握Easy IP的配置方法
拓扑图
图7.2 NAT的配置实验拓扑图
场景
为了节省IP地址,通常企业内部使用的是私有地址。然而,企业用户不仅需要访问私网,也需要访问公网。作为企业的网络管理员,您需要在企业的边缘路由器R1上通过配置NAT功能,使私网用户可以访问公网。本实验中,您需要在R1上配置动态NAT和Easy IP,实现地址转换。
操作步骤
步骤一 实验环境准备
为了保证实验结果的准确性,确保设备以空配置启动。
配置R1
<Huawei>system-view
[Huawei]sysname R1
[R1]
配置SW1
<Huawei>system-view
[Huawei]sysname SW1
[SW1]
配置R2
<Huawei>system-view
[Huawei]sysname R2-Internet
[R2-Internet]
步骤二 配置IP地址
配置R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.1.1.254 24
[R1-GigabitEthernet0/0/0]undo shut
[R1-GigabitEthernet0/0/0]quit
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 200.1.1.1 24
[R1-GigabitEthernet0/0/1]undo shutdown
[R1-GigabitEthernet0/0/1]quit
[R1]
配置SW1
[SW1]interface Vlanif 1
[SW1-Vlanif1]ip address 10.1.1.100 255.255.255.0
[SW1-Vlanif1]quit
[SW1]ip route-static 0.0.0.0 0.0.0.0 10.1.1.254
[SW1]
配置PC的IP和网关
PC1的IP:10.1.1.1/24 网关:10.1.1.254
PC2的IP:10.1.1.2/24 网关:10.1.1.254
配置R2
[R2-Internet]interface GigabitEthernet 0/0/1
[R2-Internet-GigabitEthernet0/0/1]ip address 200.1.1.254 24
[R2-Internet-GigabitEthernet0/0/1]quit
[R2-Internet]interface LoopBack 0
测试连通性。
<R1>ping 10.1.1.1
PING 10.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=128 time=150 ms
Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=128 time=50 ms
Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=128 time=30 ms
Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=128 time=40 ms
Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=128 time=40 ms
<R1>ping 10.1.1.2
PING 10.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.2: bytes=56 Sequence=1 ttl=128 time=110 ms
Reply from 10.1.1.2: bytes=56 Sequence=2 ttl=128 time=40 ms
Reply from 10.1.1.2: bytes=56 Sequence=3 ttl=128 time=40 ms
Reply from 10.1.1.2: bytes=56 Sequence=4 ttl=128 time=60 ms
Reply from 10.1.1.2: bytes=56 Sequence=5 ttl=128 time=30 ms
<R1>ping 10.1.1.100
PING 10.1.1.100: 56 data bytes, press CTRL_C to break
Reply from 10.1.1.100: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 10.1.1.100: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 10.1.1.100: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 10.1.1.100: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.1.1.100: bytes=56 Sequence=5 ttl=255 time=30 ms
<R1>ping 200.1.1.254
PING 200.1.1.254: 56 data bytes, press CTRL_C to break
Reply from 200.1.1.254: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 200.1.1.254: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 200.1.1.254: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 200.1.1.254: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 200.1.1.254: bytes=56 Sequence=5 ttl=255 time=20 ms
步骤三 配置ACL
在R1上配置高级ACL,匹配特定的流量进行NAT地址转换,特定流量为源IP为10.1.1.0/24子网向Internet发起连接的所有流量。
[R1]acl 3000
[R1-acl-adv-3000]rule permit ip source 10.1.1.0 0.0.0.255 destination any
[R1-acl-adv-3000]rule deny ip source any
[R1-acl-adv-3000]quit
[R1]
步骤四 配置动态NAT
在R1上配置缺省静态路由,指定下一跳为R1对端ISP的地址200.1.1.254
[R1]ip route-static 0.0.0.0 0.0.0.0 200.1.1.254
在R1上配置动态NAT,首先配置地址池,然后在G0/0/1接口下将ACL与地址池关联起来,使得匹配ACL 3000的数据报文的源地址选用地址池中的某个地址进行NAT转换。
[R1]nat address-group 1 200.1.1.10 200.1.1.100
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 3000 address-group 1
配置完成后,查看地址池配置是否正确。
[R1]display nat address-group
NAT Address-Group Information:
Index Start-address End-address
1 200.1.1.10 200.1.1.100
在PC1、PC2上测试内网到外网的连通性。
PC1>ping 8.8.8.8
Ping 8.8.8.8: 32 data bytes, Press Ctrl_C to break
From 8.8.8.8: bytes=32 seq=1 ttl=254 time=47 ms
From 8.8.8.8: bytes=32 seq=2 ttl=254 time=31 ms
From 8.8.8.8: bytes=32 seq=3 ttl=254 time=32 ms
From 8.8.8.8: bytes=32 seq=4 ttl=254 time=31 ms
From 8.8.8.8: bytes=32 seq=5 ttl=254 time=31 ms
PC>ping 8.8.8.8
Ping 8.8.8.8: 32 data bytes, Press Ctrl_C to break
From 8.8.8.8: bytes=32 seq=1 ttl=254 time=47 ms
From 8.8.8.8: bytes=32 seq=2 ttl=254 time=47 ms
From 8.8.8.8: bytes=32 seq=3 ttl=254 time=32 ms
From 8.8.8.8: bytes=32 seq=4 ttl=254 time=31 ms
From 8.8.8.8: bytes=32 seq=5 ttl=254 time=62 ms
以上PC1和PC2可以ping通外部地址8.8.8.8,表时动态NAT已经配置成功了。
步骤五 配置easy IP
删除以上配置的动态NAT。
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]undo nat outbound 3000 address-group 1
[R1-GigabitEthernet0/0/1]quit
[R1]undo nat address-group 1
在R1上配置easy IP
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 3000
[R1-GigabitEthernet0/0/1]quit
[R1]
查看easy IP配置
[R1]display nat outbound
NAT Outbound Information:
Interface Acl Address-group/IP/Interface Type
GigabitEthernet0/0/1 3000 200.1.1.1 easyip
在PC1、PC2上测试内网到外网的连通性。
PC1>ping 8.8.8.8
Ping 8.8.8.8: 32 data bytes, Press Ctrl_C to break
From 8.8.8.8: bytes=32 seq=1 ttl=254 time=47 ms
From 8.8.8.8: bytes=32 seq=2 ttl=254 time=31 ms
From 8.8.8.8: bytes=32 seq=3 ttl=254 time=32 ms
From 8.8.8.8: bytes=32 seq=4 ttl=254 time=31 ms
From 8.8.8.8: bytes=32 seq=5 ttl=254 time=31 ms
PC>ping 8.8.8.8
Ping 8.8.8.8: 32 data bytes, Press Ctrl_C to break
From 8.8.8.8: bytes=32 seq=1 ttl=254 time=47 ms
From 8.8.8.8: bytes=32 seq=2 ttl=254 time=47 ms
From 8.8.8.8: bytes=32 seq=3 ttl=254 time=32 ms
From 8.8.8.8: bytes=32 seq=4 ttl=254 time=31 ms
From 8.8.8.8: bytes=32 seq=5 ttl=254 time=62 ms
以上PC1和PC2可以ping通外部地址8.8.8.8,表时动态easy IP已经配置成功了。
配置文件
<R1>display current-configuration
原文来自:微思网络
原文地址:https://mp.weixin.qq.com/s/S6...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。