实验拓扑
图 1-1
注:如无特别说明,同一网段中,IP 地址的主机位为其设备编号,如 R3 的 g0/0 接口若在
192.168.1.0/24
网段,则其 IP 地址为192.168.1.3/24
,以此类推。此拓扑中 FTPA,PCA,PCB 使用路由器来模拟
实验需求
- 按照图示配置 IP 地址
-
私网 A 通过 R1 接入到互联网,私网 B 通过 R3 接入到互联网
- 私网 A 内部存在 Vlan10 和 Vlan20,通过 R1 上单臂路由访问外部网络
-
私网 A 通过 NAPT 使 Vlan10 和 Vlan20 都能够使用 R1 的公网地址访问互联网
- 私网 B 通过在 R3 上配置 EASY IP 访问互联网
-
私网 A 配置 NAT SERVER 把 FTPA 的 FTP 服务发布到公网,使 PCB 可以访问
实验解法
-
配置 IP 地址部(路由器当作电脑来使用,需要指定网关,这里的网关为R1G0/1子接口的IP地址,192.168.1.254/24 与192.168.2.254/24)
FTP服务器
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn ftp
[ftp]int g0/0
[ftp-GigabitEthernet0/0]ip add 192.168.1.10 24
[ftp-GigabitEthernet0/0]qu
[ftp]ip route-static 0.0.0.0 0 192.168.1.254
[ftp]
PCA
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn PCA
[PCA]int g0/0
[PCA-GigabitEthernet0/0]ip add 192.168.2.20 24
[PCA-GigabitEthernet0/0]qu
[PCA]ip route-static 0.0.0.0 0 192.168.2.254
SWA
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn SW1
[SW1]vlan 10
[SW1-vlan10]port g1/0/1
[SW1-vlan10]vlan 20
[SW1-vlan20]port g1/0/2
[SW1-vlan20]int g1/0/3
[SW1-GigabitEthernet1/0/3]port link-t tr
[SW1-GigabitEthernet1/0/3]port tr pe vlan 10 20
[SW1-GigabitEthernet1/0/3]
R1(这里顺便配置了单臂路由)
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn R1
[R1]vlan 10
[R1-vlan10]vlan 20
[R1-vlan20]int g0/0.1
[R1-GigabitEthernet0/0.1]vlan-type dot1q vid 10
[R1-GigabitEthernet0/0.1]ip add 192.168.1.254 24
[R1]interface g0/0.2
[R1-GigabitEthernet0/0.2]vlan-type dot1q vid 20
[R1-GigabitEthernet0/0.2]ip address 192.168.2.254 24
[R1-GigabitEthernet0/0.2]int g0/1
[R1-GigabitEthernet0/1]ip add 100.1.1.1 24
[R1-GigabitEthernet0/1]
R2
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn 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
[R2-GigabitEthernet0/1]
R3
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn 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.3 24
[R3-GigabitEthernet0/1]
PCB
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]sysn PCB
[PCB]int g0/0
[PCB-GigabitEthernet0/0]ip add 192.168.1.30 24
[PCB-GigabitEthernet0/0]qu
[PCB]ip rou
[PCB]ip route-static 0.0.0.0 0 192.168.1.3
[PCB]
2,R1 和 R3 上配置默认路由指向公网,
R1
[R1]ip route-static 0.0.0.0 0 100.1.1.2
R3
[R3]ip route-static 0.0.0.0 0 100.2.2.2
3,私网 A 通过 NAPT 使 Vlan10 和 Vlan20 都能够使用 R1 的公网地址访问互联网
分析:根据需求得知,ACL 需要配置允许 192.168.1.0/24
和 192.168.2.0/24
网段;私网 A 只有 1 个公网地址可用,意味着创建的 NAT 地址池起始和结束地址就都是 100.1.1.1
步骤 1:R1 上创建基本 ACL,允许 192.168.1.0/24
和 192.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]interface 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=2.000 ms
56 bytes from 100.2.2.3: icmp_seq=1 ttl=253 time=2.000 ms
56 bytes from 100.2.2.3: icmp_seq=2 ttl=253 time=2.000 ms
56 bytes from 100.2.2.3: icmp_seq=3 ttl=253 time=1.000 ms
56 bytes from 100.2.2.3: icmp_seq=4 ttl=253 time=1.000 ms
4,私网 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]interface g0/0
[R3-GigabitEthernet0/0]nat outbound 2000
步骤 4:在 PCB 上 Ping R1 的公网地址,测试是否可以访问互联网
[R3-GigabitEthernet0/0]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=254 time=1.000 ms 56 bytes from 100.1.1.1: icmp_seq=1 ttl=254 time=1.000 ms 56 bytes from 100.1.1.1: icmp_seq=2 ttl=254 time=1.000 ms 56 bytes from 100.1.1.1: icmp_seq=3 ttl=254 time=1.000 ms 56 bytes from 100.1.1.1: icmp_seq=4 ttl=254 time=0.000 ms
5,配置 FTP 服务器
步骤1,在 ftp服务器上配置开启 TELNET 和 FTP 服务,账户为guolaoban,密码123456
[ftp]ftp server en
[ftp]local-user guolaoban class manage
New local user added.
[ftp-luser-manage-guolaoban]password sim 123465
[ftp-luser-manage-guolaoban]authorization-attribute user-role level-15
[ftp-luser-manage-guolaoban]service-type ftp
6,私网 A 配置 NAT SERVER 把 FTPA 的 FTP 服务发布到公网,使 PCB 可以访问
分析:根据需求得知,需要发布 FTPA 的 FTP 服务,也就是把 R1 的公网地址的 20 和 21 端口映射到 FTPA 的私网地址
步骤 1:在 R1 的公网接口上配置 NAT SERVER,映射端口 20 和 21,这里映射ftp服务器的地址为192.168.1.10
[R1-GigabitEthernet0/1]int g0/1
[R1-GigabitEthernet0/1]nat server protocol tcp global current-interface 20 21 in
side 192.168.1.10 20 21
[R1-GigabitEthernet0/1]
步骤 2:在 PCB 上测试是否能够通过 R1 的公网地址访问 FTPA 的 FTP 服务,账号:guolaoban,密码:123465
<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)): guolaoban 331 Password required for guolaoban. Password: 530 Login authentication failed ftp: Login failed. Remote system type is UNIX. Using binary mode to transfer files. ftp>