一、实验目的和任务
- 学习路由器的基本工作原理;
- 进行路由器命令的操作练习;
- 进行路由策略的设置。
二、实验原理介绍
重点:路由器和交换机的区别;
路由器功能——实现网络互连,包括存储、转发、寻径;
1、路由器的工作过程
2、路由器的配置模式
1)普通用户模式;
2)特权用户模式;
3)全局配置模式;
4)接口配置模式;
5)路由协议配置模式;
二、路由器的基本配置
实现如下图所示的网络拓扑配置:
三、设计代码(或原理图)、仿真波形及分析
网络拓扑结构如下图所示:
R2配置如下:(有解释)
Would you like to enter the initial configuration dialog? [yes/no]: n
Press RETURN to get started!
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2 //命名
R2(config)#int f0/0 //进入以太网接口
R2(config-if)#ip add 192.168.1.1 255.255.255.0 //给接口fa0/0设置网关 子网掩码
R2(config-if)#no shutdown //激活接口
R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#ex
R2(config)#int s0/0/0 //串行接口
R2(config-if)#clock rate 64000 //设置波特率(路由器没锁定时可自由设置)
This command applies only to DCE interfaces
R2(config-if)#ip add 192.168.6.1 255.255.255.0 //给接口s0/0/0设置网关 子网掩码
R2(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to down
R2(config-if)#ex
R2(config)#ip route 192.168.2.0 255.255.255.0 192.168.6.2 //设置静态路由
R2(config)#end //配置结束
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#sh ip int brief //查看接口配置
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/0/0 192.168.6.1 YES manual down down
Serial0/0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
R2#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, FastEthernet0/0
//*******在配置R3时,R2会[自动]执行下面部分指令*****//
R2#
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface Serial0/0/0
R2(config-if)#
R2(config-if)#exit
R2(config)#interface FastEthernet0/1
R2(config-if)#
R2(config-if)#exit
R2(config)#interface Serial0/0/1
R2(config-if)#
R2(config-if)#exit
R2(config)#interface Serial0/0/0
R2(config-if)#
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up
R2(config-if)#end
R2(config-if)#end
R2#
%SYS-5-CONFIG_I: Configured from console by console
//******配置完R3后,回到R2执行下面命令,即可到静态路由表*********//
R2#sh ip route //查看路由表
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
C 192.168.1.0/24 is directly connected, FastEthernet0/0 //前面地址为目的网络,后面Fa...为通往目的网络的接口
S 192.168.2.0/24 [1/0] via 192.168.6.2
C 192.168.6.0/24 is directly connected, Serial0/0/0
R2#
//Codes表示路由项生成的方式,C表示直连路由;S表示静态路由;R表示RIP协议生成;O表示OPSF协议生成。
R2>en
R2#sh int f0/0 //查看具体接口的信息
FastEthernet0/0 is up, line protocol is up (connected)
Hardware is Lance, address is 0010.11e0.9d01 (bia 0010.11e0.9d01) //接口物理地址
Internet address is 192.168.1.1/24 //接口IP地址
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, //BW为带宽;DLY为延时
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Full-duplex, 100Mb/s, media type is RJ45
ARP type: ARPA, ARP Timeout 04:00:00,
Last input 00:00:08, output 00:00:05, output hang never
Last clearing of "show interface" counters never
Input queue: 0/75/0 (size/max/drops); Total output drops: 0
Queueing strategy: fifo
Output queue :0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 5 bits/sec, 0 packets/sec
12 packets input, 1536 bytes, 0 no buffer
Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
0 input packets with dribble condition detected
12 packets output, 1212 bytes, 0 underruns
0 output errors, 0 collisions, 1 interface resets
0 babbles, 0 late collision, 0 deferred
0 lost carrier, 0 no carrier
0 output buffer failures, 0 output buffers swapped out
R3配置如下:(解释类同R2)
Would you like to enter the initial configuration dialog? [yes/no]: n
Press RETURN to get started!
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#hostname R3
R3(config)#int f0/0
R3(config-if)#ip addr 192.168.2.1 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config-if)#int s0/0/0
R3(config-if)#ip addr 192.168.6.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up
R3(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up
R3(config-if)#ex
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.6.1
R3(config)#end
R3#
%SYS-5-CONFIG_I: Configured from console by console
R3#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.2.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/0/0 192.168.6.2 YES manual up up
Serial0/0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
R3#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
S 192.168.1.0/24 [1/0] via 192.168.6.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0
C 192.168.6.0/24 is directly connected, Serial0/0/0
R3#
PC0连接PC1:
PC1连接PC0:
四、实验结论与心得
- 注意
由于新加入的路由器没有串行接口,故需要手动添加,步骤如下:
1.先把路由器的电源关掉。
2.把物理串口拖动到路由器接口处。
3.启动步骤1中的电源,然后进入CLI配置页面,等待初始化完成,点击确定即可。
- 路由器配置文件保存类似交换机,在这里不作介绍,可参考文章:计算机网络配置——交换机的配置