对于想了解路由器的读者,本文将是一篇不可错过的文章,我们将详细介绍Router、交换机,并且为您提供关于./node_modules/react-router-dom/react-router-dom
对于想了解路由器的读者,本文将是一篇不可错过的文章,我们将详细介绍Router、交换机,并且为您提供关于./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”、Azure Event Hub (2) 使用Azure AD授权访问Event Hub、Azure Event Hub 技术研究系列2-发送事件到Event Hub、CCIE总结:路由器、交换机的有价值信息。
本文目录一览:- 路由器(Router)、交换机(Switch)和集线器(Hub)(路由器,交换机,集线器)
- ./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”
- Azure Event Hub (2) 使用Azure AD授权访问Event Hub
- Azure Event Hub 技术研究系列2-发送事件到Event Hub
- CCIE总结:路由器、交换机
路由器(Router)、交换机(Switch)和集线器(Hub)(路由器,交换机,集线器)
一、路由器(Router)
路由器是工作在OSI第三层-网络层上、具有连接不同类型网络的能力并能够选择数据传送路径的网络设备。因此它的三个特征是:工作在网络层上、能够连接不同类型的网络、能够选择数据传送路径
1、路由器工作在第三层上,路由器是第三层网络设备,这样说大家可能都不理解,就先说一下集线器和交换机吧。集线器工作在第一层(即物理层),它没有智能处理能力,对它来说,数据只是电流而已,当一个端口的电流传到集线器中时,它只是简单地将电流传送到其他端口,至于其他端口连接的计算机接收不接收这些数据,它就不管了。交换机工作在第二层(即数据链路层),它要比集线器智能一些,对它来说,网络上的数据就是MAC地址的集合,它能分辨出帧中的源MAC地址和目的MAC地址,因此可以在任意两个端口间建立联系,但是交换机并不懂得IP地址,它只知道MAC地址。路由器工作在第三层(即网络层),它比交换机还要“聪明”一些,它能理解数据中的IP地址,如果它接收到一个数据包,就检查其中的IP地址,如果目标地址是本地网络的就不理会,如果是其他网络的,就将数据包转发出本地网络。
2、路由器能连接不同类型的网络,我们常见的集线器和交换机一般都是用于连接以太网的,但是如果将两种网络类型连接起来,比如以太网与ATM网,集线器和交换机就派不上用场了。路由器能够连接不同类型的局域网和广域网,如以太网、ATM网、FDDI网、令牌环网等。不同类型的网络,其传送的数据单元——帧(Frame)的格式和大小是不同的,就像公路运输是汽车为单位装载货物,而铁路运输是以车皮为单位装载货物一样,从汽车运输改为铁路运输,必须把货物从汽车上放到火车车皮上,网络中的数据也是如此,数据从一种类型的网络传输至另一种类型的网络,必须进行帧格式转换。路由器就有这种能力,而交换机和集线器就没有。实际上,我们所说的“互联网”,就是由各种路由器连接起来的,因为互联网上存在各种不同类型的网络,集线器和交换机根本不能胜任这个任务,所以必须由路由器来担当这个角色。
3、路由器具有路径选择能力,在互联网中,从一个节点到另一个节点,可能有许多路径,路由器可以选择通畅快捷的近路,会大大提高通信速度,减轻网络系统通信负荷,节约网络系统资源,这是集线器和二层交换机所根本不具备的性能。
二、交换机(Switch)
交换机是一种基于MAC(网卡的硬件地址)识别,能完成封装转发数据包功能的网络设备。交换机可以“学习”MAC地址,并把其存放在内部地址表中,通过在数据帧的始发者和目标接收者之间建立临时的交换路径,使数据帧直接由源地址到达目的地址。
局域网交换机的定义
以太网、快速以太网、FDDI和令牌环网常被称为传统局域网,它们都是共享介质、共享带宽的共享式局域网。为了提高带宽,往往采用路由器进行网络分割,将一个网络分为多个网段,每个网段有不同的子网地址,不同的广播域,以减少网络上的冲突,提高网络带宽。微化网段已不能适应局域网扩展和新的网络应用对高带宽的需求,有人说“传统局域网已走到尽头”。
近几年突起的交换式局域网技术,能够解决共享式局域网所带来的网络效率低、不能提供足够的网络带宽和网络不易扩展等一系列问题。它从根本上改变了共享式局域网的结构,解决了带宽瓶颈问题。目前已有交换以太网、交换令牌环、交换FDDI和ATM等交换局域网,其中交换以太网应用最为广泛。交换局域网已成为当今局域网技术的主流。
交换机提供了桥接能力以及在现存网络上增加带宽的功能。用于L A N上的交换机与网桥相似,因为它们都运作在数据链路层(第2层)的M A C子层上,都检验着所有进入的网络流量的设备地址。与网桥还有一点相似,交换机保持一张有关地址的信息表,并用该信息来决定如何过滤并转发L A N流量。
与网桥不同,交换机采用交换技术来增加数据的输入输出总和和安装介质的带宽。一般交换机转发延迟很小,能经济地将网络分成小的冲突网域,为每个工作站提供更高的带宽。
三、集线器(Hub)
集线器,英文名又称Hub,在OSI模型中属于数据链路层。价格便宜是它最大的优势,但由于集线器属于共享型设备,导致了在繁重的网络中,效率变得十分低下,所以我们在中、大型的网络中看不到集线器的身影。如今的集线器普遍采用全双工模式,市场上常见的集线器传输速率普遍都为100Mbps。接下来我们了解一下集线器的几个概念:
共享型
集线器最大的特点就是采用共享型模式,就是指在有一个端口在向另一个端口发送数据时,其他端口就处于“等待”状态。为什么会“等待”呢?举个例子来说,其实在单位时间内A向B发送数据包时,A是发送给B、C、D三个端口的(该现象即紧接下文介绍的IP广播),但是只有B接收,其他的端口在第一单位时间判断不是自己需要的数据后将不会再去接收A发送来的数据。直到A再次发送IP广播,在A再次发送IP广播之前的单位时间内,C、D是闲置的,或者C、D之间可以传输数据。我们可以理解为集线器内部只有一条通道(即公共通道),然后在公共通道下方就连接着所有端口。
IP广播
所谓IP广播(也称:群发),是指集线器在发送数据给下层设备时,不分原数据来自何处,将所得数据发给每一个端口,如果其中有端口需要来源的数据,就会处于接收状态,而不需要的端口就处于拒绝状态。举个例子来说:在网内时,当客户端A发送数据包给客户端B时,集线器便将来自A的数据包群发给每一个端口,此时B就处于接收状态,其它端口则处于拒绝状态;在网外也如此,当客户端A发送域名“https://www.toutiao.com/”时,通过集线器,然后经过DNS域名解析把IP地址(202.108.36.172)发回给集线器。此时,集线器便群发给所有接入的端口,需要此地址的机器便处于接收状态(客户端A处于接收状态),不需要则处于拒绝状态。
单位时间
这应该是最简单的一个名词了,也可以理解为Hub的工作频率,比如工作频率为33MHz的Hub,那么在单位时间内Hub能做什么事呢?上面在解释共享型的时候已经举了个例子,但是有一点在这需要解释的是,比如我们有的时候会看到A在向B发送数据的“同时”,C也在向D传送数据,这看起来似乎有点矛盾,也确实是这样,那为什么会看起来2者同时在进行呢?因为A在第一个单位时间内发送数据给B的时候,由于广播的原因,B、C、D在第一个单位时间内会同时接受广播,但是C,D会从第2个单位时间开始拒绝接收A发来的数据,因为C和D已经判断出这些数据不是他们需要的数据。而且在第2个单位时间的时候C也发送一个数据广播,A,B,D都接受,但是只有D会接收这些数据。这些操作只用2到3个单位时间,但是我们却很难察觉到,感觉上就是在同时“进行”一样。
四、路由器(Router)与交换机(Switch)的区别
- 路由器可以给你的局域网自动分配IP,像一个交通警察,指挥着你的电脑往哪走;交换机是用来分配网络数据的
- 路由器在网络层,它根据IP地址寻址,路由器可以处理TCP/IP协议,交换机不可以;交换机在中继层,它根据MAC地址寻址
- 路由器可以把一个IP分配给很多个主机使用,这些主机对外只表现出一个IP;交换机可以把很多主机连起来,这些主机对外各有各的IP
- 路由器可以提供防火墙,交换机不提供该功能。集线器和交换机都是做端口扩展的,就是扩大局域网的接入点,也就是让局域网能连进来更多的电脑;路由器用来做网络连接,也就是连接不同的网络
- 路由器相当于邮局,把信投递到收件人地址,它的任务就完成。但是信邮到你们宿舍楼,而这个地址不是你一个人专享的,所以楼管王大爷(交换机)还需要把信给到你手里,他不关心收件人地址,只看收件人姓名,然后打电话叫你来取。没有邮局,就不能向世界各地的朋友发信。但是楼管王大爷的存在,可以使你与同宿舍楼的朋友书信来往。邮局系统构成的就是广域网,而宿舍楼就是局域网,构建局域网不需要路由器。
五、交换机和集线器的区别
- 集线器是许多个端口的转发器,工作位于物理层,是1层设备;而交换机采用的是MAC转发,工作位于数据链路层,是2层设备
- 集线器的端口是共享网络带宽,端口接入越多,网络速度越慢,它的网速会被其他端口所占用;而交换机是每个端口独享网络带宽,例如我们平时使用的百兆交换机,它能保障每个端口都有百兆的网络带宽
- 集线器连接的所有设备都是评分带宽,因为集线器上只有一根通信线路,因此带宽平分。当其中一台设备发数据时,其他设备都只能接收不能发送;而交换机连接的设备不会互相影响,每个端口都可以独享带宽
- 集线器所有的端口都位于一个冲突域也位于一个广播域中;而交换机每一个端口都是一个冲突域,所有的端口都位于一个广播域中
- 集线器的工作原理是广播原理,无论从哪个端口接收的信号包,都将以广播的形式发送给其他端口,这样比较容易出现问题,特别是网络范围较大时,网络性能将会受到影响;而交换机是根据MAC地址进行交换,能够明确MAC地址的网卡在哪个端口上,然后只会将信号包发送到对应的端口之上,这样不容易出现大规模的网络性能故障
- 交换机的自行效率比较低,一次只能发出一个信号包,
./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”
如何解决./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”
./node_modules/react-router-dom/react-router-dom.js Attempted import error: ''Navigate'' is not exported from ''react-router''.
react-router-dom的版本是6.0.0-alpha.2,而react-router是5.2.0。 两者均已正确安装。我不确定如何解决此错误。有人可以给我任何可能的解决方法吗?
我的代码中甚至没有<Navigate to=?>
行。
解决方法
为什么只安装两个都需要,这可以工作
- 执行npm删除react-router
- 删除node_modules
- 纱线安装或npm安装和
- 启动纱线或启动npm
Azure Event Hub (2) 使用Azure AD授权访问Event Hub
《Windows Azure Platform 系列文章目录》
Azure Event Hub事件中心支持两种授权方式:
- Azure Active Directory
- Shared access signatures (SAS,共享访问签名)
针对第二种SAS的授权方式,Azure Portal上直接可以查看到具体的连接字符串,相对比较简单。
本文主要介绍第一种,使用Azure AD授权访问Event Hub。
在使用Azure AD授权之前,我们需要创建应用注册(App Registration),并获得tenant id, app id和app secret。
具体可以参考:
1.假设我们已经成功创建了一个应用注册(App Registration),如下图:
2.我们需要在RBAC上,设置这个应用注册的权限。
Azure 事件中心数据所有者,使用此角色可以授予对事件中心资源的完全访问权限。
Azure 事件中心数据发送者,使用此角色可以授予对事件中心资源的发送访问权限。
Azure 事件中心数据接收者,使用此角色可以授予对事件中心资源的使用/接收访问权限。
3.我们这里演示的内容,是通过AAD给Event Hub发送消息
4.我们打开Visual Studio,创建的项目类型为.Net Core。如下图:
5.设置项目名称为EventHubSender。步骤略。
6.在Program.cs中,增加引用
using System; using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Messaging.EventHubs; using Azure.Messaging.EventHubs.Producer; using Azure.Identity;
7.在Nuget包管理中,增加以下package
8.在Class Program中,增加如下代码:
static EventHubProducerClient producerClient; //这里设置TenantID static readonly string TenantId = ""; //这里设置ClientID static readonly string ClientId = ""; //这里设置Client Secret static readonly string ClientSecret = ""; //这里设置Event Hub命名空间 static readonly string EventHubNamespace = "leieventhub01.servicebus.chinacloudapi.cn"; //这里设置Event Hub Name static readonly string EventHubName = "event01"; static async Task Main() { await ClientCredentialsScenarioAsync(); } static async Task ClientCredentialsScenarioAsync() {
var options = new ClientCertificateCredentialOptions { AuthorityHost = AzureAuthorityHosts.AzureChina }; TokenCredential credential = new ClientSecretCredential(TenantId, ClientId, ClientSecret, options); // Create a producer client that you can use to send events to an event hub producerClient = new EventHubProducerClient(EventHubNamespace, EventHubName, credential); // Create a batch of events EventDataBatch eventBatch; for (int i = 1; i <= numOfEvents; i++) { eventBatch = await producerClient.CreateBatchAsync(); eventBatch.TryAdd(new EventData(Encoding.UTF8.GetBytes($"Event {i}"))); await producerClient.SendAsync(eventBatch); Console.WriteLine($"A Message {i} has been sent"); } }
Azure Event Hub 技术研究系列2-发送事件到Event Hub
上篇博文中,我们介绍了Azure Event Hub的一些基本概念和架构:
Azure Event Hub 技术研究系列1-Event Hub入门篇
本篇文章中,我们继续深入研究,了解Azure Event Hub的创建、编程SDK,实现将事件发送到云端的Azure Event Hub。
一、Azure Portal中创建Event Hub
创建一个新的Event Hub:
将连接字符串拷贝出来,备用。
二、通过Event Hub的SDK将事件发送到Event Hub
新建一个Console工程:EventHubSend
添加Nuget:
Microsoft.Azure.EventHubs
添加关键引用:
using Microsoft.Azure.EventHubs; System.Text; using System.Threading.Tasks;
添加常量作为事件中心连接字符串和实体路径(单个事件中心名称)
private static EventHubClient eventHubClient; const string EhConnectionString = "{Event Hubs connection string}"; //第一步拷贝的连接字符串 string EhEntityPath = {Event Hub path/name}"; //MyEventHub
新加MainAsync函数
static async Task MainAsync(string[] args) { var connectionStringBuilder = new EventHubsConnectionStringBuilder(EhConnectionString) { EntityPath = EhEntityPath }; eventHubClient = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString()); await SendEvents(100); await eventHubClient.CloseAsync(); Console.WriteLine(Press ENTER to exit."); Console.ReadLine(); }
将100个事件消息发送到EventHub方法:SendEvents
/// <summary> /// 创建100个消息事件,异步发送到EventHub </summary> <param name="count">个数</param> <returns></returns> async Task SendEvents(int count) { for (var i = 0; i < count; i++) { try { var eventEntity = $Event {i}; Console.WriteLine($Sending Event: {eventEntity}); await eventHubClient.SendAsync( EventData(Encoding.UTF8.GetBytes(eventEntity))); } catch (Exception exception) { Console.WriteLine(${DateTime.Now} > Exception: {exception.Message}); } await Task.Delay(10); } Console.WriteLine(${count} messages sent.); }
在Main函数中添加:
static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}
Run:
发现错误了:The messaging entity ''sb://myeventhubtest.servicebus.chinacloudapi.cn/MyEventHub'' Could not be found.
MyEventHub这个是我们在代码中指定的。
MyEventHubMyEventHub
这个是否需要在Azure Portal中提前创建好?
再次Run:
这次可以了。
周国庆
2017/5/17
总结
以上是小编为你收集整理的Azure Event Hub 技术研究系列2-发送事件到Event Hub全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
CCIE总结:路由器、交换机
bbs.spoto.net/forum-178-1.html -----雏鹰部落
GNS3安装
1、安装的所有目录不能使用中文
ISO如何操作
securecrt如何使用建立会话:之前总是连不上的原因是没有选 telnet协议,而不是ssh协议,要注意。
cmd如何进入GNS3模式:telnet localhost 2001
GNS3使用过程以及两个路由怎样连接
打开软件--添加镜像(c3640-jk9o3s-mz.124-13a)--计算IDLE值直到出现*号选择即可,目的是降低cpu使用率在10%以下才可以--暂停双击--添加快速以太网口--add a link--两个路由连接起来
命令+?=查看帮助
用户模式:》 输入exit 可以退出
特权模式:# 输入enable进入特权模式
全局模式(router(config)#模式--更高一级):输入configure terminal特权模式
全局模式退出:end 到上一级,exit 到用户模式
pc4(config)#default interface f 0/0 ------还原默认配置
配置console密码,下次再插console就得输入密码
R1(config)#line console 0 ---进入接口
R1(config)#password spoto
R1(config-line)#login 当其他设备连接这台设备时需要密码验证
R1(config-line)#no login
R1(config-line)#no pas spoto
用户模式-特权模式 设置密码
到特权模式下
R1(config)#enable secret spoto
VTY口令-用于限制人员通过telnet访问设备,设备第一次现场调试,以后要通过远程telnet调试,
实验:
R1作为被调试的设备,R2去登陆R1调试
R1(config)#line vty 0 4 vty:虚拟通道 0-4:要开5个通道
R1(config-line)#password spototelnet
R1#sh ip int
R1#sh ip int b
R1#conf t
R1(config)#int f 0/0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R2(config)#int f 0/0
R2(config-if)#ip add 1.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R1(config-if)#ping 1.1.1.2 ---------这个模式报错--Ping测试要在特权模式下
^
% Invalid input detected at ''^'' marker
R1#ping 1.1.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 16/44/88 ms
R2#telnet 1.1.1.1 -------------注意是特权模式下
Trying 1.1.1.1 ... Open
User Access Verification
Password:
% Password: timeout expired!
Password: spototelnet
R1>enable
Password:spoto
R1#
查看当前所有配置
R1#show running-config ---注意在特权模式下 --保存在内存里面 即RAM里面,重启后会清空
start-up-config 存储在NVRA里面 现在设备都放在flash里面 保存在这里面--再重启不丢失
保存配置 第一种
R1#write
Building configuration...
[OK]
保存配置 第二种
R1#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
清空配置
R1#erase startup-config 针对旧设备, 都对当前配置没有影响,重启后才生效
R1#delete flash:config.text 现在设备 都对当前配置没有影响,重启后才生效
配IP步骤:
先进入:用户模式-》特权模式-》全局模式-》进入接口
接口区分:如果一台设备有两个插槽,第一个插槽编号是0,第二个插槽编号是1。第一个插槽里面只有一个接口编号是0;第二个插槽里面有两个接口编号,一个是0,一个是1,
一、配置以太网接口(就是以太网链路)--基于8.2.3标准走,用的ARP协议
进入普通10M以太网口
interface ethernet 0/0 -----进入第一个插槽编号,第0个接口
interface ethernet 1/0 -----进入第二个插槽编号,第0个接口
interface ethernet 1/1 -----进入第二个插槽编号,第1个接口
ethernet 0/0 第一个0表示10M 整个意思:10M以太网口
进入快速以太网口
interface fast-ethernet 0/0
添加ip
R1(config-if)#ip add 1.1.1.1 255.255.255.0
激活接口--------思科设备默认是关闭的
R1(config-if)#no shutdown
实验:
R1#conf terminal
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0 -----提示符已变成 -if
R1(config-if)#no shutdown
R1(config-if)#end
R1#
R2#configure terminal
R2(config)#interface f 0/0 interface s 0/0
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#end
R2#
Ping测试要在特权模式下
R1#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.!!!! ------5个包,第一个包超时
Success rate is 80 percent (4/5), round-trip min/avg/max = 28/45/88 ms
R1#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/71/136 ms
二、配置serial接口(就是串行接口) (就是串行链路)(广域网链路)
DCE端
R1(config)#interface serial 0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#clock rate 6400 在DCE端配置时钟信号。时钟信号在运营商,用户是DTE端,线缆两头分别写着DCE和DTE,做模拟实验,需要一端模拟运营商,
DTE端不用配时钟
R1(config)#interface serial 0/0
R1(config-if)#ip address 192.168.1.2 255.255.255.0
R1(config-if)#no shutdown
查看具体接口配置信息
R1#show interfaces f0/0 ----------注意模式
FastEthernet0/0 is up, line protocol is up ----物理接口和协议都是up
Hardware is AmdFE, address is cc00.0b00.0000 (bia cc00.0b00.0000) ---快速以太网口和MAC地
Internet address is 192.168.1.1/24
MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, BW-带宽是100M, DLY--延迟
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
R1#show ip int brief ------查看哪些接口配了哪些ip
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
YES manual up---------是物理状态,如果连接路由器的线断了就是down了,
Protocol up---------是协议状态,如果没有配置时钟信号,就是down
路由选择原理;静态路由(S),直连路由(C)
R1#show ip route
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C:表示通过什么渠道获得,比如手工配置,C是直连,。S是手工配置的静态的
192.168.1.0/24 :表示目标地址
FastEthernet0/0 :表示从哪出去,从接口出去还是吓一跳扔给谁。
直连路由:路由接口配完IP后,接口激活,且双up:物理和协议都up,就会学习到紧邻路由的网络号,如:192.168.2.0/24, ---C
静态路由:人工建表,指定去哪个网段,如果去的网段号很多,就得配好多表,--适合中小型网络。
动态路由:两个路由之间相互对话,从而学到远端路由所知道的,比如3.0;4.0;6.0等网段。
直连路由的获取:两端路由只能知道一侧的路由,中间的路由可以知道紧邻两侧的路由信息。
静态路由配置: PC->网关->目的路由->目的路由后面是公网
需要人工配置告诉网关去往目的地的路由信息,即网络号
静态路由配置两种方式
R1(config)#ip route 192.168.1.0 255.255.255.255.0 192.168.12.1 192.168.1.0指的是公网IP 192.168.12.1指的是和目的路由器相连的左边的IP.------叫做扔给对端IP
R1(config)#ip route 192.168.1.0 255.255.255.255.0 serial 0 serial 0指的是网关紧挨着右边的接口 --------叫做扔给本地接口。
通信是双向的,还需要配置回来的路由信息,也是这样的,
实验:
PC-> R1路由->R2路由->R3目的路由->目的路由后面的公网
-( R1路由)-S0/0 192.168.12.1/24
192.168.12.2/24 S0/0-( R2路由)-S0/1 192.16823.2/24
192.168.23.3/24 S0/0-( R3路由)
R1(config)#ip route 192.168.23.0 255.255.255.0 192.168.12.2
R3(config)#ip route 192.168.12.0 255.255.255.255.0 serial s0/0
192.168.12.2------叫做扔给对端IP
serial s0/0指的是网关紧挨着右边的接口 --------叫做扔给本地接口。
通信是双向的,还需要配置回来的路由信息,也是这样的,
默认路由 表示符号:S*
实验(紧接着上面):PC-> R1路由->R2路由--后面接着好多网段IP,有1.0;2.0;3.0;4.0;多个隔离网络
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.12.2 192.168.12.2相当于默认网关。
telnet七层访问构造 客户 A---网关路由---远端路由---客户 B
源端口是一个随机端口,目的端口一定是23端口。
osi七层:7-5层不重要,4层把端口号封装TCP头部,然后建立三次握手连接在四层,源端口是一个随机端口,目的端口一定是23端口;3层报头加IP,源IP和目的IP;2层是帧头,加上源mac和目标网关路由mac地址(mac只能在本地LAN有效)。A要把数据发给B,必须得先发给网关,所以必须得知道网关的mac地址。
A通过地址解析协议发送广播给网关,网关收到后再回一个给A,A就会更新它的mac表,然后加上源mac和目标网关路由mac地址,最后变成10100的字样传给网关路由,网关收到后拆到第三层漏出IP,如果发现不是给自己的,就原封不动的打包回去,但是他要帮客户送出去,但是查了查路由没有到远端的路由表,所以我们就配置静态路由的方法告诉他怎么走。到远端路由后要拆封到帧,填上自己的mac地址和客户B的mac地址,所以也要广播得到,然后送给B计算机,B也要一层层拆,拆到应用层,看是23端口号,是telnet程序,所以就丢给了telnet程序处理。
同理B回包的时候也得走这个过程。
cmd里面输入 :arp -a 得到所有的mac地址。
lookback接口是虚拟接口,是个软件接口跟物理接口一样,可以配置IP地址。当物理接口不够用时,就可以用lookback接口。所以要开启这个、
静态路由坏处:当有好多个路由时,基本每个路由都要配路由表,会很忙,而且有一个远端路由坏掉时 ,也不是道。
动态路由协议
--------动态的更新,是一个对话。
静态路由坏处:当有好多个路由时,基本每个路由都要配路由表,会很忙,而且有一个远端路由坏掉时 ,也不是道。
动态路由坏处:需要占用一定的cpu等资源,会占用一定带宽,但对网络不会造成太大影响
动网路由协议分类:内部网关协议和外部网关协议。
AS号:自治系统,-自我管理
AS号内部---------选择内部网关协议
不同AS之间---------选择外部网关协议--------比如两个跨国公司之间,---比如两个农业银行之间
内部网关协议包括:1、距离矢量协议 2、链路状态协议
外部网关协议包括:BGP--适用于超大型网络
距离矢量协议
距离矢量协议包括:1、RIPV1和RIPV2 2、EIGRP
距离指的跳数--hop 一跳要跨越一台路由器,比如 R1要通过 R2 跨越2.0网段,这就是垮了一跳,以条数衡量一条路由的好坏,
矢量:R2要通告给R1,R1要经过R2,这就是方向
一旦两台路由之间运行协议,路由就会更新自己的路由表,进行对话,周期性的更新,
更新方式:采用广播, 缺点:对链路和设备造成损耗,
收敛完成的意思:动态路由学习完毕
收敛分两步:1、初次路由信息交换,进一步交欢
度量值(Metric):衡量一条路由的好和坏 ----附图见网盘--动态路由--距离矢量路由协议。就是说路由 --------前提在同一协议中做比较A连接了两个分支路由。
-A-B-E-1.0 ---------A到1.0经过了2跳 --------更忧 来源-RIP,网络号,viaB
-A-C-D-E-1.0 --------A到1.0经过了3跳
这样以后都会走更忧的路径,但是当2跳的任何地方出了问题,就会选择3跳的路径
度量值(Metric):同一台路由器收到多条去往同一个目的地的路由,会比较Metric值,Metric值忧的会被装进路由表,注:Metric值有比较条数的,有比较带宽的。如果两个Metric都相同就会同时使用,这就是负载均衡,
RIP缺点:当3跳的那条链路带宽比2跳的那条链路带宽大时,就是浪费,---附图见网盘--动态路由--距离矢量路由协议
冗余:自动切换链路,当有一个链路挂掉时候,而静态的路由是无法自动切换的。
查看度量值(Metric):show ip route ------附图见网盘--动态路由--距离矢量路由协议
Metric:在同一协议中做比较
管理距离(AD值):指的是不同动态协议之间做比较选择最优路径。
总结:
一台路由器,当它从两种不同的动态路由协议选择协议中,学习到去往同一个目的地的路由,比较AD值。取信小的将路由装入路由表,进行数据转发,另一条路径,只有当优选的路径DOWN掉的时候,才会出现和使用;
一台路由器,当它从同种动态路由协议,但不同方向(邻居)学习 去往同一个目的地的路由,则比较metric度量值,选择忧的,装入路由表,进行数据转发。
依照传闻的更新方式(广播、更新路由表) -----容易被骗,容易产生环路
逐跳更新
环路的产生:-A-B-C-
当C右端链路断掉时。但是仍然周期性的更新,当有pc访问C时,C告诉走B,B再告诉走C,往复循环,直到跑死,------------附图见网盘--动态路由--距离矢
还有达到无穷大
量路由协议
消除环路的方法: A-B-C-x
1、定义最大度量值防止计数至无穷大(最大跳数)16 ----这是RIP的最大上限
2、水平分隔 --附图见网盘--动态路由--距离矢
3、抑制计时器:抑制计时器:远端出问题时,B和C先启动计时器。观察,如果恢复,就继续使用
4、路由中毒 ---路由无穷大--就是不可达-----泛红出去------附图见网盘--动态路由--距离矢
5、毒性逆转 :带有路由中毒的水平分隔,:C告诉B路由不可达,B也告诉C我知道路由不可达,并等待C右边的线路好
6、触发更新:拓扑发送变化时,路由立即发送更新消息
RIP:适用于金融行业,
基于UDP,端口520的应用层协议。
管理距离120
RIP实验
R1 R2 R3
如果有多个路由,依次宣告自己的网络号即可
R1#conf t
R1(config)#interface S 0/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no sh
R1#ping 192.168.12.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/38/52 ms
R1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R1#conf t
R1(config)#router rip
R1(config-router)#network 192.168.12.0
R1(config-router)#end
R1#sh ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
(配置Rip后)
R1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R2#configure t
R2(config)#int s 0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int s 0/1
R2(config-if)#ip address 192.168.23.2 255.255.255.0
R2(config-if)#no sh
R2(config)#end
R2#sh ip int b
R2#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/35/48 ms
R2#conf t
R2(config)#router rip
R2(config-router)#net
R2(config-router)#network 192.168.12.0
R2(config-router)#network 192.168.23.0
R3#conf t
R3(config)#int s 0/0
R3(config-if)#ip address 192.168.23.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#end
R3#conf t
R3(config)#router rip
R3(config-router)#network 192.168.23.0
R3(config-router)#end
R3#sh ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
R 192.168.12.0/24 [120/1] via 192.168.23.2, 00:00:22, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
R3#ping 192.168.12.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 56/68/96 ms
EIGRP
--增强型内部网关路由协议 --思科私有---只能在思科设备上运行--前身是IGRP
RFC文档 ----规范 www.rfc
特点:收敛速度比较快,减少带宽浪费,(触发性更新)--当网络拓扑发送变化时才更新,
支持多种网络层协议,(ip,ipx,appletalk) ---见截图
无类路由:可以识别不同掩码
高级距离矢量协议:不只只是根据跳数,也可以根据带宽。
100%无环路,---DUAL算法
首先形成邻居表,再进行路由信息同步,然后启用DUAL算法,查看哪个更忧。
三种表:邻居表,拓扑表。路由表,
通过组播方式泛红:224.0.0.10发送
metric计算==带宽+延迟 =BW+DLY BW=(10的7次方/带宽 )*256
DLY= ((延迟(微妙)/10)*256
带宽:沿路所有数据出接口带宽最低值,且是接口的带宽,而不是链路的带宽
延迟:沿路所有数据出接口延迟的和
DUAL算法:提供无环路
后继路由器:就是选择metric最优的那条路的下一个路由器。
可行距离:本地到达目标地的metric值,(FD) 本地可以是A 可以是B
可行后继路由器:备份的那个 (FS)
A-B-D-
A-C-D-
通告距离:C通告给A到达目的地的D右面网段的距离,(AD)
可行后继成立的条件:C通告给A到达目的地的D右面网段的距离,(AD)要小于 A通过B到达D右面网段的距离。(FD)
路由更新和数据包的方向是相反的
K值要相等
EIGRP的配置
AS:域,比如一个省份就是一个域,不同的AS用不同的号码区分,
debug:一般不要开启,开启后会出现大量调试信息,有可能把设备跑坏,
自动汇总:防止远端网络号down掉的反复计算DUAL值协议默认开启汇总,
10.1.1.0/24 这是个子网 10.网段是A类地址,进行了子网划分。
172.16.0.0/16
192.168.12.0 是个主类地址,
EIGRP的配置实验
R1#conf t
R1(config)#interface S 0/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#router eigrp 100
R1(config-router)#network 192.168.12.0
R1(config-router)#end
R1#sh ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
R2#configure t
R2(config)#int s 0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
*Mar 1 00:05:13.543: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R2(config-if)#
*Mar 1 00:05:14.547: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R2(config-if)#in
R2(config-if)#int lo0
R2(config-if)#
*Mar 1 00:05:40.851: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#router eigrp 100
R2(config-router)#networ
R2(config-router)#network 192.168.12.0
R2(config-router)#
*Mar 1 00:06:40.487: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 100: Neighbor 192.168.12.1 (Serial0/0) is up: new adjacency
R2(config-router)#netw
R2(config-router)#network 2.2.2.
R1#sh ip route
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
D 2.0.0.0/8 [90/2297856] via 192.168.12.2, 00:00:12, Serial0/0
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 192.168.12.2 Se0/0 13 00:02:10 73 438 0 4
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 192.168.12.2 Se0/0 14 00:02:33 73 438 0 4
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 192.168.12.2 Se0/0 13 00:02:43 73 438 0 4
R1#
Connected to Dynamips VM "R1" (ID 13, type c3600) - Console port
Press ENTER to get the prompt.
R1#sh
R1#show ip
R1#show ip eifr
R1#show ip eigrp
R1#show ip eigrp nei
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 192.168.12.2 Se0/0 13 00:52:02 73 438 0 4
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 192.168.12.2 Se0/0 14 00:52:20 73 438 0 4
R1#conf
R1#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int s 0/0
R1(config-if)#shu
R1(config-if)#shutdown
R1(config-if)#
*Mar 1 01:05:01.555: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 100: Neighbor 192.168.12.2 (Serial0/0) is down: interface down
R1(config-if)#
*Mar 1 01:05:03.515: %LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down
*Mar 1 01:05:04.515: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
R1(config-if)#debu
R1(config-if)#de
R1(config-if)#debu
R1(config-if)#debug ip eigr
R1(config-if)#end
R1#d
*Mar 1 01:05:59.195: %SYS-5-CONFIG_I: Configured from console by console
R1#deb
R1#debug ip eigr
R1#debug ip eigrp ?
<1-65535> Autonomous System
neighbor IP-EIGRP neighbor debugging
notifications IP-EIGRP event notifications
summary IP-EIGRP summary route processing
vrf Select a VPN Routing/Forwarding instance
<cr>
R1#debug ip eigrp
IP-EIGRP Route Events debugging is on
R1#conf
R1#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int s 0/0
R1(config-if)#no shu
R1(config-if)#no shutdown
R1(config-if)#
*Mar 1 01:08:34.855: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R1(config-if)#
*Mar 1 01:08:35.859: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-if)#
*Mar 1 01:08:44.755: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 100: Neighbor 192.168.12.2 (Serial0/0) is up: new adjacency
*Mar 1 01:08:44.915: IP-EIGRP(Default-IP-Routing-Table:100): Processing incoming UPDATE packet
*Mar 1 01:08:44.919: IP-EIGRP(Default-IP-Routing-Table:100): 192.168.12.0/24 - do advertise out Serial0/0
*Mar 1 01:08:44.987: IP-EIGRP(Default-IP-Routing-Table:100): Processing incoming UPDATE packet
*Mar 1 01:08:44.991: IP-EIGRP(Default-IP-Routing-Table:100): Int 2.0.0.0/8 M 2297856 - 1657856 640000 SM 128256 - 256 128000
*Mar 1 01:08:44.991: IP-EIGRP(Default-IP-Routing-Table:100): route installed for 2.0.0.0 ()
*Mar 1 01:08:44.995: IP-EIGRP(Default-IP-Routing-Table:100): 192.168.12.0/24 - do advertise out Serial0/0
R1(config-if)#
*Mar 1 01:08:45.083: IP-EIGRP(Default-IP-Routing-Table:100): Processing incoming UPDATE packet
*Mar 1 01:08:45.087: IP-EIGRP(Default-IP-Routing-Table:100): Int 2.0.0.0/8 M 2297856 - 1657856 640000 SM 128256 - 256 128000
R1(config-if)#end
R1#sh
*Mar 1 01:11:41.339: %SYS-5-CONFIG_I: Configured from console by console
R1#sh ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
D 2.0.0.0/8 [90/2297856] via 192.168.12.2, 00:03:01, Serial0/0
R1#un all
All possible debugging has been turned off
R1#sh ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
D 2.0.0.0/8 [90/2297856] via 192.168.12.2, 00:04:33, Serial0/0 ---这个8见截图,
R1#show ip eigrp neigh
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 100
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
0 192.168.12.2 Se0/0 11 00:41:48 121 726 0 7
R1#ping 192.168.12.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/40/76 ms
R1#show ip eigrp topology
IP-EIGRP Topology Table for AS(100)/ID(192.168.12.1)
Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
r - reply Status, s - sia Status
P 2.0.0.0/8, 1 successors, FD is 2297856
via 192.168.12.2 (2297856/128256), Serial0/0
P 192.168.12.0/24, 1 successors, FD is 2169856
via Connected, Serial0/0
实验:见截图 三个路由构成三角形。R3连接一个lookback接口
R1#conf
R1#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f 0/0
^
% Invalid input detected at ''^'' marker.
R1(config)#int s 0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
*Mar 1 01:12:39.935: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R1(config-if)#
*Mar 1 01:12:40.939: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-if)#int s 0/1
*Mar 1 01:13:04.195: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
R1(config-if)#int s 0/1
R1(config-if)#ip add 192.168.13.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#
*Mar 1 01:13:41.003: %LINK-3-UPDOWN: Interface Serial0/1, changed state to up
R1(config-if)#
*Mar 1 01:13:42.007: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
R1(config-if)#
*Mar 1 01:14:04.207: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to down
R1(config-if)#netw
R1(config-if)#networ
R1(config-if)#network 192.168.12.0
^
% Invalid input detected at ''^'' marker.
R1(config-if)#rout
R1(config-if)#routing i
^
% Invalid input detected at ''^'' marker.
R1(config-if)#routing ei 1
^
% Invalid input detected at ''^'' marker.
R1(config-if)#route
R1(config-if)#router ei 1
R1(config-router)#netw
R1(config-router)#network 192.168.12.0
R1(config-router)#network 192.168.13.0
R1(config-router)#
*Mar 1 01:22:54.179: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-router)#
*Mar 1 01:23:51.639: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 192.168.12.2 (Serial0/0) is up: new adjacency
R1(config-router)#
*Mar 1 01:26:24.207: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
R1(config-router)#
*Mar 1 01:29:43.699: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 192.168.13.3 (Serial0/1) is up: new adjacency
R1(config-router)#end
R2#conf
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int s 0/0
R2(config-if)#ip add 192.168.12.2
% Incomplete command.
R2(config-if)#ip add 192.168.12.2
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
*Mar 1 01:22:48.531: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R2(config-if)#
*Mar 1 01:22:49.535: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R2(config-if)#int s 0/1
R2(config-if)#ip add 192.168.23.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
*Mar 1 01:23:14.087: %LINK-3-UPDOWN: Interface Serial0/1, changed state to up
R2(config-if)#
*Mar 1 01:23:15.091: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
R2(config-if)#rout
R2(config-if)#router ei 1
R2(config-router)#netw
R2(config-router)#network
*Mar 1 01:23:42.515: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to down
R2(config-router)#network 192.168.12.0
R2(config-router)#network 192.168.12.0
*Mar 1 01:23:50.183: %DUAL-5-NBRCHANGE: IP-EIGRP(0) 1: Neighbor 192.168.12.1 (Serial0/0) is up: new adjacency
R2(config-router)#network 192.168.23.0
R3#int
R3#int
R3#conf
R3#configure t
R3#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#ip add 192.168.13.3 255.255.255.0
^
% Invalid input detected at ''^'' marker.
R3(config)#int s 0/0
R3(config-if)#ip add 192.168.13.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#no shutdown
R3(config-if)#
*Mar 1 01:26:18.555: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R3(config-if)#
*Mar 1 01:26:19.559: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R3(config-if)#int s 0/1
R3(config-if)#ip add 192.168.23.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#no shutdown
R3(config)#int lo0
R3(config-if)#
*Mar 1 01:28:14.019: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R3(config-if)#ip add 3.3.3.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#no shutdown
R3(config-router)#router ei 1
R3(config-router)#network 192.168.23.0
R3(config-router)#network 192.168.13.0
R3(config-router)#network 3.0.0.0
R1#show ip eigrp neighbors
IP-EIGRP neighbors for process 1
H Address Interface Hold Uptime SRTT RTO Q Seq
(sec) (ms) Cnt Num
1 192.168.13.3 Se0/1 12 00:01:57 82 492 0 12
0 192.168.12.2 Se0/0 12 00:07:49 74 444 0 12
R1#sho
R1#show ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
C 192.168.13.0/24 is directly connected, Serial0/1
D 3.0.0.0/8 [90/2297856] via 192.168.13.3, 00:00:55, Serial0/1
D 192.168.23.0/24 [90/2681856] via 192.168.13.3, 00:02:27, Serial0/1
[90/2681856] via 192.168.12.2, 00:02:27, Serial0/0
R1#sho
R1#show ip ei
R1#show ip eigrp to
R1#show ip eigrp topology
IP-EIGRP Topology Table for AS(1)/ID(192.168.13.1)
Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
r - reply Status, s - sia Status
P 3.0.0.0/8, 1 successors, FD is 2297856
via 192.168.13.3 (2297856/128256), Serial0/1
P 192.168.12.0/24, 1 successors, FD is 2169856
via Connected, Serial0/0
P 192.168.13.0/24, 1 successors, FD is 2169856
via Connected, Serial0/1
P 192.168.23.0/24, 2 successors, FD is 2681856
via 192.168.12.2 (2681856/2169856), Serial0/0
via 192.168.13.3 (2681856/2169856), Serial0/1
R1#show ip eigrp topology all
R1#show ip eigrp topology all-links
IP-EIGRP Topology Table for AS(1)/ID(192.168.13.1)
Codes: P - Passive, A - Active, U - Update, Q - Query, R - Reply,
r - reply Status, s - sia Status
P 3.0.0.0/8, 1 successors, FD is 2297856, serno 5
via 192.168.13.3 (2297856/128256), Serial0/1
via 192.168.12.2 (2809856/2297856), Serial0/0
P 192.168.12.0/24, 1 successors, FD is 2169856, serno 1
via Connected, Serial0/0
P 192.168.13.0/24, 1 successors, FD is 2169856, serno 2
via Connected, Serial0/1
P 192.168.23.0/24, 2 successors, FD is 2681856, serno 4
via 192.168.12.2 (2681856/2169856), Serial0/0
via 192.168.13.3 (2681856/2169856), Serial0/1
R1#show ip protocols ------ 查看全局指令
负载均衡
负载均衡:同时出现了两条路由到达目的地。并且metric值相等。提高了带宽的利用率。
不等价负载均衡: --见图
允许两条优劣路由都放在路由表里。--防止闲置带宽:同时使用两条链路,
variance=2 自定义这个数
(20+10)=30<[2*FD=40] 这个时候30这个metric值就可以作为负载路由一起使用。
网络工程师概念:不是机房,不是弱电,是整个路由器,交换机等设备组成的系统,上面跑了平台,又有各种协议,根据客户现场进需求行规划。变成实施方案,最终落实,
多和行业内人士交流。
OSPF
OSPF协议:链路状态路由协议(开放式最短路径优先)---用的最广泛 --SPF算法 很多园区网都在用
O:开放 共有的 没有跳数限制
路由之间交流的是链路的状态而不是直接的路由信息,而距离矢量路由协议交流的直接是路由信息
状态:这个接口到某个路由之间的开销或邻居关系。
根据开销选择 路径,和带宽成反比,带宽越大,到达目的地的开销越小。
cost=10的8次方/接口带宽 带宽=沿路入接口所有带宽之和
OSPF报文类型 相当于婚恋过程
HELLO:建立初步关系 ,采用组播方式,224.0.0.5,发给所有运行OSPF协议的路由器
DBD:链路状态表 LSA:具体信息,在LSDB中 --这一步了解基本信息,LSDB在拓扑表中,
LSR:请求详细情况--链路状态信息
LSU:给的答复(包括了多了LSA)
LSACK:确认报文的安全机制,对LSU中的LSA进行确认。
OSPF区域:
泛红,每台路由都要装在小区内的所有信息,浪费资源,所以区域要弄小点,且区域大,不易管理,且拓扑发生变化容易发生网络抖动,
OSPF 区域划分,以路由器为界限,
OSPF三张表:邻居表,拓扑表,OSPF路由表。
OSPF优势
几乎适应所有网络类型,包括以太网,点对点串行链路,就是运行在OS七层的第二层,比如物理层是以太网接口,在二层就会识别封装成以太网帧,如果是串行接口,就封装成HPLC的帧,接口不一样,封装时候叫的名字也不一样,然后OSPF就会根据这种不同的数据链路层进行操作,不同的数据链路就是不同的网络,
一共4种网络类型
广播型:就是以太网链路,比如在LAN中连接了多台路由器,简称BMA。
串行链路:就是点对点模式,一条线两头各连一个路由,只有两个
NBMA:也是多路型网络,但是不支持广播和组播,最典型的封装方式就是 x.25和帧中
通配符(反掩码):用来匹配,=255.255.255.255-接口的掩码
实验--通配符
R1#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f 0/0
^
% Invalid input detected at ''^'' marker.
R1(config)#int s 0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
*Mar 1 00:03:55.751: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R1(config-if)#
*Mar 1 00:03:56.755: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-if)#
*Mar 1 00:04:23.955: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
R1(config-if)#rou
R1(config-if)#router os
R1(config-if)#ex
R1(config)#router os
R1(config)#router ospf 1
R1(config-router)#netw
R1(config-router)#network 192.168.12.0 0.0.0.255 ar
R1(config-router)#network 192.168.12.0 0.0.0.255 area 0 ---- 255.255.255.255-3个255
R1(config-router)#
*Mar 1 00:08:03.955: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-router)#
*Mar 1 00:09:35.611: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.23.2 on Serial0/0 from LOADING to FULL, Loading Done
R2#conf
R2#configure t
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#in
R2(config)#interface s 0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
*Mar 1 00:07:49.223: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R2(config-if)#in
*Mar 1 00:07:50.227: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R2(config-if)#in
R2(config-if)#int
R2(config-if)#ex
R2(config)#int s 0/1
R2(config-if)#ip add 192.168.23.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown
R2(config-if)#
*Mar 1 00:08:47.295: %LINK-3-UPDOWN: Interface Serial0/1, changed state to up
R2(config-if)#
*Mar 1 00:08:48.299: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
R2(config-if)#ex
R2(config)#rou
R2(config)#router os
R2(config)#router ospf 1
R2(config-router)#
*Mar 1 00:09:13.151: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to down
R2(config-router)#netw
R2(config-router)#network 192.168.12.0 0.0.0.255 a
R2(config-router)#network 192.168.12.0 0.0.0.255 area 0
R2(config-router)#
*Mar 1 00:09:34.371: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.12.1 on Serial0/0 from LOADING to FULL, Loading Done
R2(config-router)#net
R2(config-router)#network 192.168.23.0 0.0.0.255 ar
R2(config-router)#network 192.168.23.0 0.0.0.255 area 0
R2(config-router)#
*Mar 1 00:11:43.151: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to up
R3#conf
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int s 0/0
R3(config-if)#ip add 192.168.23.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#no shutdown
R3(config-if)#
*Mar 1 00:11:30.879: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R3(config-if)#
*Mar 1 00:11:31.883: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R3(config-if)#ex
R3(config)#rou
R3(config)#routee
R3(config)#router os
R3(config)#router ospf 1
R3(config-router)#netw
R3(config-router)#network 192.168.23.0 0.0.0.255 a 0
R3(config-router)#
*Mar 1 00:14:48.359: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.23.2 on Serial0/0 from LOADING to FULL, Loading Done
R1(config-router)#end
R1#
*Mar 1 00:15:07.071: %SYS-5-CONFIG_I: Configured from console by console
R1#sh
R1#show ip os
R1#show ip ospf ne
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.23.2 0 FULL/ - 00:00:38 192.168.12.2 Serial0/0
R1#sh ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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.12.0/24 is directly connected, Serial0/0
O 192.168.23.0/24 [110/128] via 192.168.12.2, 00:01:17, Serial0/0
R1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/60/64 ms
多区域配置:area0 area1 不一样而已。
二层交换基础
VLAN概念
TRUNK概念
二层交换基本配置
交换机对帧进行转发,如果不知道数据包的走向就会泛红,不能隔绝广播域,
园区网络分层结构
接入层:用户接入,接入安全,防止PC中毒影响整个网络,接入层VLAN,接受用户流量
汇聚层:流量汇聚,链路冗余,设备冗余,防止环路
核心层:高速转发,服务器接入,路由选择,
出口层:广域网接入,出口策略,带宽控制,链路备份。
接入层交换机---二层交换机,二层:数据链路层,定义了MAC地址,
作用:学习MAC地址,数据转发,帧:源和目的,还有data,环路避免,
交换机为什么工作在第二层:能够识别帧,转发帧。
mac地址:硬件地址,叫做二层地址,00000111,出厂时唯一的,
工作原理:刚开始寻址,泛红,之后就是针对性的
VLAN概念
HUB:整个是个冲突域
交换机:一个接口就是一个冲突域,整台是个广播域,是个LAN,比如192.168.1.0/24,不能隔绝广播域,因为是根据MAC地址转发,
路由器:每个接口就是个独立的广播域,
交换机如何划分多个广播域
192.168.1.1 和192.168.1.2 是一个VLAN 192.168.1.3H和 192.168.1.4 是另一个LAN, 这两个LAN之间不能互访,要想互访需要借助路由器配置。
VLAN V:就是虚拟
不同的LAN之间不能互访,要想通信就得知道MAC,而要知道MAC就得通过广播来获得,而不同的LAN是不同的广播,所以无法获得,
1、静态VLAN --人工配置
2、动态VLAN --通过VSPS服务器实现,防止人员位置发生变化,MAC注册后。一直跟踪MAC,别管电脑到哪里
集成商:布线,强电弱电等,
网络工程师:调试设备,运营。个根据客户需求,上架设备。100台设备,一个下午。善用工具,myBase管理脚本--复制粘贴,大型设备都是写脚本,复制粘贴,速度很快
trunk :一条链路需要承载多ALAN信息的时候,需要使用trunk来实现。标记不同颜色,存在于交换机之间或交换机与路由器之间。由人为手工配置,
trunk:要配在链路上,就是干道上,交换机之间用的Trunk
ISL:思科私有,一种封装协议,
802.1Q又叫Qus:共有协议,使用里面插入tag来做标记,
数据帧:又叫纯洁以太网数据帧,
VTP模式:思科私有,在大型网络中,动态管理VLAN,在server模式,发送并更新,让其他交换机也具有,放在flash里面的vlan.dat里面。删除配置文件,他也在,client端只能学习,transparent下不学习,只转发。 --------很少用。 -在Teunk之间运行,
vlan的基本配置
跨交换机配置vlan
等车排队的时候放些视频学习材料
c3600模拟交换机添加的模块是 GNS3里面的倒数第二个NM-16ESW,PC分配快速以太网口,
路由器怎么模拟pc
1、 no ip routing ---关掉路由功能
2、 interface f/0
ip address xxx
no shutdown
3、 ip default-gateway xxxx ---指定网关
sw1(vlan)#ex -----这种方式退出才会保存
R1#conf
R1#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#host
R1(config)#hostname sw1
sw1(config)#end
sw1#
*Mar 1 00:10:10.939: %SYS-5-CONFIG_I: Configured from console by console
sw1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#vlan 10
^
% Invalid input detected at ''^'' marker.
sw1(config)#end
sw1#
*Mar 1 00:18:38.879: %SYS-5-CONFIG_I: Configured from console by console
R2#conf
R2#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#host
R2(config)#hostname sw2
sw2(config)#end
R3#conf
R3#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#hos
R3(config)#hostname pc1
pc1(config)#no ip rou
pc1(config)#no ip routi
pc1(config)#no ip routing
pc1(config)#int f 0/0
pc1(config-if)#ip add 192.168.10.1 255.255.255.0
pc1(config-if)#no sh
pc1(config-if)#no shutdown
pc1(config-if)#
*Mar 1 00:11:58.447: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:11:59.447: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
pc1(config-if)#ip def
pc1(config-if)#ip defau
pc1(config-if)#ex
pc1(config)#ip defa
pc1(config)#ip default-gate
pc1(config)#ip default-gateway 192.168.10.254
pc1(config)#end
R4#conf
R4#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#host
R4(config)#hostname pc2
pc2(config)#no ip rou
pc2(config)#no ip rout
pc2(config)#no ip routi
pc2(config)#no ip routing
pc2(config)#int f 0/0
pc2(config-if)#ip add 192.168.20.1 255.255.255.0
pc2(config-if)#no shu
pc2(config-if)#no shutdown
pc2(config-if)#
*Mar 1 00:14:04.523: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:14:05.523: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
pc2(config-if)#ex
pc2(config)#end
R5#conf
R5#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#host
R5(config)#hostname pc3
pc3(config)#no ip rou
pc3(config)#no ip routti
pc3(config)#no ip routi
pc3(config)#no ip routing
pc3(config)#int f 0/0
pc3(config-if)#ip add 192.168.10.2 255.255.255.0
pc3(config-if)#no sh
pc3(config-if)#no shutdown
R6#conf
R6#configure t
R6#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R6(config)#hostn
R6(config)#hostname pc4
pc4(config)#no ip rout
pc4(config)#no ip routi
pc4(config)#no ip routing
pc4(config)#int f 0/0
pc4(config-if)#ip add 192.168.20.2 255.255.255.0
pc4(config-if)#no sh
pc4(config-if)#no shutdown
pc4(config-if)#end
sw1#vlan da
sw1(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
sw1(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
sw1(vlan)#ex
APPLY completed.
Exiting....
sw1#conf
sw1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#int f 0/0
sw1(config-if)#swit
sw1(config-if)#switchport mo
sw1(config-if)#switchport mode acc
sw1(config-if)#switchport mode access
sw1(config-if)#swi
sw1(config-if)#switchport ac vl
sw1(config-if)#switchport ac vlan 10
sw1(config-if)#ex
sw1(config)#int f 0/1
sw1(config-if)#switchport mode access
sw1(config-if)#switchport ac vlan 10
sw1(config-if)#ex
sw1(config)#int f 0/2
sw1(config-if)#sw
sw1(config-if)#swi
sw1(config-if)#switchport mo
sw1(config-if)#switchport mode ac
sw1(config-if)#sw mo
sw1(config-if)#sw mode ac vl
sw1(config-if)#sw mode ac vla
sw1(config-if)#sw acc
sw1(config-if)#sw access vl
sw1(config-if)#sw access vlan 20
sw1(config-if)#end
sw1#
*Mar 1 00:24:44.411: %SYS-5-CONFIG_I: Configured from console by console
sw1#sho
sw1#show vl
sw1#show vlan-s
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/3, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15
10 VLAN0010 active Fa0/0, Fa0/1
20 VLAN0020 active Fa0/2
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 1002 1003
10 enet 100010 1500 - - - - - 0 0
20 enet 100020 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 1 1003
1003 tr 101003 1500 1005 0 - - srb 1 1002
1004 fdnet 101004 1500 - - 1 ibm - 0 0
1005 trnet 101005 1500 - - 1 ibm - 0 0
sw1#conf
sw1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#sw
sw1(config)#swi
sw1(config)#int f 0/15
sw1(config-if)#swi
sw1(config-if)#switchport tru
sw1(config-if)#switchport trunk en
sw1(config-if)#switchport trunk encapsulation ?
dot1q Interface uses only 802.1q trunking encapsulation when trunking
sw1(config-if)#switchport trunk encapsulation do
sw1(config-if)#switchport trunk encapsulation dot1q
sw1(config-if)#swi
sw1(config-if)#switchport mo
sw1(config-if)#switchport mode tru
sw1(config-if)#switchport mode trunk
sw1(config-if)#
*Mar 1 00:27:37.255: %DTP-5-TRUNKPORTON: Port Fa0/15 has become dot1q trunk
sw1(config-if)#ex
sw1(config)#end
sw1#
*Mar 1 00:27:58.959: %SYS-5-CONFIG_I: Configured from console by console
sw1#sho
sw1#show int
sw1#show interfaces tru
sw1#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Fa0/15 on 802.1q trunking 1
Port Vlans allowed on trunk
Fa0/15 1-1005
Port Vlans allowed and active in management domain
Fa0/15 1,10,20
Port Vlans in spanning tree forwarding state and not pruned
Fa0/15 1,10,20
sw2#vlan da
sw2(vlan)#vl
sw2(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
sw2(vlan)#vl
sw2(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
sw2(vlan)#ex
APPLY completed.
Exiting....
sw2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw2(config)#int f 0/1
sw2(config-if)#sw
sw2(config-if)#switchport ac
sw2(config-if)#switchport access vl
sw2(config-if)#switchport access vlan 10
sw2(config-if)#int f 0/2
sw2(config-if)#sw
sw2(config-if)#switchport ac
sw2(config-if)#switchport access vl
sw2(config-if)#switchport access vlan 20
sw2(config-if)#int f 0/15
sw2(config-if)#sw
sw2(config-if)#switchport mo
sw2(config-if)#switchport mode tru
sw2(config-if)#switchport mode trunk
sw2(config-if)#
*Mar 1 00:31:10.931: %DTP-5-TRUNKPORTON: Port Fa0/15 has become dot1q trunk
sw2(config-if)#sw
sw2(config-if)#switchport tru
sw2(config-if)#switchport trunk en
sw2(config-if)#switchport trunk encapsulation do
sw2(config-if)#switchport trunk encapsulation dot1q
sw2(config-if)#ex
sw2(config)#end
sw2#sho
*Mar 1 00:31:47.155: %SYS-5-CONFIG_I: Configured from console by console
sw2#sho
sw2#show int
sw2#show interfaces tru
sw2#show interfaces trunk
Port Mode Encapsulation Status Native vlan
Fa0/15 on 802.1q trunking 1
Port Vlans allowed on trunk
Fa0/15 1-1005
Port Vlans allowed and active in management domain
Fa0/15 1,10,20
Port Vlans in spanning tree forwarding state and not pruned
Fa0/15 1,10,20
pc1#show ip it
pc1#show ip ii
pc1#show ip in
pc1#show ip int
pc1#show ip interface b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.10.1 YES manual up up
pc1#ping 192.168.10.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.10.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/21/40 ms
pc2#ping 192.168.20.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 20/40/76 ms
pc2#
不同的VLAN要访问就得借助路由器,而路由器的接口少,非常宝贵,提出了单臂,必须是快速以太网口,就是一个物理接口承载两个vlan,通过创建子接口实现。
单臂实验--接着上面的实验----不同的VLAN要访问---通过创建子接口实现
单臂路由缺点:占用带宽,链路来回占用,
sw2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw2(config)#int f 0/2
sw2(config-if)#no sw ac vl
sw2(config-if)#no sw ac vlan 20 -----------去掉vlan要改成Trunk
sw2(config-if)#sw
sw2(config-if)#switchport no
sw2(config-if)#switchport mo
sw2(config-if)#switchport mode tr
sw2(config-if)#switchport mode trunk
sw2(config-if)#
*Mar 1 01:08:22.583: %DTP-5-TRUNKPORTON: Port Fa0/2 has become dot1q trunk
sw2(config-if)#sw
sw2(config-if)#switchport tru
sw2(config-if)#switchport trunk en
sw2(config-if)#switchport trunk encapsulation d
sw2(config-if)#switchport trunk encapsulation dot1q
sw2(config-if)#ex
sw2(config)#end
sw2#sh
*Mar 1 01:09:01.275: %SYS-5-CONFIG_I: Configured from console by console
sw2#sh int tr
Port Mode Encapsulation Status Native vlan
Fa0/2 on 802.1q trunking 1
Fa0/15 on 802.1q trunking 1
Port Vlans allowed on trunk
Fa0/2 1-1005
Fa0/15 1-1005
Port Vlans allowed and active in management domain
Fa0/2 1,10,20
Fa0/15 1,10,20
Port Vlans in spanning tree forwarding state and not pruned
Fa0/2 1,10,20
Fa0/15 1,10,20
sw2#sh ip ro
Codes: C - connected, S - static, 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
i - IS-IS, su - IS-IS summary, 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
pc4#conf
pc4#configure t
Enter configuration commands, one per line. End with CNTL/Z.
pc4(config)#ip rou
pc4(config)#ip routi
pc4(config)#ip routing
pc4(config)#defau
pc4(config)#default int
pc4(config)#default interface f 0/0 ---------恢复默认配置
Building configuration...
Interface FastEthernet0/0 set to default configuration
pc4(config)#end
pc4#
*Mar 1 01:06:57.819: %SYS-5-CONFIG_I: Configured from console by console
pc4#host
pc4#hostna
pc4#conf t
Enter configuration commands, one per line. End with CNTL/Z.
pc4(config)#hostn
pc4(config)#hostname
pc4(config)#hostname GW
pc4(config)#hostname GW
GW(config)#int f 0/0
GW(config-if)#no shu
GW(config-if)#no shutdown
GW(config-if)#int f 0/0.10
GW(config-subif)#enca
GW(config-subif)#encapsulation do
GW(config-subif)#encapsulation dot1Q 10
GW(config-subif)#ip add 192.168.10.254 255.255.255.0
GW(config-subif)#no sh
GW(config-subif)#int f 0/0.20
GW(config-subif)#en
GW(config-subif)#encapsulation do
GW(config-subif)#encapsulation dot1Q 20
GW(config-subif)#ip add 192.168.20.254 255.255.255.0
GW(config-subif)#no sh
GW(config-subif)#ex
GW(config)#end
GW#sho
GW#show
*Mar 1 01:16:16.787: %SYS-5-CONFIG_I: Configured from console by console
GW#show ip int b
GW#show ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES TFTP up up
FastEthernet0/0.10 192.168.10.254 YES manual up up
FastEthernet0/0.20 192.168.20.254 YES manual up up
pc2#configure t
Enter configuration commands, one per line. End with CNTL/Z.
pc2(config)#ip def
pc2(config)#ip default-g
pc2(config)#ip default-gateway 192.168.10.254
pc2(config)#^Z
pc2#
*Mar 1 01:19:01.843: %SYS-5-CONFIG_I: Configured from console by console
pc2#configure t
Enter configuration commands, one per line. End with CNTL/Z.
pc2(config)#ip default-gateway 192.168.20.254
pc3(config-if)#ip def
pc3(config-if)#ip defau
pc3(config-if)#ip defaul
pc3(config-if)#ip default-
pc3(config-if)#ip default-g
pc3(config-if)#ex
pc3(config)#ip def
pc3(config)#ip default-ge
pc3(config)#ip default-get
pc3(config)#ip default-g
pc3(config)#ip default-gateway 192.168.10.254
pc1#sh ip int b
pc1#sh ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.10.1 YES manual up up
pc1#sh ip ro
Default gateway is 192.168.10.254
Host Gateway Last Use Total Uses Interface
ICMP redirect cache is empty
pc1#ping 192.168.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 36/46/64 ms
pc1#ping 192.168.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.20.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/48/84 ms
总结:
trunk只有在不同的vlan的时候才设置在链路上
纯净的数据帧只有在trunk链路中才会打上封装。
学会创建自己的个人笔记,要通过word来写,可以自定义格式。生成目录树。
383187373
VTP的基本配置
OSPF
STP生成树---在二层
单点故障:1、单链路,2、单设备
冗余又容易造成环路
三层链路:两台路由器之间叫做三层链路,存在于广播中
二层链路:存在于交换机与交换机之间。通过vlan接口互联的。
二层还没有很好的机制避免环路,
环路的缺点:
1、环路--广播风暴,资源耗尽,网络卡,ping丢包等都是这个环路造成。ping100个包,丢50个包。一旦有一台pc中毒,就会泛红产生广播风暴,2、环路占用资源
3、MAC地址表乱,带来了MAC泛红攻击,---当MAC地址表满了以后就不能再学习新的mac,
4、造成MAC地址飘逸,--manc地址一会在这个接口一会在另一个接口,--紊乱,
交换机对帧进行转发,
STP通过选举解决了环路--生成树协议 802.1D标准
做法:
1、选择根桥----路由---就是交换机
2、每个非根桥选择一个根端口。DP --距离根桥交换机距离最小,cost值来衡量---ospf里面用的
3、每一段选择一个指定端口,---距离根桥交换机距离最小
4、选择一个非指定端口,---阻塞掉
通过BPDU包泛红来操作
刚开始所有的交换机都认为自己的根桥,不断发送BPDU包,最后达成共识,选出根桥。
Bridge ID = 2个字节桥优先级(人为给路由器定的) + 6个字节桥MAC地址 (背板的MAC地址)
都要比小,适用:路径相等时,
Bridge ID 装在BPDU报文中,BPDU泛红后,所有人达成共识,生成一个Root ID --根桥
1Gb/s是千兆的 cost值---19 开销值
10Mb/s 10M的 cost值----100
如果路径代价相等就比较 Bridge ID
2.1 每个非根桥选择一个根端口 RP
1、最低的桥ID
2、最低的根路径代价
3、最低发送者桥ID Bridge ID
4、最低端口ID
3.1、每一段选择一个指定端口 DP
1、最低的桥ID
2、最低的根路径代价
3、最低发送者桥ID Bridge ID
4、最低端口ID
今天关于路由器和Router、交换机的分享就到这里,希望大家有所收获,若想了解更多关于./node_modules/react-router-dom/react-router-dom.js尝试导入错误:未从“ react-router”导出“ Navigate”、Azure Event Hub (2) 使用Azure AD授权访问Event Hub、Azure Event Hub 技术研究系列2-发送事件到Event Hub、CCIE总结:路由器、交换机等相关知识,可以在本站进行查询。
本文标签: