1.合理划分网段
为方便路由编写
R1 - R2之间划分的网段为----- 12.1.1.0/24
R2 - R3之间划分的网段为----- 23.1.1.0/24
R3 - R4之间划分的网段为----- 34.1.1.0/24
R1 - R4之间划分的网段为----- 14.1.1.0/24
R4 - R5之间划分的网段为----- 45.1.1.0/24
R4 - R6之间划分的网段为----- 46.1.1.0/24
R6 - R7之间划分的网段为----- 67.1.1.0/24
R1 - R7的环回地址分别为:1.1.1.0/24;2.2.2.0/24;3.3.3.0/24;4.4.4.0/24;5.5.5.0/24;6.6.6.0/24;7.7.7.0/24。
2、配置IP地址:
R1:
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
Jul 7 2022 21:49:38-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]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 14.1.1.2 24
[R1-GigabitEthernet0/0/1]
Jul 7 2022 21:49:53-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]int l0
[R1-LoopBack0]ip add 172.16.1.1 24
[R1-LoopBack0]int l1
[R1-LoopBack1]ip add 172.16.2.1 24
[R1-LoopBack1]int l2
[R1-LoopBack2]ip add 172.16.3.1 24
[R1-LoopBack2]int l3
[R1-LoopBack3]ip add 1.1.1.1 24
[R1-LoopBack3]q
[R1]
R2:
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
Jul 7 2022 21:52:14-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]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 23.1.1.1 24
Jul 7 2022 21:52:26-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]int l0
[R2-LoopBack0]ip add 2.2.2.1 24
[R2-LoopBack0]q
R3:
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
Jul 7 2022 21:54:01-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]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
Jul 7 2022 21:54:22-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]int l0
[R3-LoopBack0]ip add 3.3.3.1 24
[R3-LoopBack0]
R4:
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 14.1.1.1 24
Jul 7 2022 21:55:41-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]int g0/0/1
[R4-GigabitEthernet0/0/1]ip add 34.1.1.2 24
Jul 7 2022 21:56:06-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]int g0/0/2
[R4-GigabitEthernet0/0/2]ip add 45.1.1.1 24
Jul 7 2022 21:56:23-08:00 R4 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/2 has entered the UP state.
[R4-GigabitEthernet0/0/2]int g4/0/0
[R4-GigabitEthernet4/0/0]ip add 46.1.1.1 24
[R4-GigabitEthernet4/0/0]
Jul 7 2022 21:56:46-08:00 R4 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP on the interface GigabitEthernet4/0/0 has entered the UP state.
[R4-GigabitEthernet4/0/0]int l0
[R4-LoopBack0]ip add 4.4.4.1 24
[R4-LoopBack0]
R5:
[R5]int g0/0/0
[R5-GigabitEthernet0/0/0]ip add 45.1.1.2 24
Jul 7 2022 21:58:19-08:00 R5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[R5-GigabitEthernet0/0/0]int l0
[R5-LoopBack0]ip add 5.5.5.1 24
[R5-LoopBack0]
R6:
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 46.1.1.2 24
Jul 7 2022 21:58:59-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 67.1.1.1 24
Jul 7 2022 21:59:22-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[Huawei-GigabitEthernet0/0/1]int l0
[Huawei-LoopBack0]ip add 6.6.6.1 24
[Huawei-LoopBack0]
R7:
[R7]int g0/0/0
[R7-GigabitEthernet0/0/0]ip add 67.1.1.2 24
Jul 7 2022 22:00:13-08:00 R7 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[R7-GigabitEthernet0/0/0]int l0
[R7-LoopBack0]ip add
[R7-LoopBack0]ip address 7.7.7.1 24
[R7-LoopBack0]
3. 全网可达
将每个接口进行宣告,R1-R5的版本为v2,R6-R7的版本为v1,但是R5的环回不能进行宣告,直接做为缺省路由,将R1进行汇总,并做空接口路由,避免环路,实现传递的安全性
R1:
[R1]rip
[R1-rip-1]net
[R1-rip-1]network 172.16.0.0
[R1-rip-1]network 12.0.0.0
[R1-rip-1]network 14.0.0.0
[R1-rip-1]int g0/0/0
[R1-GigabitEthernet0/0/0]rip su
[R1-GigabitEthernet0/0/0]rip summary-address 172.16.0.0 24
^
Error: Wrong parameter found at '^' position.
[R1-GigabitEthernet0/0/0]rip summary-address 172.16.0.0 255.255.252.0
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]rip su
[R1-GigabitEthernet0/0/1]rip summary-address 172.16.0.0 255.255.252.0
[R1-GigabitEthernet0/0/1]q
[R1]ip rou
[R1]ip route-st
[R1]ip route-static 172.16.0.0 22 N
[R1]ip route-static 172.16.0.0 22 NULL 0
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]rip au
[R1-GigabitEthernet0/0/0]rip authentication-mode mo
[R1-GigabitEthernet0/0/0]rip authentication-mode md
[R1-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R1-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R1-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]rip au
[R1-GigabitEthernet0/0/1]rip authentication-mode mo
[R1-GigabitEthernet0/0/1]rip authentication-mode md
[R1-GigabitEthernet0/0/1]rip authentication-mode md5 us
[R1-GigabitEthernet0/0/1]rip authentication-mode md5 usual ci
[R1-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher 123
[R1-GigabitEthernet0/0/1]
R2:
[R2]rip
[R2-rip-1]ver
[R2-rip-1]verify-source
[R2-rip-1]version 2
[R2-rip-1]net
[R2-rip-1]network 12.0.0.0
[R2-rip-1]network 23.0.0.0
[R2-rip-1]network 2.0.0.0
[R2-rip-1]int g0/0/0
[R2-GigabitEthernet0/0/0]rip au
[R2-GigabitEthernet0/0/0]rip authentication-mode md
[R2-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R2-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R2-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]rip au
[R2-GigabitEthernet0/0/1]rip authentication-mode md
[R2-GigabitEthernet0/0/1]rip authentication-mode md5 us
[R2-GigabitEthernet0/0/1]rip authentication-mode md5 usual ci
[R2-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher 123
[R2-GigabitEthernet0/0/1]
R3:
[R3]rip
[R3-rip-1]ver
[R3-rip-1]verify-source
[R3-rip-1]version 2
[R3-rip-1]net
[R3-rip-1]network 23.0.0.0
[R3-rip-1]network 34.0.0.0
[R3-rip-1]network 3.0.0.0
[R3-rip-1]int g0/0/0
[R3-GigabitEthernet0/0/0]rip au
[R3-GigabitEthernet0/0/0]rip authentication-mode md
[R3-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R3-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R3-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]rip au
[R3-GigabitEthernet0/0/1]rip authentication-mode mo
[R3-GigabitEthernet0/0/1]rip authentication-mode md
[R3-GigabitEthernet0/0/1]rip authentication-mode md5 us
[R3-GigabitEthernet0/0/1]rip authentication-mode md5 usual ci
[R3-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher 123
[R3-GigabitEthernet0/0/1]
R4:
[R4]rip
[R4-rip-1]ver
[R4-rip-1]verify-source
[R4-rip-1]version 2
[R4-rip-1]net
[R4-rip-1]network 14.0.0.0
[R4-rip-1]network 34.0.0.0
[R4-rip-1]network 46.0.0.0
[R4-rip-1]network 45.0.0.0
[R4-rip-1]network 4.0.0.0
[R4-rip-1]q
[R4]ip rou
[R4]ip route-st
[R4]ip route-static 0.0.0.0 0 45.1.1.2
[R4]rip
[R4-rip-1]de
[R4-rip-1]default-cost
[R4-rip-1]default-route or
[R4-rip-1]default-route originate
[R4-rip-1]int g0/0/0
[R4-GigabitEthernet0/0/0]rip au
[R4-GigabitEthernet0/0/0]rip authentication-mode md
[R4-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R4-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R4-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R4-GigabitEthernet0/0/0]int g0/0/1
[R4-GigabitEthernet0/0/1]rip au
[R4-GigabitEthernet0/0/1]rip authentication-mode md
[R4-GigabitEthernet0/0/1]rip authentication-mode md5 us
[R4-GigabitEthernet0/0/1]rip authentication-mode md5 usual ci
[R4-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher 123
[R4-GigabitEthernet0/0/1]int g0/0/2
[R4-GigabitEthernet0/0/2]rip su
[R4-GigabitEthernet0/0/2]rip au
[R4-GigabitEthernet0/0/2]rip authentication-mode md
[R4-GigabitEthernet0/0/2]rip authentication-mode md5 us
[R4-GigabitEthernet0/0/2]rip authentication-mode md5 usual ci
[R4-GigabitEthernet0/0/2]rip authentication-mode md5 usual cipher 123
[R4-GigabitEthernet0/0/2]int g4/0/0
[R4-GigabitEthernet4/0/0]rip au
[R4-GigabitEthernet4/0/0]rip authentication-mode md
[R4-GigabitEthernet4/0/0]rip authentication-mode md5 us
[R4-GigabitEthernet4/0/0]rip authentication-mode md5 usual ci
[R4-GigabitEthernet4/0/0]rip authentication-mode md5 usual cipher 123
[R4-GigabitEthernet4/0/0]
R5:
[R5]rip
[R5-rip-1]ver
[R5-rip-1]verify-source
[R5-rip-1]version 2
[R5-rip-1]net
[R5-rip-1]network 45.0.0.0
[R5-rip-1]int g0/0/0
[R5-GigabitEthernet0/0/0]rip au
[R5-GigabitEthernet0/0/0]rip authentication-mode md
[R5-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R5-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R5-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R5-GigabitEthernet0/0/0]
[R5-GigabitEthernet0/0/0]q
[R5]rip
[R5-rip-1]net
[R5-rip-1]network 5.0.0.0
[R5-rip-1]
R6:
[R6]rip
[R6-rip-1]ver
[R6-rip-1]verify-source
[R6-rip-1]version 1
[R6-rip-1]net
[R6-rip-1]network 46.0.0.0
[R6-rip-1]network 67.0.0.0
[R6-rip-1]network 6.0.0.0
[R6-rip-1]int g0/0/0
[R6-GigabitEthernet0/0/0]rip ver
[R6-GigabitEthernet0/0/0]rip version 2
[R6-GigabitEthernet0/0/0]int g0/0/0
[R6-GigabitEthernet0/0/0]rip au
[R6-GigabitEthernet0/0/0]rip authentication-mode md
[R6-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R6-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R6-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R6-GigabitEthernet0/0/0]int g0/0/1
[R6-GigabitEthernet0/0/1]rip au
[R6-GigabitEthernet0/0/1]rip authentication-mode md
[R6-GigabitEthernet0/0/1]rip authentication-mode md5 us
[R6-GigabitEthernet0/0/1]rip authentication-mode md5 usual ci
[R6-GigabitEthernet0/0/1]rip authentication-mode md5 usual cipher 123
[R6-GigabitEthernet0/0/1]
R7:
[R7]rip
[R7-rip-1]ver
[R7-rip-1]verify-source
[R7-rip-1]version 1
[R7-rip-1]net
[R7-rip-1]network 67.0.0.0
[R7-rip-1]network 7.0.0.0
[R7-rip-1]int g0/0/0
[R7-GigabitEthernet0/0/0]rip au
[R7-GigabitEthernet0/0/0]rip authentication-mode m
[R7-GigabitEthernet0/0/0]rip authentication-mode md5 us
[R7-GigabitEthernet0/0/0]rip authentication-mode md5 usual ci
[R7-GigabitEthernet0/0/0]rip authentication-mode md5 usual cipher 123
[R7-GigabitEthernet0/0/0]
4. R3使用R2访问R1的环回
需要在R3上进行抓取流量,抓取R1上的环回地址,然后再R3的0/0/1接口上修改开销值
R3:
[R3]acl 2000
[R3-acl-basic-2000]su
[R3-acl-basic-2000]ru
[R3-acl-basic-2000]rule per
[R3-acl-basic-2000]rule permit so
[R3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R3-acl-basic-2000]int g0/0/1
[R3-GigabitEthernet0/0/1]rip metr
[R3-GigabitEthernet0/0/1]rip metricin 2000 10
[R3-GigabitEthernet0/0/1]
[R3-GigabitEthernet0/0/1]q
- 只能通过R2的接口进行访问
5. R1telnetR2的环回实际telnetR7上
我们需要在R7上开启telnet服务,在R2上做地址映射,并且使得只能往R2回
R7:
[R7]aaa
[R7-aaa]lo
[R7-aaa]local-user 111 pr
[R7-aaa]local-user 111 privilege le
[R7-aaa]local-user 111 privilege level 15 pa
[R7-aaa]local-user 111 privilege level 15 password ci
[R7-aaa]local-user 111 privilege level 15 password cipher 123
Info: Add a new user.
[R7-aaa]lo
[R7-aaa]local-user 111 ser
[R7-aaa]local-user 111 service-type se
[R7-aaa]local-user 111 service-type te
[R7-aaa]local-user 111 service-type telnet
[R7-aaa]us
[R7-aaa]q
[R7]us
[R7]user-groupint
[R7]us
[R7]user
[R7]user-bind
[R7]user-group
[R7]user-interface vty 0 4
[R7-ui-vty0-4]au
[R7-ui-vty0-4]authentication-mode aaa
[R7-ui-vty0-4]
R2:
Enter system view, return user view with Ctrl+Z.
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]na
[R2-GigabitEthernet0/0/0]nat ser
[R2-GigabitEthernet0/0/0]nat server pro
[R2-GigabitEthernet0/0/0]nat server protocol tcp
[R2-GigabitEthernet0/0/0]nat server protocol tcp gl
[R2-GigabitEthernet0/0/0]nat server protocol tcp global in
[R2-GigabitEthernet0/0/0]nat server protocol tcp global interface lo
[R2-GigabitEthernet0/0/0]nat server protocol tcp global interface loopback 0 23ins
[R2-GigabitEthernet0/0/0]nat server protocol tcp global interface loopback 0 23 inside 7.7.7.7 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
配完之后因为R2找7.7.7.0/24的时候走的是两条路,我们只能往R3走,不能往R1上走,所以需要将走R1上的开销值修改大一点,同理,在R4回的时候也有两条路,这里只能通过R3回到R2上才行,所以也需要将R4到R1的开销值修改大一点。
R2:
[R2-GigabitEthernet0/0/0]acl 2000
[R2-acl-basic-2000]ru
[R2-acl-basic-2000]rule per
[R2-acl-basic-2000]rule permit so
[R2-acl-basic-2000]rule permit source 7.0.0.0 0
[R2-acl-basic-2000]int g0/0/0
[R2-GigabitEthernet0/0/0]rip
[R2-GigabitEthernet0/0/0]rip me
[R2-GigabitEthernet0/0/0]rip metricout
[R2-GigabitEthernet0/0/0]rip metricin 2000 10
[R2-GigabitEthernet0/0/0]dsi
[R2-GigabitEthernet0/0/0]dis
[R2-GigabitEthernet0/0/0]display ip rou
[R2-GigabitEthernet0/0/0]display ip routing-table pr
[R2-GigabitEthernet0/0/0]display ip routing-table protocol rip
[R2-GigabitEthernet0/0/0]display ip routing-table protocol rip
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : RIP
Destinations : 12 Routes : 19
RIP routing table status : <Active>
Destinations : 12 Routes : 19
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 RIP 100 2 D 12.1.1.1 GigabitEthernet0/0/0
RIP 100 2 D 23.1.1.2 GigabitEthernet0/0/1
3.3.3.0/24 RIP 100 1 D 23.1.1.2 GigabitEthernet0/0/1
4.4.4.0/24 RIP 100 2 D 12.1.1.1 GigabitEthernet0/0/0
RIP 100 2 D 23.1.1.2 GigabitEthernet0/0/1
5.5.5.0/24 RIP 100 3 D 12.1.1.1 GigabitEthernet0/0/0
RIP 100 3 D 23.1.1.2 GigabitEthernet0/0/1
6.6.6.0/24 RIP 100 3 D 23.1.1.2 GigabitEthernet0/0/1
RIP 100 3 D 12.1.1.1 GigabitEthernet0/0/0
7.0.0.0/8 RIP 100 4 D 23.1.1.2 GigabitEthernet0/0/1
14.1.1.0/24 RIP 100 1 D 12.1.1.1 GigabitEthernet0/0/0
34.1.1.0/24 RIP 100 1 D 23.1.1.2 GigabitEthernet0/0/1
45.1.1.0/24 RIP 100 2 D 12.1.1.1 GigabitEthernet0/0/0
RIP 100 2 D 23.1.1.2 GigabitEthernet0/0/1
46.1.1.0/24 RIP 100 2 D 12.1.1.1 GigabitEthernet0/0/0
RIP 100 2 D 23.1.1.2 GigabitEthernet0/0/1
67.1.1.0/24 RIP 100 3 D 23.1.1.2 GigabitEthernet0/0/1
RIP 100 3 D 12.1.1.1 GigabitEthernet0/0/0
172.16.0.0/22 RIP 100 1 D 12.1.1.1 GigabitEthernet0/0/0
RIP routing table status : <Inactive>
Destinations : 0 Routes : 0
[R2-GigabitEthernet0/0/0]
测试结果:
5. R6-R7不能学习到R1的环回
只需要在R6上操作,因为R7是通过R6进行访问的,如果R6都不能访问,那R7也不能进行访问,我们先抓取R1环回地址的流量,将它设置为不能通过,其它都设置为允许,并在R6的入接口上(0/0/0接口)进行路由过滤,因为filter-policy没有路由过滤功能,所以需要调用acl来实现路由过滤
R6:
[r6]acl 2000
[r6-acl-basic-2000]rule deny source 172.16.0.0 0.0.255.255 抓取R1环回地址流量,不允许通过
[r6-acl-basic-2000]rule permit source any
[r6-acl-basic-2000]q
[r6]rip
[r6-rip-1]filter-policy 2000 import
测试:
R1:
R2:
R3:
R4:
R5:
R6:
R7: