1.规划IP
192.168.1.0/24
192.168.1.0/27 骨干
192.168.1.0/30 192.168.1.4/30 192.168.1.8/30 192.168.1.12/30
192.168.1.16/30 192.168.1.20/30 192.168.1.24/30 192.168.1.28/30
192.168.1.32/27 R1 两个环回 192.168.1.32/28 192.168.1.48/28
192.168.1.64/27 R2 两个环回 192.168.1.64/28 192.168.1.80/28
192.168.1.96/27 R3 一个环回
192.168.1.128/27 R4 两个环回 192.168.1.128/28 192.168.1.144/28
192.168.1.160/27 R5 一个环回
192.168.1.192/27
192.168.1.224/27
2.建立模型
3.配置路由器的接口和环回的IP
R1
<Huawei>
<Huawei>
<Huawei>
<Huawei>sys
[Huawei]sysname R1
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 30
Aug 3 2023 19:25:44-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]q
[R1]int lo1
[R1-LoopBack1]ip address 192.168.1.49 28
[R1-LoopBack1]q
[R1]int lo0
[R1-LoopBack0]ip address 192.168.1.33 28
[R1-LoopBack0]q
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.1.5 30
Aug 3 2023 19:42:52-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]q
[R1]
R2
The device is running!
<Huawei>
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]int lo0
[R2-LoopBack0]ip address 192.168.1.65 28
[R2-LoopBack0]q
[R2]int lo1
[R2-LoopBack1]ip address 192.168.1.81 28
[R2-LoopBack1]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip address 192.168.1.2 30
Aug 3 2023 19:47:04-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R2-GigabitEthernet0/0/0]q
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.1.9 30
Aug 3 2023 19:48:01-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R2-GigabitEthernet0/0/1]q
[R2]
R3
接口配置IP
The device is running!
<Huawei>
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.1.14 30
Aug 3 2023 20:45:13-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R3-GigabitEthernet0/0/0]q
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip address 192.168.1.6 30
Aug 3 2023 20:45:39-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R3-GigabitEthernet0/0/1]q
[R3]
[R3]interface g0/0/2
[R3-GigabitEthernet0/0/2]ip address 192.168.1.97 27
Aug 3 2023 20:51:10-08:00 R3 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R3-GigabitEthernet0/0/2]q
配置DHCP给R3下的两台PC机自动分配地址
[R3]
[R3]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R3]ip pool 1
Info: It's successful to create an IP address pool.
[R3-ip-pool-1]network 192.168.1.96 mask 27
[R3-ip-pool-1]gateway-list 192.168.1.97
[R3-ip-pool-1]q
[R3]int g0/0/2
[R3-GigabitEthernet0/0/2]dhcp select global
[R3-GigabitEthernet0/0/2]
R4
Please press enter to start cmd line!
########
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R4
[R4]
[R4]int e4/0/0
[R4]int lo0
[R4-LoopBack0]ip address 192.168.1.129 28
[R4-LoopBack0]q
[R4]int lo1
[R4-LoopBack1]ip address 192.168.1.145 28
[R4-LoopBack1]q
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip address 192.168.1.10 30
Aug 3 2023 20:38:03-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R4-GigabitEthernet0/0/0]q
[R4]int g0/0/1
[R4-GigabitEthernet0/0/1]ip address 192.168.1.13 30
Aug 3 2023 20:38:19-08:00 R4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R4-GigabitEthernet0/0/1]q
[R4]int e4/0/0
[R4-Ethernet4/0/0]ip address 192.168.1.17 30
Aug 3 2023 20:39:30-08:00 R4 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface Ethernet4/0/0 has entered the UP state.
[R4-Ethernet4/0/0]q
[R4]int g0/0/2
[R4-GigabitEthernet0/0/2]ip address 192.168.1.21 30
Aug 3 2023 20:40:01-08:00 R4 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R4-GigabitEthernet0/0/2]q
[R4]
R5
The device is running!
<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R5
[R5]int lo0
[R5-LoopBack0]ip address 192.168.1.161 27
[R5-LoopBack0]q
[R5]int e4/0/0
[R5-Ethernet4/0/0]ip address 192.168.1.18 30
Aug 3 2023 21:05:41-08:00 R5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface Ethernet4/0/0 has entered the UP state.
[R5-Ethernet4/0/0]q
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip address 192.168.1.22 30
Aug 3 2023 21:06:26-08:00 R5 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R5-GigabitEthernet0/0/0]q
[R5]int g0/0/1
[R5-GigabitEthernet0/0/1]ip address 56.1.1.1 24
[R5-GigabitEthernet0/0/1]
Aug 3 2023 21:06:54-08:00 R5 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R5-GigabitEthernet0/0/1]q
[R5]
R6
The device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R6
[R6]int lo0
[R6-LoopBack0]ip address 6.6.6.6 24
[R6-LoopBack0]q
[R6]int g0/0/0
[R6-GigabitEthernet0/0/0]ip address 56.1.1.2 24
Aug 3 2023 21:09:18-08:00 R6 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R6-GigabitEthernet0/0/0]q
[R6]
4.配置缺省与静态路由
R1
[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.96 27 192.168.1.6
[R1]ip route-static 192.168.1.12 30 192.168.1.6
R2
[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.96 27 192.168.1.1
[R2]ip route-static 192.168.1.96 27 192.168.1.10
R3
[R3]ip route-static 0.0.0.0 0 192.168.1.13
[R3]ip route-static 192.168.1.32 27 192.168.1.5
[R3]ip route-static 192.168.1.0 30 192.168.1.5
[R3]ip route-static 192.168.1.64 27 192.168.1.5
[R3]ip route-static 192.168.1.64 27 192.168.1.13
R4
[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 preference 61
[R4]ip route-static 192.168.1.64 27 192.168.1.9
[R4]ip route-static 192.168.1.32 27 192.168.1.9
[R4]ip route-static 192.168.1.0 30 192.168.1.9
[R4]ip route-static 192.168.1.32 27 192.168.1.14
[R4]ip route-static 192.168.1.4 30 192.168.1.14
[R4]ip route-static 192.168.1.96 27 192.168.1.14
R5
[R5]ip route-static 0.0.0.0 0 56.1.1.2
[R5]ip route-static 192.168.1.128 27 192.168.1.21
[R5]ip route-static 192.168.1.32 27 192.168.1.21
[R5]ip route-static 192.168.1.64 27 192.168.1.21
[R5]ip route-static 192.168.1.8 30 192.168.1.21
[R5]ip route-static 192.168.1.0 30 192.168.1.21
[R5]ip route-static 192.168.1.4 30 192.168.1.21
[R5]ip route-static 192.168.1.12 30 192.168.1.21
[R5]ip route-static 192.168.1.96 27 192.168.1.21
[R5]
[R5]ip route-static 192.168.1.128 27 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.32 27 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.64 27 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.8 30 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.0 30 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.4 30 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.12 30 192.168.1.17 preference 61
[R5]ip route-static 192.168.1.96 27 192.168.1.17 preference 61
5.配置NAT使内网可以访问外网
[R5]acl 2000
[R5-acl-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R5-acl-basic-2000]q
[R5]int g0/0/1
[R5-GigabitEthernet0/0/1]nat outbound 2000
[R5-GigabitEthernet0/0/1]
6.R6 telnet R5的公有IP时实际登陆到R1
[R5-GigabitEthernet0/0/1]nat static protocol tcp global current-interface 23 ins
ide 192.168.1.1 23
Warning:The port 23 is well-known port. If you continue it may cause function fa
ilure.
Are you sure to continue?[Y/N]:y
[R5-GigabitEthernet0/0/1]q
[R5]
7.给R1设置远程登录的账号密码
[R1]aaa
[R1-aaa]local-user huawei privilege level 15 password cipher 123456
Info: Add a new user.
[R1-aaa]local-user huawei service-type telnet
[R1-aaa]q
[R1]user-interface vty 0 4
[R1-ui-vty0-4]authentication-mode aaa
[R1-ui-vty0-4]q
8.测试
远程登录
ping