CCNA学习笔记10--静态路由(包括三个实验)
1.什么是路由?
如果两个网络之间需要访问,那么就需要路由
2.路由的功能?
选路
转发
3.静态路由的实验一
实验拓扑:
实验目的:
练习静态路由,使1.1.1.1能ping通2.2.2.2。
实验操作:
① 配置基本配置 Router>enable Router#configure terminal Router(config)#enable password cisco Router(config)#no ip domain lookup Router(config)#line console 0 Router(config-line)#password cisco Router(config-line)#logging synchronous Router(config-line)#exec-timeout 0 0 Router(config-line)#exit Router(config)#line vty 0 4 Router(config-line)#password cisco Router(config-line)#logging synchronous Router(config-line)#exit Router(config)#hostname R1 R1(config)#^Z R1#wr Building configuration... [OK] |
② 环回口和接口配置IP 地址 R1(config)#interface loopback 0 R1(config-if)#ip address 1.1.1.1 255.255.255.0 R1(config-if)#no shutdown R1(config)#interface ethernet 0/0 R1(config-if)#ip address 10.0.12.1 255.255.255.0 R1(config-if)#no shutdown |
③配置静态路由 R1(config)#ip route 2.2.2.0 255.255.255.0 10.0.12.2 R1(config)#do show ip route 1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 1.1.1.0/24 is directly connected, Loopback0 L 1.1.1.1/32 is directly connected, Loopback0 2.0.0.0/24 is subnetted, 1 subnets S 2.2.2.0 [1/0] via 10.0.12.2 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.0.12.0/24 is directly connected, Ethernet0/0 L 10.0.12.1/32 is directly connected, Ethernet0/0 R2(config)#ip route 1.1.1.0 255.255.255.0 10.0.12.1 解释说明: 第一列:描述的该条路由通过什么方式学习到的。 第二例:目的网络 第三列:【1/0】【AD/Metric】 第四列:via下一跳 第五列:出接口 |
④测试 R1#ping 2.2.2.2 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/5 ms |
解释说明:AD和Meric
AD:管理距离,每个不同的路由获取方式(不同的路由协议),有不同的AD 值。
AD和Meric是路有选择需要用到的值,如果有两条目的网络相同的路由,那么选择AD小的走。如果AD值一样,选择Meric小的。
AD
路由协议 |
AD |
直连路由 |
0 |
静态路由 |
1 |
RIP |
120 |
OSPF |
110 |
EIGRP |
90 |
Meric
路由协议 |
Meric的计算方式 |
直连路由 |
0 |
静态路由 |
0 |
RIP |
基于跳数 |
OSPF |
基于带宽 |
EIGRP |
基于带宽,延迟,可靠性,负载,MTU(思科私有协议) |
例:
10.0.12.0/24[100/10]
10.0.12.0/24[10/100000000]------将选择这一条
例:
10.0.12.0/24[100/10]
10.0.12.0/24[100/10]
两条一模一样,实现负载均衡
例:
10.0.0.0/8 [10/100]
10.1.0.0/16 [10/50]
10.1.1.0/24 [50/100]
10.1.1.1/32 [30/10]------将选择这一条
不同网络之间的选路:最长掩码匹配原则
如果路由表中有多条路由能把数据送到目的地,那么选择掩码最长的
4.静态路由的实验二
实验拓扑:
实验目的:
充分练习静态路由的配置
实验步骤:
①配上基本配置 Router> Router>enable Router#configure terminal Router(config)#enable password cisco Router(config)#no ip domain lookup Router(config)#line console 0 Router(config-line)#password cisco Router(config-line)#logging synchronous Router(config-line)#exec-timeout 0 0 Router(config-line)#exit Router(config)#line vty 0 4 Router(config-line)#password cisco Router(config-line)#logging synchronous Router(config-line)#exit Router(config)#hostname R3 R3(config)#^Z R3#wr *May 20 09:18:25.131: %SYS-5-CONFIG_I: Configured from console by console R3#wr Building configuration... [OK] |
②配置各端口和环回口的IP地址 R3(config)#interface loopback 0 R3(config-if)#ip address 1.1.1.1 255.255.255.0 R3(config)#interface ethernet 0/0 R3(config-if)#ip address 10.0.12.1 255.255.255.0 R3(config-if)#no shutdown |
③配置静态路由 R3(config)# ip route 2.2.2.0 255.255.255.0 10.0.12.2 R3(config)#ip route 10.0.23.0 255.255.255.0 10.0.12.2 R3(config)#ip route 3.3.3.0 255.255.255.0 10.0.12.2 R4(config)#ip route 3.3.3.0 255.255.255.0 10.0.23.3 R5(config)#ip route 2.2.2.0 255.255.255.0 10.0.23.2 R5(config)#ip route 10.0.12.0 255.255.255.0 10.0.23.2 R4(config)#ip route 1.1.1.0 255.255.255.0 10.0.12.1 R5(config)#ip route 1.1.1.0 255.255.255.0 10.0.23.2 |
④测试 R3#ping 2.2.2.2 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
R3#ping 10.0.23.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.23.3, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
R3#ping 10.0.23.3 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.23.3, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
R3#ping 3.3.3.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms
R3#ping 3.3.3.3 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms |
5.静态路由的实验三
实验拓扑:
实验目的:
进一步练习静态路由
实验步骤:
① 基本配置 |
② 每个端口和本地环回口配置ip地址 |
③ 配置静态路由 R6(config)#ip route 2.2.2.0 255.255.255.0 10.0.12.2 R6(config)#ip route 10.0.23.0 255.255.255.0 10.0.12.2 R6(config)#ip route 3.3.3.0 255.255.255.0 10.0.12.2 R6(config)#ip route 10.0.34.0 255.255.255.0 10.0.12.2 R6(config)#ip route 4.4.4.0 255.255.255.0 10.0.12.2
R7(config)#ip route 3.3.3.0 255.255.255.0 10.0.23.3 R7(config)#ip route 10.0.34.0 255.255.255.0 10.0.23.3 R7(config)#ip route 4.4.4.0 255.255.255.0 10.0.23.3 R7(config)#ip route 1.1.1.0 255.255.255.0 10.0.12.1
R8(config)#ip route 4.4.4.0 255.255.255.0 10.0.34.4 R8(config)#ip route 2.2.2.0 255.255.255.0 10.0.23.2 R8(config)#ip route 10.0.12.0 255.255.255.0 10.0.23.2 R8(config)#ip route 1.1.1.0 255.255.255.0 10.0.23.2
R9(config)#ip route 3.3.3.0 255.255.255.0 10.0.34.3 R9(config)#ip route 10.0.23.0 255.255.255.0 10.0.34.3 R9(config)#ip route 2.2.2.0 255.255.255.0 10.0.34.3 R9(config)#ip route 10.0.12.0 255.255.255.0 10.0.34.3 R9(config)#ip route 1.1.1.0 255.255.255.0 10.0.34.3 |
4. 测试 R6#ping 4.4.4.4 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms |