NAT实验

实验拓扑

拓扑

注:如无特别说明,同一网段中,IP 地址的主机位为其设备编号,如 R3 的 g0/0 接口若在192.168.1.0/24 网段,则其 IP 地址为 192.168.1.3/24,以此类推。此拓扑中 FTPA,PCA,PCB 使用路由器来模拟

实验需求

1、按照图示配置 IP 地址
2、私网 A 通过 R1 接入到互联网,私网 B 通过 R3 接入到互联网
3、私网 A 内部存在 Vlan10 和 Vlan20,通过 R1 上单臂路由访问外部网络
4、私网 A 通过 NAPT 使 Vlan10 和 Vlan20 都能够使用 R1 的公网地址访问互联网
5、私网 B 通过在 R3 上配置 EASY IP 访问互联网
6、私网 A 配置 NAT SERVER 把 FTPA 的 FTP 服务发布到公网,使 PCB 可以访问

实验解法

1、配置 IP 地址部分(注意配置PC网关,路由器模拟的PC使用缺省路由实现网关功能)
R1:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sys
[H3C]sysname R1
[R1]int g0/1
[R1-GigabitEthernet0/1]ip address 100.1.1.1 24
[R1-GigabitEthernet0/1]int g0/0.1
[R1-GigabitEthernet0/0.1]vlan-type dot1q vid 10
[R1-GigabitEthernet0/0.1]ip address 192.168.1.254 24
[R1-GigabitEthernet0/0.1]int g0/0.2
[R1-GigabitEthernet0/0.2]vlan-type dot1q vid 20
[R1-GigabitEthernet0/0.2]ip address 192.168.2.254 24

R2:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname R2
[R2]int g0/0
[R2-GigabitEthernet0/0]ip add 100.1.1.2 24
[R2-GigabitEthernet0/0]int g0/1
[R2-GigabitEthernet0/1]ip add 100.2.2.2 24

R3:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname R3
[R3]int g0/0
[R3-GigabitEthernet0/0]ip add 100.2.2.3 24
[R3-GigabitEthernet0/0]int g0/1
[R3-GigabitEthernet0/1]ip add 192.168.1.254 24

SWA:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname SWA
[SWA]vlan 10
[SWA-vlan10]port g1/0/1
[SWA-vlan10]vlan 20
[SWA-vlan20]port g1/0/2
[SWA-vlan20]int g1/0/3
[SWA-GigabitEthernet1/0/3]port link-type trunk
[SWA-GigabitEthernet1/0/3]port trunk permit vlan 10 20

FTP-A:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname FTP-A
[FTP-A]int g0/0
[FTP-A-GigabitEthernet0/0]ip add 192.168.1.1 24

PCA:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname PCA
[PCA]int g0/0
[PCA-GigabitEthernet0/0]ip add 192.168.2.1 24

PCB:

<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysname PCB
[PCB]int g0/0
[PCB-GigabitEthernet0/0]ip add 192.168.1.1 24
[PCB-GigabitEthernet0/0]qu
[PCB]ip route-static 0.0.0.0 0 192.168.1.254
[PCB]ping 192.168.1.254
Ping 192.168.1.254 (192.168.1.254): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.254: icmp_seq=0 ttl=255 time=0.462 ms
56 bytes from 192.168.1.254: icmp_seq=1 ttl=255 time=0.562 ms
56 bytes from 192.168.1.254: icmp_seq=2 ttl=255 time=0.509 ms
56 bytes from 192.168.1.254: icmp_seq=3 ttl=255 time=1.009 ms
56 bytes from 192.168.1.254: icmp_seq=4 ttl=255 time=0.632 ms

2、R1 和 R3 上配置默认路由指向公网,配置步骤:
R1:

<R1>sys
System View: return to User View with Ctrl+Z.
[R1]ip route-static 0.0.0.0 0 100.1.1.2

R3:

<R3>sys
System View: return to User View with Ctrl+Z.
[R3]ip route-static 0.0.0.0 0 100.2.2.2

3、私网 A 内部单臂路由配置:
FTP-A:

[FTP-A]ip route-static 0.0.0.0 0 192.168.1.254
[FTP-A]ping 192.168.1.254
Ping 192.168.1.254 (192.168.1.254): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.254: icmp_seq=0 ttl=255 time=0.776 ms
56 bytes from 192.168.1.254: icmp_seq=1 ttl=255 time=0.652 ms
56 bytes from 192.168.1.254: icmp_seq=2 ttl=255 time=3.039 ms
56 bytes from 192.168.1.254: icmp_seq=3 ttl=255 time=0.772 ms
56 bytes from 192.168.1.254: icmp_seq=4 ttl=255 time=0.606 ms

