计算机网络配置——路由器的配置

news/2025/2/12 23:50:26/

 一、实验目的和任务

  1. 学习路由器的基本工作原理;
  2. 进行路由器命令的操作练习;
  3. 进行路由策略的设置。

二、实验原理介绍

重点:路由器和交换机的区别;

   路由器功能——实现网络互连,包括存储、转发、寻径;

1、路由器的工作过程

 

2、路由器的配置模式

   1)普通用户模式;

   2)特权用户模式;

   3)全局配置模式;

   4)接口配置模式;

   5)路由协议配置模式;

二、路由器的基本配置

实现如下图所示的网络拓扑配置:

三、设计代码(或原理图)、仿真波形及分析

网络拓扑结构如下图所示:

PC0&PC1地址配置,网关配置如图中标记所示

R2配置如下:(有解释)

Would you like to enter the initial configuration dialog? [yes/no]: nPress 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 upR2(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 consoleR2#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 downR2#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - 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 - ODRP - periodic downloaded static routeGateway of last resort is not setC    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 upR2(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 - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - 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 - ODRP - periodic downloaded static routeGateway of last resort is not setC    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/0R2#
//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/255Encapsulation ARPA, loopback not setFull-duplex, 100Mb/s, media type is RJ45ARP type: ARPA, ARP Timeout 04:00:00, Last input 00:00:08, output 00:00:05, output hang neverLast clearing of "show interface" counters neverInput queue: 0/75/0 (size/max/drops); Total output drops: 0Queueing strategy: fifoOutput queue :0/40 (size/max)5 minute input rate 0 bits/sec, 0 packets/sec5 minute output rate 5 bits/sec, 0 packets/sec12 packets input, 1536 bytes, 0 no bufferReceived 0 broadcasts, 0 runts, 0 giants, 0 throttles0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort0 input packets with dribble condition detected12 packets output, 1212 bytes, 0 underruns0 output errors, 0 collisions, 1 interface resets0 babbles, 0 late collision, 0 deferred0 lost carrier, 0 no carrier0 output buffer failures, 0 output buffers swapped out

R3配置如下:(解释类同R2)

Would you like to enter the initial configuration dialog? [yes/no]: nPress 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 shutdownR3(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to upR3(config-if)#int s0/0/0
R3(config-if)#ip addr 192.168.6.2 255.255.255.0
R3(config-if)#no shutdownR3(config-if)#
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to upR3(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to upR3(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 consoleR3#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 - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGPi - 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 - ODRP - periodic downloaded static routeGateway of last resort is not setS    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/0R3#

PC0连接PC1:

PC1连接PC0:

四、实验结论与心得

  • 注意

由于新加入的路由器没有串行接口,故需要手动添加,步骤如下:

1.先把路由器的电源关掉。

2.把物理串口拖动到路由器接口处。

3.启动步骤1中的电源,然后进入CLI配置页面,等待初始化完成,点击确定即可。

  • 路由器配置文件保存类似交换机,在这里不作介绍,可参考文章:计算机网络配置——交换机的配置

http://www.ppmy.cn/news/384695.html

相关文章

运维圣经:DDos攻击应急响应指南

目录 DDos攻击简介 DDos攻击应急响应指南 一. 问题排查 二. 临时处置 三. 研判溯源 四. 清楚加固 DDos攻击简介 分布式拒绝服务是种基于DoS的特殊形式的拒绝服务攻击,是一种分布、 协作的大规模攻击方式,主要瞄准比较大的站点,像商业公…

JDK常用的数据类型【1】 ——HashMap(分享篇)

x mod 2^n x & (2^n - 1) 1. 拿到 key 的 hashCode 值 2. 将 hashCode 的高位参与运算,重新计算 hash 值 3. 将计算出来的 hash 值与 (table.length - 1) 进行 & 运算数据结构 1.B树 和 B树 B树叶子节点可以存放多个元素B树的叶子节点之间是有指针的 红…

AndroidTV焦点问题总结

AndroidTV焦点问题总结 焦点1.确定当前焦点位置2.子view焦点跟随父View变化3.设置下一个获取焦点的View4.设置父View和子View哪个获取焦点5.常用的按键值7.控制RecycleView焦点跳转逻辑8.其他View焦点跳转到RecyclerView9.ViewGroup的某个子View获取焦点 焦点 1.确定当前焦点位…

Spring的存储与获取Bean

Spring的存储与获取Bean 🔎Spring—存储Bean配置扫描路径利用类注解进行存储添加注解存储Bean关于Id为什么需要五个类注解类注解之间的关系 利用方法注解进行存储关于Id 🔎Spring—获取Bean属性注入Set注入构造方法注入总结(Spring的注入方式? 它们之间…

运维圣经:Webshell应急响应指南

目录 Webshell简介 Webshell检测手段 Webshell应急响应指南 一. Webshell排查 二. 确定入侵时间 三. Web日志分析 四. 漏洞分析 五. 漏洞复现 六. 清除Webshell并修复漏洞 七. Webshell防御方法 Webshell简介 Webshell通常指以JSP、ASP、 PHP等网页脚本文件形式存在…

IM相关技术

messages表 保存的消息记录(Saved Messages) bff,session TON以及tdlib 官方版设置中文 tg://setlanguage?langclassic-zh-cn https://web.telegram.org/k/ https://web.telegram.org/a/ https://github.com/TGX-Android https://github.com/NekoX-Dev/NekoX, 内置公共代理不…

【第9题】容斥原理:P3197 [HNOI2008]越狱

题目:P3197 [HNOI2008]越狱 题目原文请移步下面的链接 https://www.luogu.com.cn/problem/P3197 参考题解:https://www.luogu.com.cn/problem/solution/P3197 标签:OI、 数学、容斥 题解 思路 第一点:排列组合的问题&#xf…

怎么快速给需要的网路标记颜色?

引入 我们在走线的时候,需要知道那些类型的线需要先走,接下来又要走那些类型的线,然后依次走完,如果在团队中,这一类型的线分配给这个人走,哪一类型的线有分配给那个人走。而在不管是那单个人,还…