部分基础
ip地址:三点分十进制 c类私有地址:192.168.0.0 -192.168.255.255
子网掩码:255.255.255.0 24位掩码
网段:192.168.1.0/24 表示IP地址192.168.1.0和子网掩码255.255.255.0,其中24表示子网掩码中有24个连续的1。
Router#show ip route 查询路由表
路由类型:直连路由 、静态路由 、动态路由
路由表:存储路由条目 C--直连 S--静态
静态路由:手动指定 实现不同网段之间的通信
Router#show ip interface brief 查询接口IP地址
如果在全局配置模式下查询命令加上do
例如do show ip route
Router> 用户模式 :不能去ip地址,协议 基本查询
Router>enable 进入到特权模式
Router# 特权模式 :不能做配置,但是能实现完整查询功能
Router#configure terminal 进入到全局配置模式
Router(config)#interface fastEthernet 0/0 //进入对应接口
Router(config-if)# //接口视图
Router(config-if)#ip address 192.168.1.1 255.255.255.0 //配置ip地址
Router(config-if)#no shutdown //开启接口
Router#ping 192.168.1.2 //测试连通性
静态路由:
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
192.168.1.0 //目标范围
255.255.255.0 //掩码
192.168.2.1 //下一跳出接口地址
Router(config)#hostname XX //修改设备名称
loopback 虚拟环回口 作用:测试非直连连通性,标识
R1(config)#interface loopback 0 //进入loopback 接口上 0为你随机设置的名称
R1(config-if)#ip address 1.1.1.1 255.255.255.0
实验拓扑
实验配置
1) 参照拓扑结构,使用合适的线缆对路由器和交换机完成拓扑的搭建
2) 完成各路由器的设备名和 IP 地址的基本配置,实现各设备直连链路之间可以互 ping,
各路由器的直连接口地址自行规划
3) 在路由器 R1、路由器 R2 和路由器 R3 上各新增一个 Loopback 接口,模拟各 LAN所在的主机,自行规划 LAN1 、 LAN2 和 LAN3 所在网段的地址
4) 在路由器 R1 上创建两条分别到达 LAN2 、 LAN3 所在网段的静态路由
5) 在路由器 R2 上创建两条分别到达 LAN1 、 LAN3 所在网段的静态路由
6) 在路由器 R3 上创建两条分别到达 LAN1 、 LAN2 所在网段的静态路由
7) 使用 ping 命令测试 LAN1 、 LAN2 、 LAN3 主机之间的连通性
8) 观察 R1、R2、R3 的路由表,比较不同路由表的内容,并分析 LAN1 分别访问 LAN2、
LAN3 的数据通信过程
9) 完成相关配置,使 R4主机去访问 LAN1 时实现链路备份,当R2与R4相连链路故障时能够切换另外的一条线路进行通信
实验需求
1) ip地址配置
Router>en
Router#config
Router(config)#hostname R2
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface fastEthernet 0/1
R2(config-if)#ip address 192.168.24.2 255.255.255.0
R2(config-if)#no shutdown
R1 R3 R4同
R2(config-if)#
R2(config)#ip route 192.168.13.0 255.255.255.0 192.168.12.1
R2(config)#ip route 192.168.34.0 255.255.255.0 192.168.24.4
R2(config)#exit
R1 R3 R4 同
Ping测试成功
2) 环回口配置
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R2 R3 同
3) 在路由器 R1 上创建两条分别到达 LAN2 、 LAN3 所在网段的静态路由
R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.12.2
R1(config)#ip route 3.3.3.0 255.255.255.0 192.168.13.3
4) 在路由器 R2 上创建两条分别到达 LAN1 、 LAN3 所在网段的静态路由
R2(config)#ip route 3.3.3.0 255.255.255.0 192.168.12.1
R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.12.1
5) 在路由器 R3 上创建两条分别到达 LAN1 、 LAN2 所在网段的静态路由
R3(config)#ip route 1.1.1.0 255.255.255.0 192.168.13.1
R3(config)#ip route 2.2.2.0 255.255.255.0 192.168.13.1
8)完成相关配置,使 R4主机去访问 LAN1 时实现链路备份,当R2与R4相连链路故障时能够切换另外的一条线路进行通信
R4(config)#ip route 1.1.1.0 255.255.255.0 192.168.24.2
R4(config)#ip route 1.1.1.0 255.255.255.0 192.168.34.3
实验测试
使用 ping 命令测试 LAN1 、 LAN2 、 LAN3 主机之间的连通性
发现R1可ping 2.2.2.2 与3.3.3.3 R2 R3可ping 1.1.1.1 R2也可ping 3.3.3.3 R3也可ping 2.2.2.2
链路备份 R4测试LAN1 ,断开与R2相连接的链路后测试连通性
2=====》3
ping 数据包
源IP:192.168.12.2
目标IP:3.3.3.3
原IP可通(via)(查看路由表)
相反的
源IP:3.3.3.3
目标IP:192.168.12.2
回程也必须可via
实操部分
R1(config)#interface fastEthernet 0/1
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.13.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
Router>en
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#int
R2(config)#interface fastEthernet 0/1
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 192.168.24.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exit
Router>
Router>en
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R3
R3(config)#interface fastEthernet 0/1
R3(config-if)#ip address 192.168.13.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface fastEthernet 0/0
R3(config-if)#ip address 192.168.34.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
Router>en
Router#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R4
R4(config)#interface fastEthernet 0/1
R4(config-if)#ip address 192.168.24.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit
R4(config)#interface fastEthernet 0/0
R4(config-if)#ip address 192.168.34.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exit
R1(config)#ip route 192.168.24.0 255.255.255.0 192.168.12.2
R1(config)#ip route 192.168.34.0 255.255.255.0 192.168.13.3
R2(config)#ip route 192.168.13.0 255.255.255.0 192.168.12.1
R2(config)#ip route 192.168.34.0 255.255.255.0 192.168.24.4
R3(config)#ip route 192.168.24.0 255.255.255.0 192.168.34.4
R3(config)#ip route 192.168.12.0 255.255.255.0 192.168.13.1
R4(config)#ip route 192.168.12.0 255.255.255.0 192.168.24.2
R4(config)#ip route 192.168.13.0 255.255.255.0 192.168.34.3
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R1(config)#ip route 2.2.2.0 255.255.255.0 192.168.12.2
R1(config)#ip route 3.3.3.0 255.255.255.0 192.168.13.3
R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.12.1
R2(config)#ip route 3.3.3.0 255.255.255.0 192.168.12.1
R3(config)#ip route 1.1.1.0 255.255.255.0 192.168.13.1
R3(config)#ip route 2.2.2.0 255.255.255.0 192.168.13.1
R4(config)#ip route 1.1.1.0 255.255.255.0 192.168.24.2
R4(config)#ip route 1.1.1.0 255.255.255.0 192.168.34.3
R4(config)#interface fastEthernet 0/1
R4(config-if)#shutdown
R4(config)#interface fastEthernet 0/1
R4(config-if)#no shutdown
我遇到的问题;
- 设备一般是符合情形的,协议是可用的
- 线的连接符合,自己内心有所把握,1-2 1-3 2-1 2-4 3-1 3-4 4-2 4-3
- 记得命名,方便查错,清晰明了 R1 R2 R3 R4
- 配置时不用拔电脑的接口,拔路由器的接口就行,不必多开窗口
- 边做适当检验