PCA:

[PCA]ip route-static 0.0.0.0 0 192.168.2.254
[PCA]ping 192.168.1.254
Ping 192.168.1.254 (192.168.1.254): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.1.254: icmp_seq=0 ttl=255 time=0.817 ms
56 bytes from 192.168.1.254: icmp_seq=1 ttl=255 time=0.662 ms
56 bytes from 192.168.1.254: icmp_seq=2 ttl=255 time=0.671 ms
56 bytes from 192.168.1.254: icmp_seq=3 ttl=255 time=0.870 ms
56 bytes from 192.168.1.254: icmp_seq=4 ttl=255 time=0.877 ms

4、私网 A 通过 NAPT 使 Vlan10 和 Vlan20 都能够使用 R1 的公网地址访问互联网
思路:
根据需求得知,ACL 需要配置允许192.168.1.0/24192.168.2.0/24网段;私网 A 只有 1 个公网地址可用,意味着创建的 NAT 地址池起始和结束地址就都是 100.1.1.1

步骤 1:R1 上创建基本 ACL,允许192.168.1.0/24192.168.2.0/24网段

[R1]acl basic 2000
[R1-acl-ipv4-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R1-acl-ipv4-basic-2000]rule permit source 192.168.2.0 0.0.0.255

步骤 2:R1 上创建 NAT 地址池,设置公网地址

[R1]nat address-group 1
[R1-address-group-1]address 100.1.1.1 100.1.1.1

步骤 3:在 R1 的公网接口上配置 NAPT

[R1]int g0/1
[R1-GigabitEthernet0/1]nat outbound 2000 address-group 1

步骤 4:在 PCA 上 Ping R3 的公网地址,测试是否可以访问互联网

<PCA>ping 100.2.2.3
Ping 100.2.2.3 (100.2.2.3): 56 data bytes, press CTRL+C to break
56 bytes from 100.2.2.3: icmp_seq=0 ttl=253 time=1.292 ms
56 bytes from 100.2.2.3: icmp_seq=1 ttl=253 time=1.391 ms
56 bytes from 100.2.2.3: icmp_seq=2 ttl=253 time=1.455 ms
56 bytes from 100.2.2.3: icmp_seq=3 ttl=253 time=1.056 ms
56 bytes from 100.2.2.3: icmp_seq=4 ttl=253 time=1.283 ms

5、私网 B 通过在 R3 上配置 EASY IP 访问互联网
思路:
根据需求得知,ACL 需要配置允许192.168.1.0/24网段;使用 EASY IP,就无需配置 NAT 地址池,直接在公网接口上配置即可,EASY IP 会自动识别公网接口的 IP 地址

步骤 1:R3 上创建基本 ACL,允许192.168.1.0/24网段

[R3]acl basic 2000
[R3-acl-ipv4-basic-2000]rule permit source 192.168.1.0 0.0.0.255

步骤 2:在 R3 的公网接口上配置 EASY IP

[R3]int g0/0
[R3-GigabitEthernet0/0]nat outbound 2000

步骤 4:在 PCB 上 Ping R1 的公网地址,测试是否可以访问互联网

<PCB>ping 100.1.1.1
Ping 100.1.1.1 (100.1.1.1): 56 data bytes, press CTRL+C to break
56 bytes from 100.1.1.1: icmp_seq=0 ttl=253 time=1.050 ms
56 bytes from 100.1.1.1: icmp_seq=1 ttl=253 time=1.049 ms
56 bytes from 100.1.1.1: icmp_seq=2 ttl=253 time=0.916 ms
56 bytes from 100.1.1.1: icmp_seq=3 ttl=253 time=1.084 ms
56 bytes from 100.1.1.1: icmp_seq=4 ttl=253 time=1.092 ms

6、私网 A 配置 NAT SERVER 把 FTPA 的 FTP 服务发布到公网,使 PCB 可以访问
思路:
根据需求得知,需要发布 FTP-A 的 FTP 服务,也就是把 R1 的公网地址的 20 和 21 端口映射到 FTP-A 的私网地址
配置 FTP 服务请参考H3C配置管理实验

步骤 1:在 R1 的公网接口上配置 NAT SERVER,映射端口 20 和 21

[R1-GigabitEthernet0/1]nat server protocol tcp global 100.1.1.1 20 21 inside 192.168.1.10 20 21

步骤 2:在 PCB 上测试是否能够通过 R1 的公网地址访问 FTPA 的 FTP 服务

<PCB>ftp 100.1.1.1
Press CTRL+C to abort.
Connected to 100.1.1.1 (100.1.1.1).
220 FTP service ready.
User (100.1.1.1:(none)):
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

梦南司

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值