一、实验拓扑图
二、实验要求:
1、R6为ISP,接口IP地址均为公有地址,该设备只能配置IP地址,之后不能再对其进行任何配置;
2、R1-R5为局域网,私有IP地址192.168.1.0/24,请合理分配;
3、R1、R2、R4,各有两个环回IP地址;R5,R6各有一个环回地址;所有路由器上环回均代表连接用户的接口;
4、R3下面的两台PC通过DHCP自动获取IP地址;
5、选路最佳,路由表尽量小,避免环路;
6、R1-R5均可以访问R6的环回;
7、R6 telnet R5的公有地址时,实际登录到R1上;
8、R4与R5正常通过1000M链路,故障时通过100m链路;
三、实验思路
1.根据网段数并且简化路由再划分IP
2.配置DHCP服务,下发给主机IP
3.配置静态路由,使得内网全通
4.配置路由防止成环
5. 配置nat,使得公网与私网互通,
6.R6telentR5,实则登录R1
7.R4与R5正常通过1000M链路,故障时通过100m链路,即修改优先级
四、实验步骤:
分别给R1~R6配置IP地址和环回
[R1]int g 0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 30
Mar 21 2024 14:40:09-08:00 R1 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.1.5 30
Mar 21 2024 14:41:21-08:00 R1 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]q
[R1]int l0
[R1-LoopBack0]ip add 192.168.1.33 28
[R1-LoopBack0]int l1
[R1-LoopBack1]ip add 192.168.1.49 28
[R1-LoopBack1]q
[R1]dis ip int b
[R1]dis ip int brief
配置R2的IP和环回:
R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.1.2 30
Mar 21 2024 14:48:07-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 g 0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.1.9 30
Mar 21 2024 14:49:09-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]
[R2]int l0
[R2-LoopBack0]ip add 192.168.1.65 28
[R2-LoopBack0]int l1
[R2-LoopBack1]ip add 192.168.1.81 28
[R2-LoopBack1]q
配置R3
R3]int g 0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.1.6 30
Mar 21 2024 14:54:54-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 g 0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.1.13 30
Mar 21 2024 14:55:36-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
配置好IP地址后因为下面还有一个网段且都连接着两台主机pc1和pc2,直接用dhcp获取,所以下面就是给R3配置dhcp:
R3]dhcp en
[R3]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R3]ip pool aa
Info: It's successful to create an IP address pool.
R3-ip-pool-aa]net
[R3-ip-pool-aa]netbios-type
[R3-ip-pool-aa]network 192.168.1.96 mask 27
[R3-ip-pool-aa]ga
[R3-ip-pool-aa]gateway-list 192.168.1.97
R3-ip-pool-aa]dns-list 114.114.114.114 8.8.8.8
[R3-ip-pool-aa]int g 0/0/2
[R3-GigabitEthernet0/0/2]dhcp se
[R3-GigabitEthernet0/0/2]dhcp select q
[R3-GigabitEthernet0/0/2]dhcp select q
[R3-GigabitEthernet0/0/2]dhcp select g
[R3-GigabitEthernet0/0/2]dhcp select global (把dhcp下发到下面的pc端,还有dhcp服务器)
在pc端查看是否有地址分配,若还没有出现可能是延迟的原因
配置R4的环回和IP
R4]int g 0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.1.10 30
Mar 21 2024 14:57:00-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 g 0/0/1
[R4-GigabitEthernet0/0/1]ip add 192.168.1.14 30
Mar 21 2024 14:57:32-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]int g 0/0/2
[R4-GigabitEthernet0/0/2]ip add 192.168.1.17 30
Mar 21 2024 15:42:28-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R4-GigabitEthernet0/0/2]int g 4/0/0
[R4-GigabitEthernet4/0/0]ip add 192.168.1.21 30
Mar 21 2024 15:43:15-08:00 R4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet4/0/0 has entered the UP state.
[R4-GigabitEthernet4/0/0]
[R4]int l0
[R4-LoopBack0]ip add 192.168.1.129 28
[R4-LoopBack0]int l1
[R4-LoopBack1]ip add 192.168.1.145 28
给r5配置IP跟环回:
[R5]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip add 192.168.1.18 30
[R5-GigabitEthernet0/0/0]
Mar 24 2024 11:35:16-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 g 0/0/2
[R5-GigabitEthernet0/0/2]ip add 192.168.1.22 30
Mar 24 2024 11:35:39-08:00 R5 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[R5]int g 0/0/1
[R5-GigabitEthernet0/0/1]ip add 12.0.0.5 24(r5配置12.0.0.5主要是为了好记)
[R5-GigabitEthernet0/0/1]
Mar 24 2024 11:37:45-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]int l0
[R5-LoopBack0]ip add 192.168.1.161 27
配置R6的IP跟环回
[R6]int g 0/0/0
[R6-GigabitEthernet0/0/0]ip add 12.0.0.6 24
Mar 24 2024 11:41:14-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]int l0
[R6-LoopBack0]ip add 1.1.1.6 24
[R6-LoopBack0]q
[R6]
2.配置静态路由(私网通)
给R1配置静态路由:
[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]
[R1]ip route
[R1]ip route
[R1]ip route-static 192.168.1.128 27 192.168.1.2
[R1]ip route-static 192.168.1.128 27 192.168.1.6
[R1]
[R1]ip rou
[R1]ip route
[R1]ip route-static 192.168.1.16 30 192.168.1.2
[R1]ip route-static 192.168.1.16 30 192.168.1.6
[R1]ip
[R1]ip r
[R1]ip relay
[R1]ip route
[R1]ip route-static 192.168.1.160 27 192.168.1.2
[R1]ip route-static 192.168.1.160 27 192.168.1.6
[R1]ip ro
[R1]ip route
[R1]ip route-static 192.168.1.20 30 192.168.1.2
[R1]ip route-static 192.168.1.20 30 192.168.1.6
[R1]
[R1]ip ro
[R1]ip route
[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
最后用dis ip routing-table protocol static可以查看路由表
配置R2的静态路由;
[R2]ip route-static 192.168.1.128 27 192.168.1.10
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.1.16 30 192.168.1.10
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.1.160 27 192.168.1.10
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.1.20 30 192.168.1.10
[R2]
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.1.12 30 192.168.1.10
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.96 27 192.168.1.10
^
Error: Wrong parameter found at '^' position.
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.1.96 27 192.168.1.10
[R2]ip ro
[R2]ip route
[R2]ip route-static 192.168.1.96 27 192.168.1.1
[R2]ip rou
[R2]ip route
[R2]ip route-static 192.168.1.4 30 192.168.1.1
[R2]dis ro
[R2]dis rollback
[R2]dis route-policy
[R2]dis router
[R2]ip r
[R2]ip relay
[R2]ip route
[R2]ip route-static 192.168.1.32 27 192.168.1.1
[R2]dis ip r
[R2]dis ip rd-filter
[R2]dis ip routing-table p
[R2]dis ip routing-table protocol s
[R2]dis ip routing-table protocol static
配置R3的静态路由:
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.32 27 192.168.1.5
[R3]ip ro
[R3]ip route
[R3]ip route-static
^
Error:Incomplete command found at '^' position.
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.0 30 192.168.1.5
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.64 27 192.168.1.5
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.64 27 192.168.1.14
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.8 30 192.168.1.14
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.128 27 192.168.1.14
[R3]ip
[R3]ip ro
[R3]ip route-static
[R3]ip route
[R3]ip route-static 192.168.1.16 30 192.168.1.14
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.160 27 192.168.1.14
[R3]ip ro
[R3]ip route
[R3]ip route-static 192.168.1.20 30 192.168.1.14
[R3]dis ip rp
[R3]dis ip ro
[R3]dis ip routing-table p
[R3]dis ip routing-table protocol s
[R3]dis ip routing-table protocol static
配置R4的静态路由:
[R4]ip route-static 192.168.1.96 27 192.168.1.13
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.4 30 192.168.1.13
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.32 27 192.168.1.13
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.32 27 192.168.1.9
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.64 27 192.168.1.9
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.0 30 192.168.1.9
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.160 27 192.168.1.18
[R4]ip ro
[R4]ip route
[R4]ip route-static 192.168.1.160 27 192.168.1.22
[R4]dis ip r
[R4]dis ip rd-filter
[R4]dis ip routing-table p
[R4]dis ip routing-table protocol s
[R4]dis ip routing-table protocol static
配置r5的静态路由:
[R5]ip ro
[R5]ip route
[R5]ip route-static 192.168.1.128 27 192.168.1.17
[R5]
[R5]ip route-static 192.168.1.128 27 192.168.1.17
[R5]
[R5]ip route-static 192.168.1.128 27 192.168.1.17
Error: The route already exists.
[R5]
[R5]ip route-static 192.168.1.128 27 192.168.1.21
[R5]ip route-static 192.168.1.12 30 192.168.1.17
[R5]ip route-static 192.168.1.128 27 192.168.1.21
Error: The route already exists.
[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.17
[R5]ip route-static 192.168.1.96 27 192.168.1.21
[R5]ip route-static 192.168.1.4 30 192.168.1.17
[R5]ip route-static 192.168.1.4 30 192.168.1.21
[R5]ip route-static 192.168.1.32 27 192.168.1.17
[R5]ip route-static 192.168.1.32 27 192.168.1.21
[R5]ip route-static 192.168.1.0 30 192.168.1.17
[R5]ip route-static 192.168.1.0 30 192.168.1.21
[R5]ip route-static 192.168.1.64 27 192.168.1.17
[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.17
[R5]ip route-static 192.168.1.8 30 192.168.1.21
[R5]dis ip r
[R5]dis ip rd-filter
[R5]dis ip routing-table p
[R5]dis ip routing-table protocol s
[R5]dis ip routing-table protocol static
r1去ping一下看是否内网通了(有延迟是正常)
3.给r5配置缺省路由,不能配置明细;
配置缺省的目的:1.是为了做nat的时候把内网中pc所发出去的流量能顺利带到公网的路由器上,即使配错了,也可以通过缺省到公网
- 4.避免环路,在配置了环回接口的地方配置防环机制(静态防环)
五、配置nat
Ping1.1.1.6发现ping不通,搞缺省
给r1~r4配置缺省:
发现能够ping通
配置telnet
测试:
七、R4与R5正常通过1000M链路,故障时通过100m链路
[R4]ip route-static 0.0.0.0 0 192.168.1.22 preference 61
R5配置:
[R5]ip route-static 192.168.1.0 30 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.4 30 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.4 30 192.168.1.21 preference 61
Error: The route already exists.
[R5]ip route-static 192.168.1.8 30 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.12 30 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.32 27 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.64 27 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.96 27 192.168.1.21 preference 61
Info: Succeeded in modifying route.
[R5]ip route-static 192.168.1.128 27 192.168.1.21 preference 61
Info: Succeeded in modifying route.
测试