1.实验要求:
2.实验拓扑图
3.实验步骤 :
- 首先进行拓扑搭建 (根据子网划分,划分出ip地址)
- 进行IP的配置 ,使所有合法设置都拥有ip
- 路由设置后达到全网可达
- 测试路由
- 进行优化
一.配置ip和静态路由(各路由器配置)
R1:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 30
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.1.5 30
[R1-GigabitEthernet0/0/1]int lo0
[R1-LoopBack0]int lo0
[R1-LoopBack0]ip add 192.168.1.33 28
[R1-LoopBack0]int lo1
[R1-LoopBack1]ip add 192.168.1.49 28
[R1-LoopBack1]q
[R1]ip route-static 0.0.0.0 0 192.168.1.2
[R1]ip route-static 0.0.0.0 0 192.168.1.6
[R1]ip route-static 192.168.1.64 27 192.168.1.2
[R1]ip route-static 192.168.1.8 30 192.168.1.2
[R1]ip route-static 192.168.1.12 30 192.168.1.6
[R1]ip route-static 192.168.1.96 27 192.168.1.6
[R1]ip route-static 192.168.1.96 27 192.168.1.6
R2:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.1.2 30
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.1.9 30
[R2-GigabitEthernet0/0/1]int lo2
[R2-LoopBack2]ip add 192.168.1.65 28
[R2-LoopBack2]ip add 192.168.1.81 28
[R2-LoopBack2]q
[R2]ip route-static 0.0.0.0 0 192.168.1.10
[R2]ip route-static 192.168.1.4 30 192.168.1.1
[R2]ip route-static 192.168.1.12 30 192.168.1.10
[R2]ip route-static 192.168.1.96 27 192.168.1.1
[R2]ip route-static 192.168.1.96 27 192.168.1.10
[R2]ip route-static 192.168.1.32 27 192.168.1.1
R3:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.1.6 30
[R3-GigabitEthernet0/0/1]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.1.13 30
[R3-GigabitEthernet0/0/0]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 192.168.1.97 27
[R3-GigabitEthernet0/0/2]q
R4:
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R4
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.1.10 30
ip add 192.168.1.10 30
[R4-LoopBack4]ip add 192.168.1.129 28
[R4-LoopBack5]ip add 192.168.1.145 28
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.1.10 30
[R4-GigabitEthernet0/0/1]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.1.14 30
[R4-GigabitEthernet0/0/0]int g0/0/2
[R4-GigabitEthernet0/0/2]ip add 192.168.1.17 30
[R4-GigabitEthernet0/0/2]int e4/0/0
[R4-Ethernet4/0/0]ip add 192.168.1.21 30
[R4-Ethernet4/0/0]q
[R4]ip route-static 0.0.0.0 0 192.168.1.18
[R4]ip route-static 0.0.0.0 0 192.168.1.22 pr
[R4]ip route-static 0.0.0.0 0 192.168.1.22 preference 61
[R4]ip route-static 192.168.1.0 30 192.168.1.9
[R4]ip route-static 192.168.1.4 30 192.168.1.13
[R4]ip route-static 192.168.1.96 27 192.168.1.13
[R4]ip route-static 192.168.1.32 27 192.168.1.9
[R4]ip route-static 192.168.1.32 27 192.168.1.13
[R4]ip route-static 192.168.1.64 27 192.168.1.13
[R4]ip route-static 192.168.1.128 27 NULL 0(路由汇总加空接口,防止一个环回口坏掉后,成环)
R5:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R5
[R5]int g0/0/2
[R5-GigabitEthernet0/0/2]ip add 192.168.1.161 27
[R5-GigabitEthernet0/0/2]int e4/0/0
[R5-Ethernet4/0/0]ip add 192.168.1.21 30
[R5-Ethernet4/0/0]int lo5
[R5-LoopBack0]int g0/0/2
[R5-GigabitEthernet0/0/2]ip add 192.168.1.18 30
[R5-GigabitEthernet0/0/2]int e4/0/0
[R5-Ethernet4/0/0]ip add 192.168.1.22 30
[R5-Ethernet4/0/0]int g0/0/0
int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 10.1.56.5 24
ip add 10.1.56.5 24
[R5-GigabitEthernet0/0/0]int lo5
[R5-LoopBack5]ip add 192.168.1.161 27
ip add 192.168.1.161 27
[R5-LoopBack5]q
ip route-static 0.0.0.0 0.0.0.0 10.1.56.6
ip route-static 192.168.1.0 255.255.255.252 192.168.1.17
ip route-static 192.168.1.0 255.255.255.252 192.168.1.21 preference 61
ip route-static 192.168.1.4 255.255.255.252 192.168.1.17
ip route-static 192.168.1.4 255.255.255.252 192.168.1.21 preference 61
ip route-static 192.168.1.8 255.255.255.252 192.168.1.17
ip route-static 192.168.1.8 255.255.255.252 192.168.1.21 preference 61
ip route-static 192.168.1.12 255.255.255.252 192.168.1.17
ip route-static 192.168.1.12 255.255.255.252 192.168.1.21 preference 61
ip route-static 192.168.1.32 255.255.255.224 192.168.1.17
ip route-static 192.168.1.32 255.255.255.224 192.168.1.21 preference 61
ip route-static 192.168.1.64 255.255.255.224 192.168.1.17
ip route-static 192.168.1.64 255.255.255.224 192.168.1.21 preference 61
ip route-static 192.168.1.96 255.255.255.224 192.168.1.17
ip route-static 192.168.1.96 255.255.255.224 192.168.1.21 preference 61
ip route-static 192.168.1.128 255.255.255.224 192.168.1.17
ip route-static 192.168.1.128 255.255.255.224 192.168.1.21 preference 6
R6:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R6
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip add 10.1.56.6 25
[R6]int lo6
[R6-LoopBack6]ip add 6.6.6.6
二、配置DHCP
[R3]ip pool nnn
[R3]ip pool nnn?
STRING<1-64> Pool name
[R3]ip pool nnn
Info: It's successful to create an IP address pool.
[R3-ip-pool-nnn]network 192.168.1.96 mask 27
[R3-ip-pool-nnn]gateway-list 192.168.1.97
[R3-ip-pool-nnn]dns-list 8.8.8.8
[R3-ip-pool-nnn]int g0/0/2
[R3-GigabitEthernet0/0/2]dhcp select glo
[R3-GigabitEthernet0/0/2]dhcp select global
[R3-GigabitEthernet0/0/2]q
配置成功后如图所示:
此时已经实现私网互通
三、实现私网与公网互通
运用nat
[R5]acl 2000
[R5-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R5-acl-basic-2000]int g0/0/0
[R5-GigabitEthernet0/0/0]nat outbound 2000
[R5-GigabitEthernet0/0/0]q
四、用ping命令查看全网是否互通
[R1]ping 6.6.6.6
Reply from 6.6.6.6: bytes=56 Sequence=1 ttl=252 time=50 ms
Reply from 6.6.6.6: bytes=56 Sequence=2 ttl=252 time=30 ms
Reply from 6.6.6.6: bytes=56 Sequence=3 ttl=252 time=30 ms
Reply from 6.6.6.6: bytes=56 Sequence=4 ttl=252 time=30 ms
Reply from 6.6.6.6: bytes=56 Sequence=5 ttl=252 time=30 ms
--- 6.6.6.6 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/34/50 ms
PC>ping 10.1.56.6
Ping 10.1.56.6: 32 data bytes, Press Ctrl_C to break
From 10.1.56.6: bytes=32 seq=1 ttl=252 time=62 ms
From 10.1.56.6: bytes=32 seq=2 ttl=252 time=63 ms
From 10.1.56.6: bytes=32 seq=3 ttl=252 time=46 ms
From 10.1.56.6: bytes=32 seq=4 ttl=252 time=47 ms
From 10.1.56.6: bytes=32 seq=5 ttl=252 time=78 ms
--- 10.1.56.6 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 46/59/78 ms
五、进行端口映射,完成R6telnetR5的公有IP地址时,实际登陆到R1上
1.首先配置telnet
[R1]aaa
[R1-aaa]local-user nnn password cipher 123
Info: Add a new user.
[R1-aaa]local-user nnn privilege level 15
[R1-aaa]local-user nnn service-type telnet
[R1-aaa]q
[R1]user-interface vty 0 4
[R1-ui-vty0-4]au
[R1-ui-vty0-4]authentication-mode aaa
[R1-ui-vty0-4]q
2.验证R5是否可以登录R1
<R5>telnet 192.168.1.49
Username:nnn
Password:
3.进行端口映射
[R5-GigabitEthernet0/0/0]nat server protocol tcp global current-interface 23 inside 192.168.1.33 23
Warning:The port 23 is well-known port. If you continue it may cause function failure.
Are you sure to continue?[Y/N]:y
[R5-GigabitEthernet0/0/0]q
4.此时R6可以通过连接R5登录R1
<R6>telnet 10.1.56.5
Press CTRL_] to quit telnet mode
Trying 10.1.56.5 ...
Connected to 10.1.56.5 ...
Login authentication
Username:nnn
Password:
-----------------------------------------------------------------------------
User last login information:
-----------------------------------------------------------------------------
Access Type: Telnet
IP-Address : 192.168.1.18
Time : 2023-01-01 19:13:31-08:00
-----------------------------------------------------------------------------
<R1>
至此,实验完成