From 4e426dbe4624ace46d4a6ef184415d6bde27d847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:31:07 +0000 Subject: [PATCH 01/17] =?UTF-8?q?20240417=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- ...56\344\270\216\347\256\241\347\220\206.md" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240417\344\272\244\346\215\242\346\234\272\347\232\204\345\237\272\347\241\200\351\205\215\347\275\256\344\270\216\347\256\241\347\220\206.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240417\344\272\244\346\215\242\346\234\272\347\232\204\345\237\272\347\241\200\351\205\215\347\275\256\344\270\216\347\256\241\347\220\206.md" "b/\347\216\213\345\202\262\345\263\260/20240417\344\272\244\346\215\242\346\234\272\347\232\204\345\237\272\347\241\200\351\205\215\347\275\256\344\270\216\347\256\241\347\220\206.md" new file mode 100644 index 0000000..c8c5750 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240417\344\272\244\346\215\242\346\234\272\347\232\204\345\237\272\347\241\200\351\205\215\347\275\256\344\270\216\347\256\241\347\220\206.md" @@ -0,0 +1,45 @@ +## 交换机的基础配置与管理 + +#### 快捷指令: + +帮助信息(?) + +命令自动补全(tab) + +中断测试(Ctrl+c,Ctrl+shift+6) + +退回到特权视图(Ctrl+z) + +在特权模式下重启(reload) + +#### 端口配置指令: + +speed(10,100,auto),duplex (half,full,auto): 配置交换机端口参数 + +show version : 查看交换机版本信息 + +show running-config :查看当前生效的配置信息 + +show interface :查看端口信息 + +show mac-address-table : 查看交换机的mac地址 + +#### 密码指令设置: + +设置进入特权模式的密码: + +Switch(config)# enable password *** + +通过console端口连接设备及Telnet远程登录时所需的密码: + +Switch(config)# line console 0 表示配置控制台路线,0是控制台的线路编号 + +Switch(config-line)# login 用于打开登录认证功能 + +Switch(config-line)# password *** 设置进入控制台访问的密码 + +#### ps: + +若交换机设置为auto以外的具体速度,此时应注意保证通信双方也要有相同的设置值。 + +注意事项:在配置交换机时,要注意交换机端口的单双工模式的匹配,如果链路一端设置的是全双工,另一端是自动协商,则会造成响应差和高出错率,丢包现象会很严重。通常两端设置为相同的模式。S \ No newline at end of file -- Gitee From 519062927b62a3a8477e696156845bf95d2a19cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:32:52 +0000 Subject: [PATCH 02/17] =?UTF-8?q?20240418=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240418.md" | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240418.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240418.md" "b/\347\216\213\345\202\262\345\263\260/20240418.md" new file mode 100644 index 0000000..74d9526 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240418.md" @@ -0,0 +1,95 @@ +## SSH远程登录 + +在Cisco模拟器(如Cisco Packet Tracer或GNS3)中配置SSH登录,可以让您模拟真实环境中的远程管理操作。以下是详细的步骤来配置SSH登录: + +##### 步骤1: 基本设备配置 + +首先,确保交换机的基本配置已完成,包括设备名称、接口配置等。 + +Switch> enable + +Switch# configure terminal + +Switch(config)# hostname S1 + +S1(config)# interface vlan 1 + +S1(config-if)# ip address 192.168.1.2 255.255.255.0 + +S1(config-if)# no shutdown + +S1(config-if)# exit + +##### 步骤2: 配置域名 + +SSH需要一个域名来生成密钥。 + +S1(config)# ip domain-name example.com + +##### 步骤3: 生成加密密钥 + +生成RSA密钥对,这是SSH需要用到的。密钥长度至少为1024位。 + +S1(config)# crypto key generate rsa + +The name for the keys will be: S1.example.com + +Choose the size of the key modulus in the range of 360 to 2048 for your + +General Purpose Keys. Choosing a key modulus greater than 512 may take + +a few minutes. + +How many bits in the modulus [512]: 2048 + +% Generating 2048 bit RSA keys, keys will be non-exportable...[OK] + +##### 步骤4: 启用SSH + +确保SSH服务已启用。 + +S1(config)# ip ssh version 2 + +S1(config)# line vty 0 15 + +S1(config-line)# transport input ssh + +S1(config-line)# login local + +S1(config-line)# exit + +##### 步骤5: 配置用户和密码 + +配置设备登录的用户名和密码。这是SSH登录验证所必需的。 + +S1(config)# username admin passsword 123 + +S1(config)#exit + +S1#wr m //保存 + +##### 步骤6: 保存配置 + +保存配置,确保在设备重启后配置仍然有效。 + +S1(config)# end + +S1# write memory + +Building configuration... + +[OK] + +S1# + +##### 步骤7: 测试SSH连接 + +从另一台设备(如PC或另一台路由器/交换机)测试SSH连接。 + +PC> ssh -l admin 192.168.1.2 + +Password: adminpass + +以上步骤展示了在Cisco模拟器中配置SSH的完整过程 + +注:第一步设置的ip address 和后面写的不能一样 \ No newline at end of file -- Gitee From f1a97a6b7823afa39669ba1f80b075cbc89a05f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:33:13 +0000 Subject: [PATCH 03/17] =?UTF-8?q?20240419=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240419.md" | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240419.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240419.md" "b/\347\216\213\345\202\262\345\263\260/20240419.md" new file mode 100644 index 0000000..34c3126 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240419.md" @@ -0,0 +1,96 @@ +## 交换机远程配置telent登录 + +### 实验步骤: + +进入VLAN端口模式(interface vlan 1) + +配置交换机管理IP地址(ip address IP submask) + +选择具体的线路配置模式(line vty [0-15] [0-15]) + +配置登录密码(password ******) + +手动打开VLAN1端口(no shutdown) + +将两台PC与交换机连接,同时保证其IP地址与交换机管理IP地址在同一个网段 + +``` +PC0设置 +192.168.1.2 +255.255.255.0 +192.168.1.1 +PC1设置 +192.168.1.3 +255.255.255.0 +192.168.1.1 +PC0(超级终端下) +Switch>en +Switch#conf t +Switch(config)#interface vlan 1 //进入端口模式 +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //设置交换机管理IP地址 +Switch(config-if)#no shutdown //打开该端口 +Switch(config-if)#exit +Switch(config)#line vty 0 //进入编号为0的vty线路配置模式 +Switch(config-line)#password cisco0 //设置vty线路编号为0的登录密码 +Switch(config-line)#exit +Switch(config)#line vty 1 4 //进入编号为1~4的vty线路配置模式 +Switch(config-line)#password cisco1 //设置对应vty线路的登录密码 +Switch(config-line)#privilege level 15 //设置该线路权限级别为15 +Switch(config-line)#exit +Switch(config)#service password-encryption //启用全局密码加密功能 +Switch(config)#^z //快捷键(Ctrl+z):进入特权模式 +Switch#show r +PC0(命令提示符CMD下) +ping 192.168.1.1 //链路通 +telnet 192.168.1.1 +//输入密码: cisco0 +Switch> +PC1(命令提示符CMD下) +ping 192.168.1.1 //链路通 +telnet 192.168.1.1 +//输入密码: cisco1 +Switch#show users //显示正在使用中的控制台和所有连接中的vtp线路 +``` + +### 配置SSH登录(建议) + +必须的步骤: + +1.配置设备名称 + +``` +switch(config)# hostname sw1 +``` + +2.配置设备域名 + +``` +sw1(config)# ip domain-name qq.com +``` + +3.配置ip地址(如果是交换机,是配置其vlan的管理地址,如果是路由器,则配置接口地址) 命令如下(以思科模拟器中的交换机为例): + +``` +sw1(config)# interface vlan 1 // 进入默认的vlan +sw1(config)# ip address 192.168.2.250 255.255.255.0 // 配置管理的ip地址 +``` + +4.生成密钥对 + +``` +sw1(config)# crypto key generate rsa +How many bits in the modulus [512]:2048 +% Generating 2048 bit RSA keys, keys will be non-exportable...[OK] +``` + +5.启用SSH版本,并设置本地用户登录,同时设置本地用户和密码 + +``` +sw1(config)# ip ssh version 2 // 启用ssh版本,建议2这个版本,更加安全 +sw1(config)# line vty 0 15 // 设置0~15的虚拟线路(其实就是所有的线路) +sw1(config)# transport input ssh // 用于指定允许通过哪些协议来访问终端行(如 vty 行,即虚拟终端) +sw1(config)# login local // 允许本地账户登录 +sw1(config)# usrname admin password 113 // 设置用户名和密码,用户名可以自己设定,不一定是admin +``` + +6.保存配置 \ No newline at end of file -- Gitee From a8d1ee61df057a5e485f043f7107f57b4a76ff5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:33:35 +0000 Subject: [PATCH 04/17] =?UTF-8?q?20240421=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240421.md" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240421.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240421.md" "b/\347\216\213\345\202\262\345\263\260/20240421.md" new file mode 100644 index 0000000..41c1d2c --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240421.md" @@ -0,0 +1,37 @@ +# 三层交换机的基本配置 + +## 实验步骤: + +1. 开启路由功能 + +``` +Switch(config)#ip routing +``` + +1. 配置三层交换机端口的路由功能 + +``` +Switch(config)#interface fastEthenet 0/5 +Switch(config-if)#no switchport +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 +Switch(config-if)#no shutdown +Switch(config-if)#end +PC0设置 +192.168.1.2 +255.255.255.0 +192.168.1.1 +Switch0配置 +Switch>en +Switch#config t +Switch(config)#hostname S3560 +S3560(config)#ip routing //开启路由功能 +S3560(config)#interface fastEthemet 0/5 +S3560(config-if)#no switchport //该端口启用三层路由功能 +S3560(config-if)#ip address 192.168.5.1 255.255.255.0 //配置 IP 地址 +S3560(config-if)#no shutdown //开启端口 +S3560(conflg-if)#end +S3560# +PC0(命令提示符CMD下) +ping 192.168.1.2 //ping通自身 +ping 192.168.1.1 //ping通网关 +``` \ No newline at end of file -- Gitee From 23bb0887d16a7260e8dea0057fd4052d6a337a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:33:53 +0000 Subject: [PATCH 05/17] =?UTF-8?q?20240422=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240422.md" | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240422.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240422.md" "b/\347\216\213\345\202\262\345\263\260/20240422.md" new file mode 100644 index 0000000..c4dc358 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240422.md" @@ -0,0 +1,123 @@ +## 交换机VLAN配置 + +### 交换机的命令行VLAN模式包括: + +``` +VLAN子模式 Switch(vlan)# + +VLAN配置模式 Switch(config-vlan)# + +VLAN接口(SVI)模式 Switch(config-if)# +``` + +实验设备:Switch_2960 2台;PC 4台;直通线;交叉线。 + +## 实验步骤: + +1. 单交换机下的配置 + + - 创建若干个vlan 编号从2开始(1为默认局域网),并命名 + - 将若干端口分配到指定vlan + + ``` + Switch>en + Switch#conf t + Switch(config)#vlan 2 // 创建VLAN 2 + Switch(config-vlan)#name x1 // 命名VLAN + Switch(config-vlan)#vlan 3 + Switch(config-vlan)#name x2 + Switch(config-vlan)#vlan 3 + Switch(config-vlan)#name x3 + Switch(config-vlan)#exit + Switch(config)#inter rang fa 0/1-8 //批量指定端口 + Switch(config)#switchport access vlan 2 //批量分配端口到指定vlan + ... + Switch(config-vlan)#exit //回到全局设置模式 + Switch(config)#exit //回到特权模式 + Switch#wr m //保存 + ``` + +2. 多交换机下的配置 + + - 创建VLAN 2和VLAN 3,财务部对应VLAN 2,销售部对应VLAN 3 + - 将部门PC对应端口划分到相应的VLAN中 + - 为其中一台交换机配置VTP模式及VTP域名 + - 配置交换机间互联的端口为Trunk类型 + + ``` + PC设置 + 192.168.1.2 //PC0 + 192.168.1.3 //PC1 + 192.168.1.4 //PC2 + 192.168.1.5 //PC3 + //子网掩码和网关 + 255.255.255.0 + 192.168.1.1 + ``` + + ``` + Switch0配置 + Switch>en + Switch#conf t + Switch(config)#vlan 2 //创建VLAN 2 + Switch(config-vlan)#name Finance_Dept //将该VLAN命名为Finance_Dept + Switch(config-vlan)#vlan 3 //创建VLAN 2 + Switch(config-vlan)#name Sales_Dept //将该VLAN命名为Sales_Dept + Switch(config-vlan)#exit + Switch(config)#inter f0/1 + Switch(config-if)#switchport access vlan 2 //将该端口划分到VLAN 2 + Switch(config-if)#exit + Switch(config)#inter f0/2 + Switch(config-if)#switchport access vlan 3 //将该端口划分到VLAN 3 + Switch(config-if)#exit + Switch(config)#inter f0/24 + Switch(config-if)#switch mode trunk //将端口配置为Trunk模式 + Switch(config-if)#end + Switch#show vlan brief //显示VLAN配置信息 + Switch#vlan database //进入VLAN子模式 + Switch(vlan)#vtp server //设置VTP模式为server + Switch(vlan)#vtp domain vtp0 //设置VTP域名为vtp0 + Switch(vlan)#exit + Switch#show vtp status //查看VTP配置信息 + ``` + + 输入vlan database命令时将报告这一模式将被弃用,所以更新为如下命令(设置其中一台交换机下的vlan模式为服务器模式,以便两台设置了vlan的交换机同步vlan信息,以实现相互通讯) + + ``` + vtp mode server // 用于将交换机的vtp模式设置为server,其中一台交换机设置就可以了 + vtp domain vtp0 // 设置vtp的“域名” + ``` + + ``` + Switch1配置 + Switch>en + Switch#vlan database //进入VLAN子模式 + Switch(vlan)#vtp client //设置VTP模式为client + Switch(vlan)#vtp domain vtp0 //设置VTP域名为vtp0,此处不填亦可 + Switch(vlan)#exit + Switch#show vtp status //查看VTP配置信息 + Switch#show vlan brief //显示VLAN配置信息 + Switch#conf t + Switch(config)#inter f0/1 + Switch(config-if)#switchport access vlan 2 //将该端口划分到VLAN 2 + Switch(config-if)#exit + Switch(config)#inter f0/2 + Switch(config-if)#switchport access vlan 3 //将该端口划分到VLAN 3 + Switch(config-if)#exit + Switch(config)#inter f0/24 + Switch(config-if)#switch mode trunk //将端口配置为Trunk模式 + Switch(config-if)#end + Switch#show r + ``` + + ``` + PC0(命令提示符CMD下) + ping 192.168.1.3 //链路不通 + ping 192.168.1.4 //链路通 + ``` + + ``` + PC1(命令提示符CMD下) + ping 192.168.1.4 //链路不通 + ping 192.168.1.5 //链路通 + ``` \ No newline at end of file -- Gitee From dcda8042cad998c6157928468131886d5ed9445a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:34:24 +0000 Subject: [PATCH 06/17] =?UTF-8?q?20240423=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240423.md" | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240423.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240423.md" "b/\347\216\213\345\202\262\345\263\260/20240423.md" new file mode 100644 index 0000000..0ef6013 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240423.md" @@ -0,0 +1,153 @@ +### 生成树协议 + +为了提高网络可靠性 交换网络中通常会使用冗余链路 而冗余链路会给交换网络带来环路风险 并导致广播风暴以及MAC地址表不稳定等问题 进而会影响到用户的通信质量 生成树协议(Spanning Tree Protocol)可以在提高可靠性的同时又能避免环路带来的各种问题 + +### 生成树版本 + +生成树(STP) + +- stp通过阻塞端口来消除环路 并能够实现链路备份目的 +- 消除了广播风暴 +- 物理链路冗余 网络变成了层次化结构的网络 + +快速生成树协议(RSTP) + +- 当主链路断掉后可以在一秒内收敛快速恢复网络的连通性 + +### 生成树端口四种状态 + +- 阻塞(Block):只监听/接收BPDU报文 +- 侦听(Listening):只能接收或发送BPDU报文 +- 学习(Learning):能接收或发送BPDU报文,并形成MAC地址表,但不能转发数据帧 +- 转发(Forwarding):能接收或发送BPDU报文,并形成MAC地址表,同时发送和接收数据帧 + +``` +注意:两台交换机都配置快速生成树协议后,再将两台交换机连接起来 如果先连线再配置会造成广播风暴,影响交换机的正常工作 +``` + +![alt text](https://img2.imgtp.com/2024/04/23/LwG4ncNU.png) + +### SW1 + +``` +Switch>enable +Switch#configure terminal +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#hostname SW1 +SW1(config-vlan)#int f0/1 +SW1(config-if)#swi acc vlan 10 +SW1(config-if)#int g0/1-2 +SW1(config-if)#swi mode trunk -- 开启端口Trunk模式 +SW1(config-if)#exit +SW1(config)#spanning-tree mode rapid-pvst --配置生成树协议 +``` + +### SW2 + +``` +Switch>enable +Switch#configure terminal +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#hostname SW2 +SW2(config-vlan)#int f0/1 +SW2(config-if)#swi acc vlan 10 +SW2(config-if)#int g0/1-2 +SW2(config-if)#swi mode trunk -- 开启端口Trunk模式 +SW2(config-if)#exit +SW2(config)#spanning-tree mode rapid-pvst --配置生成树协议 +``` + +配置两台pc机IP及子网掩码 测试是否能联通 + +### 查看交换机生成树协议配置 + +- Switch#show spanning-tree summary +- Switch#show spanning-tree + +### 测试链路 + +``` +在pc机中ping -t --不间断的ping指定计算机 +Switch(config)#inter g0/1 --关闭主链路上的端口 +Switch(config-if)#shutdown +``` + +这时候可以发现当主链路断开后 两台pc机依然能够持续ping通中 (通过生成树协议在两个或两个通信时候来解决多交换机环路问题) + +![alt text](https://img2.imgtp.com/2024/04/23/FrzwpsBw.png)生成树协议 + +为了提高网络可靠性 交换网络中通常会使用冗余链路 而冗余链路会给交换网络带来环路风险 并导致广播风暴以及MAC地址表不稳定等问题 进而会影响到用户的通信质量 生成树协议(Spanning Tree Protocol)可以在提高可靠性的同时又能避免环路带来的各种问题 + +### 生成树版本 + +生成树(STP) + +- stp通过阻塞端口来消除环路 并能够实现链路备份目的 +- 消除了广播风暴 +- 物理链路冗余 网络变成了层次化结构的网络 + +快速生成树协议(RSTP) + +- 当主链路断掉后可以在一秒内收敛快速恢复网络的连通性 + +### 生成树端口四种状态 + +- 阻塞(Block):只监听/接收BPDU报文 +- 侦听(Listening):只能接收或发送BPDU报文 +- 学习(Learning):能接收或发送BPDU报文,并形成MAC地址表,但不能转发数据帧 +- 转发(Forwarding):能接收或发送BPDU报文,并形成MAC地址表,同时发送和接收数据帧 + +``` +注意:两台交换机都配置快速生成树协议后,再将两台交换机连接起来 如果先连线再配置会造成广播风暴,影响交换机的正常工作 +``` + +![alt text](https://img2.imgtp.com/2024/04/23/LwG4ncNU.png) + +### SW1 + +``` +Switch>enable +Switch#configure terminal +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#hostname SW1 +SW1(config-vlan)#int f0/1 +SW1(config-if)#swi acc vlan 10 +SW1(config-if)#int g0/1-2 +SW1(config-if)#swi mode trunk -- 开启端口Trunk模式 +SW1(config-if)#exit +SW1(config)#spanning-tree mode rapid-pvst --配置生成树协议 +``` + +### SW2 + +``` +Switch>enable +Switch#configure terminal +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#hostname SW2 +SW2(config-vlan)#int f0/1 +SW2(config-if)#swi acc vlan 10 +SW2(config-if)#int g0/1-2 +SW2(config-if)#swi mode trunk -- 开启端口Trunk模式 +SW2(config-if)#exit +SW2(config)#spanning-tree mode rapid-pvst --配置生成树协议 +``` + +配置两台pc机IP及子网掩码 测试是否能联通 + +### 查看交换机生成树协议配置 + +- Switch#show spanning-tree summary +- Switch#show spanning-tree + +### 测试链路 + +``` +在pc机中ping -t --不间断的ping指定计算机 +Switch(config)#inter g0/1 --关闭主链路上的端口 +Switch(config-if)#shutdown +``` + +这时候可以发现当主链路断开后 两台pc机依然能够持续ping通中 (通过生成树协议在两个或两个通信时候来解决多交换机环路问题) + +![alt text](https://img2.imgtp.com/2024/04/23/FrzwpsBw.png) \ No newline at end of file -- Gitee From 67bd088daf9516b9710757df8c01f299de64f567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:45:09 +0000 Subject: [PATCH 07/17] =?UTF-8?q?20240424=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240424.md" | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240424.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240424.md" "b/\347\216\213\345\202\262\345\263\260/20240424.md" new file mode 100644 index 0000000..e2776a4 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240424.md" @@ -0,0 +1,93 @@ +## 端口聚合配置 + +端口聚合(又称为链路聚合) 将交换机上的多个端口在物理上连接起来 在逻辑上捆绑在一起 形成一个拥有较大宽带的端口 可以实现负载均衡并提供冗余链路 + +- 由于cisco交换机默认开启生成树协议 要实现端口聚合 需要关闭生成树协议 + +``` +Switch(config)#no spanning-tree moed rapid-post +``` + +- 配置端口模式 + +``` +Switch(config)#interface range g0/1-2 +``` + +- 将端口加入聚合组 + +``` +Switch(config-if-rang)#channel-group 1 mode on +-- mode active表示接口将以主动模式参与LACP协商 +-- 还有另一种模式passive,表示接口将以被动模式参与协商 +Switch(config-if-rang)#swi mode trunk -- cisco交换机自动将连接端口配置trunk模式 所以在测试中可以略过这一步配置 +``` + +- 配置聚合口 + +``` +Switch(config)#port-channel load-balance dst-ip -- 按目的IP地址来实现负载均衡 +Switch(config)#interface port-channel 1 -- 如果需要的话可以进入port-channel接口配置模式并分配IP地址等参数 +Switch#show interfaces etherchannel -- 显示聚合端口信息 +``` + +当关闭了g0/1端口后还能ping通 且未出现丢包 + +![alt text](https://img2.imgtp.com/2024/04/24/nv8J8cFj.png) + +## 端口安全配置 + +![alt text](https://img2.imgtp.com/2024/04/27/z6Y2COTd.png) + +### 配置端口安全 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#int range f0/3-24,g0/1-2 -- 禁用未使用的端口 +Switch(config-if-range)#shutdown +Switch(config-if-range)#exit +Switch(config)#int range f0/1-2 +Switch(config-if-range)#swi port-security -- 端口安全配置命令 +Command rejected: FastEthernet0/1 is a dynamic port. -- 这里报错了 +Command rejected: FastEthernet0/2 is a dynamic port. -- 这是因为端口安全只能在手动配置的接入模式(access)端口或手动配置的中继(trunk)端口上 +Switch(config-if-range)#swi mode acc -- 设置接入模式 +Switch(config-if-range)#swi port-security -- 再一次配置就没有报错提示 +Switch(config-if-range)#swi port-security maximum 1 -- 限制端口上MAC地址最大数量 默认值为1 +Switch(config-if-range)#swi port-security violation restrict -- 设置违规模式 +Switch(config-if-range)#swi port-security mac-address sticky + +%LINK-5-CHANGED: Interface FastEthernet0/3, changed state to administratively down +%LINK-5-CHANGED: Interface FastEthernet0/4, changed state to administratively down +······ +Switch(config-if-range)#exit + +* ipconfig /all查看每台pc机的MAC地址(Physical Address)* + +Switch(config)#int f0/1 +Switch(config-if)#switchport port-security mac-address sticky MAC地址 +Switch(config-if)#exit +Switch(config)#int f0/2 +Switch(config-if)#switchport port-security mac-address sticky MAC地址 +Switch(config-if)#exit +``` + +### 动态获取 + +``` +Switch(config-if)#swi port-security mac-address MAC地址 +在执行switchport port-security之后,这个端口直接连接的设备的源MAC地址就会成为安全MAC。但是,这个地址不会添加到启动配置中,也就是说,交换机重启后必须重新学习MAC地址 +``` + +### 动态获取-粘滞(Sticky) + +``` +Switch(config-if)#swi port-security mac-address sticky (MAC地址) -- 将动态获取的MAC地址写入到运行配置文件中 +``` + +### 设置端口中违规后的操作 有以下三种模式 + +- swi port-security violation (shutdown) -- 如果违反规定关闭端口 +- swi port-security violation (protect) -- 当违规时 只丢弃违规的数据流量 而且不会有通知有流量违规 +- swi port-security violation (restrict) -- 当违规时 只丢弃违规的流量 不违规的正常转发 但它会产生流量违规通知 \ No newline at end of file -- Gitee From 019fb0e273bf2804fece3efdcce947894f925c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:45:27 +0000 Subject: [PATCH 08/17] =?UTF-8?q?20240425=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240425.md" | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240425.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240425.md" "b/\347\216\213\345\202\262\345\263\260/20240425.md" new file mode 100644 index 0000000..e5549dd --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240425.md" @@ -0,0 +1,79 @@ +## 三层交换机配置 + +- 开启路由功能 + +``` +Switch(config)#ip routing +``` + +- 三层交换机端口默认为二层口,如果需要启用三层功能就需要在此端口输入`no switchport`命令 +- 三层交换机设置Trunk模式 + +``` +Switch(config-if-range)#swi trunk encapsulation dot1q +Switch(config-if-range)#swi mode trunk +``` + +- 显示路由表 + +``` +Switch#show ip route +注意:配置三层交换机通讯时一定要给pc机配置网关 +``` + +![alt text](https://img2.imgtp.com/2024/04/27/sJ4D2O9A.png) + +### SW1 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 10 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#int f0/1 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config-vlan)#int f0/2 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 20 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int g0/1 +Switch(config-if)#swi mode trunk +Switch(config-if)#ex +``` + +### SW2 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 10 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#exit +Switch(config)#ip routing -- 开启三层交换机路由功能 +Switch(config-vlan)#int vlan 10 -- 配置VLAN网关及子网掩码并开启 +Switch(config-if)#ip addr 192.168.1.1 255.255.255.0 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int vlan 20 +Switch(config-if)#ip addr 192.168.2.1 255.255.255.0 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int g0/1 +Switch(config-if-range)#swi trunk encapsulation dot1q -- 封装 设置Trunk模式 +Switch(config-if-range)#swi mode trunk +Switch(config-if-range)#ex +Switch(config)#int f0/1 -- 将端口划分到VLAN中并开启 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#do wr m +Building configuration... +[OK] +``` \ No newline at end of file -- Gitee From ccff9eb3ffa6c7e1134d8d018fc32b317fd9a689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:45:49 +0000 Subject: [PATCH 09/17] =?UTF-8?q?20240426=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240426.md" | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240426.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240426.md" "b/\347\216\213\345\202\262\345\263\260/20240426.md" new file mode 100644 index 0000000..edfc39f --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240426.md" @@ -0,0 +1,95 @@ +## 配置三层交换机VLAN之间通讯 + +![alt text](https://img2.imgtp.com/2024/04/27/jFets3m8.png) + +### SW1 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 10 -- 创建VLAN10、VLAN20 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#ex +Switch(config)#int f0/1 -- 将端口划分到VLAN中设置模式并开启 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#no shut +Switch(config-if)#int f0/2 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 20 +Switch(config-if)#no shut +Switch(config-if)#int f0/3 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#no shut +Switch(config-if)#int f0/4 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 20 +Switch(config-if)#no shut +Switch(config-if)#int g0/1 -- 设置交换机为Trunk模式 +Switch(config-if)#swi mode trunk +Switch(config-if)#ex +Switch(config)# +``` + +### SW2 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 20 +Switch(config-vlan)#int f0/1 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 20 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int g0/2 +Switch(config-if)#swi mode trunk +Switch(config-if)#ex +Switch(config)# +配置完两台交换机时可以测试一下同VLAN能否ping通 +``` + +### SW3 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 10 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#vlan 30 +Switch(config-vlan)#exit +Switch(config)#ip routing -- 开启三层交换机路由功能 +Switch(config-vlan)#int vlan 10 -- 配置VLAN网关及子网掩码并开启 +Switch(config-if)#ip addr 192.168.1.1 255.255.255.0 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int vlan 20 +Switch(config-if)#ip addr 192.168.2.1 255.255.255.0 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int vlan 30 +Switch(config-if)#ip addr 192.168.3.1 255.255.255.0 +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#int rang g0/1-2 +Switch(config-if-range)#swi trunk encapsulation dot1q -- 封装 设置Trunk模式 +Switch(config-if-range)#swi mode trunk +Switch(config-if-range)#ex +Switch(config)#int f0/1 -- 将端口划分到VLAN中并开启 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#no shut +Switch(config-if)#int f0/2 +Switch(config-if)#swi acc vlan 30 +Switch(config-if)#swi mode acc +Switch(config-if)#no shut +Switch(config-if)#ex +Switch(config)#do wr m +Building configuration... +[OK] +配置完所有可以测试一下同VLAN能否ping通 不同VLAN能否ping通 +``` \ No newline at end of file -- Gitee From f41a9de3324c366010abaade142f3655a2bdea4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:46:14 +0000 Subject: [PATCH 10/17] =?UTF-8?q?20240428=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240428.md" | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240428.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240428.md" "b/\347\216\213\345\202\262\345\263\260/20240428.md" new file mode 100644 index 0000000..12722c1 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240428.md" @@ -0,0 +1,97 @@ +## 单臂路由 + +单臂路由(router-on-a-sTIck)是指在路由器的一个接口上通过配置子接口(或“逻辑接口”,并不存在真正物理接口)的方式,实现原来相互隔离的不同VLAN(虚拟局域网)之间的互联互通 + +### 为什么用单臂路由 + +在没有单臂路由的情况下,不同VLAN之间的通信需要通过网络中的路由器进行,这会导致数据传输延迟并增加了网络复杂性。使用单臂路由后,可以在一个物理接口上通过配置逻辑接口的方式实现不同VLAN之间的互联互通,降低了网络设备的投入成本,简化了网络结构,并提高了网络管理效率。 + +另外,单臂路由的NAT(网络地址转换)协议功能可以对外提供访问服务,使得用户可以访问外部网络资源。同时,通过一些特定的配置,单臂路由还可以实现网络流量的监控、管理和优化,进一步提高了网络的性能和安全性。特别是在企业网络和公共网络中,它的应用非常广泛 + +### 单臂路由的子接口 + +路由器的物理接口可以被划分成多个逻辑接口,这些被划分后的逻辑接口被形象的称为子接口。值得注意的是这些逻辑子接口不能被单独的开启或关闭,也就是说,当物理接口被开启或关闭时,所有的该接口的子接口也随之被开启或关闭 + +### 优缺点 + +  VLAN能有效分割局域网,实现各网络区域之间的访问控制。但现实中,往往需要配置某些VLAN之间的互联互通。比如,你的公司划分为领导层、销售部、财务部、人力部、科技部、审计部,并为不同部门配置了不同的VLAN,部门之间不能相互访问,有效保证了各部门的信息安全。但经常出现领导层需要跨越VLAN访问其他各个部门,这个功能就由单臂路由来实现 + +- 优点: 实现不同vlan之间的通信,有助理解、学习VLAN原理和子接口概念 +- 缺点: 容易成为网络单点故障,配置稍有复杂,现实意义不大 + +![alt text](https://img2.imgtp.com/2024/04/28/eboM8uz8.png) + +- 交换机配置 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 10 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#vlan 30 +Switch(config-vlan)#vlan 40 +Switch(config-vlan)#exit +Switch(config)#interface fastEthernet 0/1 +Switch(config-if)#switchport mode access -- 主机与交换机之间要开启access链路模式 +Switch(config-if)#switchport access vlan 10 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface fastEthernet 0/2 +Switch(config-if)#switchport mode access +Switch(config-if)#switchport access vlan 20 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface fastEthernet 0/3 +Switch(config-if)#switchport mode access +Switch(config-if)#switchport access vlan 30 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface fastEthernet 0/4 +Switch(config-if)#switchport mode access +Switch(config-if)#switchport access vlan 40 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface fastEthernet 0/5 +Switch(config-if)#switchport mode trunk -- 路由器与交换机之间要开启trunk链路模式 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)# +``` + +- 路由器配置 + +``` +Would you like to enter the initial configuration dialog? [yes/no]: no +Press RETURN to get started! + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#interface f0/0 --Cisco路由器接口默认是关闭的 配置前先进行开启接口 +Router(config-if)#no shutdown +Router(config-if)#exit +Router(config)#interface fastEthernet 0/0.1 +Router(config-subif)#encapsulation dot1Q 10 -- 子接口使用了802.1Q协议进行封装 子接口后数字对应相应的VLAN +Router(config-subif)#ip address 192.168.1.1 255.255.255.0 -- 子接口分配网关以及子网掩码 +Router(config-subif)#no shutdown +Router(config-subif)#exit +Router(config)#interface fastEthernet 0/0.2 -- 子接口对应一个VLAN +Router(config-subif)#encapsulation dot1Q 20 +Router(config-subif)#ip address 192.168.2.1 255.255.255.0 +Router(config-subif)#no shutdown +Router(config-subif)#exit +Router(config)#interface fastEthernet 0/0.3 +Router(config-subif)#encapsulation dot1Q 30 +Router(config-subif)#ip address 192.168.3.1 255.255.255.0 +Router(config-subif)#no shutdown +Router(config-subif)#exit +Router(config)#interface fastEthernet 0/0.4 +Router(config-subif)#encapsulation dot1Q 40 +Router(config-subif)#ip address 192.168.4.1 255.255.255.0 +Router(config-subif)#no shutdown +Router(config-subif)#exit +Router(config)# +``` + +配置完成 测试不同VLAN之间能否互通 能通表示配置单臂路由成功 \ No newline at end of file -- Gitee From e3d103388b915d06e3577368b3ec49d14d240f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:50:20 +0000 Subject: [PATCH 11/17] =?UTF-8?q?20240429=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240429.md" | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240429.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240429.md" "b/\347\216\213\345\202\262\345\263\260/20240429.md" new file mode 100644 index 0000000..411e906 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240429.md" @@ -0,0 +1,102 @@ +### 配置单臂静态路由 + +![![image-20240429112512109](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20240429112512109.png)](https://img2.imgtp.com/2024/05/05/AatgYDUT.png) + +### 交换机配置 + +``` +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 10 +Switch(config-vlan)#vlan 20 +Switch(config-vlan)#int f0/1 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 10 +Switch(config-if)#no shut +Switch(config-if)#int f0/2 +Switch(config-if)#swi mode acc +Switch(config-if)#swi acc vlan 20 +Switch(config-if)#no shut +Switch(config-if)#int f0/4 +Switch(config-if)#swi mode trunk +Switch(config-if)#swi trunk all +Switch(config-if)#swi trunk allowed vlan 10,20 -- 允许所有VLAN通过 +Switch(config-if)#no shut +Switch(config-if)#exit +Switch(config)# +``` + +### 路由器一 + +``` +Would you like to enter the initial configuration dialog? [yes/no]: no +Press RETURN to get started! + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#int f0/0 +Router(config-if)#no shut +Router(config-if)#int f0/0.1 -- 进入子接口 +Router(config-subif)#encapsulation dot1Q 10 -- 子接口封装配置网关及子网掩码 +Router(config-subif)#ip addr 192.168.1.1 255.255.255.0 +Router(config-subif)#no shut +Router(config-subif)#int f0/0.2 +Router(config-subif)#encapsulation dot1Q 20 +Router(config-subif)#ip addr 192.168.2.1 255.255.255.0 +Router(config-subif)#no shut +Router(config-subif)#exit +Router(config)#int f0/1 +Router(config-if)#ip addr 10.10.10.31 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#exit +Router(config)#ip route 192.168.3.0 255.255.255.0 10.10.10.13 -- 配置静态路由 +Router(config)#ip route 192.168.4.0 255.255.255.0 11.11.11.12 -- 目的地址 子网掩码 下一跳地址IP +Router(config)#ip route 192.168.4.0 255.255.255.0 11.11.11.30 +Router(config)# +``` + +### 路由器二 + +``` +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#int f0/0 +Router(config-if)#ip addr 10.10.10.13 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#int f0/1 +Router(config-if)#ip addr 192.168.3.1 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#exit +Router(config)#int s0/3/0 +Router(config-if)#ip addr 11.11.11.30 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#clock rate 64000 +Router(config-if)#exit +Router(config)#ip route 192.168.2.0 255.255.255.0 10.10.10.31 +Router(config)#ip route 192.168.1.0 255.255.255.0 10.10.10.31 +Router(config)#ip route 192.168.4.0 255.255.255.0 11.11.11.12 +Router(config)# +``` + +### 路由器三 + +``` +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#int s0/3/1 +Router(config-if)#ip addr 11.11.11.12 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#int f0/0 +Router(config-if)#ip addr 192.168.4.1 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#exit +Router(config)#ip route 192.168.3.0 255.255.255.0 11.11.11.30 +Router(config)#ip route 192.168.2.0 255.255.255.0 10.10.10.31 +Router(config)#ip route 192.168.1.0 255.255.255.0 10.10.10.31 +Router(config)#ip route 192.168.3.0 255.255.255.0 10.10.10.13 +Router(config)# +``` \ No newline at end of file -- Gitee From 8fe48280ea3252e28da08898cb67fbbe9d153b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:50:45 +0000 Subject: [PATCH 12/17] =?UTF-8?q?202404230506=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240506.md" | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240506.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240506.md" "b/\347\216\213\345\202\262\345\263\260/20240506.md" new file mode 100644 index 0000000..3e5832a --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240506.md" @@ -0,0 +1,80 @@ +# RIP配置 + +`RIP(Routing Information Protocol)-路由信息协议`:是一种基于距离矢量算法的协议 以跳数(被传送数据所经过路由器的个数)为度数来衡量到达目标网络的距离 属于IGP(内部网关协议)协议 有RIP1和RIP2两个版本 基于UDP协议 端口号为520 主要用于小型网络 + +![alt text](https://img2.imgtp.com/2024/05/06/fb1PdHCz.png) + +### 配置路由器(Router0)端口 + +``` +Would you like to enter the initial configuration dialog? [yes/no]: no +Press RETURN to get started! + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#int g0/0/0 +Router(config-if)#ip addr 192.168.10.1 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#int g0/0/1 +Router(config-if)#ip addr 10.10.10.2 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#exit + +--配置路由器(Router0)RIP协议 + +Router(config)#route rip -- 开启RIP协议 +Router(config-router)#version 2 -- 启用RIP协议第二版 +Router(config-router)#network 192.168.10.0 -- 宣告网段 +Router(config-router)#network 10.10.10.0 +Router(config-router)#no auto-summary -- 关闭自动汇总 +Router(config-router)#do wr m +Building configuration... +[OK] +``` + +### 为什么要关闭自动汇总 + +是因为RIP协议更新时不带子网掩码,路由器会根据IP自动判断汇总给其加上自己汇总后的子网掩码。假如有个网段是30.1.1.0/24,更新时不会带上24,路由器会认为是A类IP,通过自动汇总会把24汇总成8,这个不是我们想要的,所以要关闭自动汇总 + +### 配置路由器(Router1)端口 + +``` +Would you like to enter the initial configuration dialog? [yes/no]: no +Press RETURN to get started! + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#int g0/0/0 +Router(config-if)#ip addr 192.168.20.1 255.255.255.0 +Router(config-if)#no shut +Router(config)#int g0/0/1 +Router(config-if)#ip addr 10.10.10.3 255.255.255.0 +Router(config-if)#no shut +Router(config-if)#exit + +--配置路由器(Router1)RIP协议 + +Router(config)#route rip +Router(config-router)#version 2 +Router(config-router)#network 192.168.20.0 +Router(config-router)#network 10.10.10.0 +Router(config-router)#no auto-summary +Router(config-router)#do wr m +Building configuration... +[OK] +``` + +### 查看路由表 + +``` +Router(config)#do show ip route +L-本地,C-直连,S-静态,R-RIP,以R开头的就是RIP协议的 +``` + +![alt text](https://img2.imgtp.com/2024/05/06/8xyGLw5S.png) + +配置完成后进入主机中测试链路(此时网关以及主机都能ping通(且线路是绿灯`注意绿灯不代表一定是能通`)) + +![alt text](https://img2.imgtp.com/2024/05/06/qJoKQPiO.png) \ No newline at end of file -- Gitee From 5877daa78c940a596e1926c0a59841f4373ffdda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Mon, 13 May 2024 02:51:15 +0000 Subject: [PATCH 13/17] =?UTF-8?q?20240508=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240508.md" | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240508.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240508.md" "b/\347\216\213\345\202\262\345\263\260/20240508.md" new file mode 100644 index 0000000..e6b4739 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240508.md" @@ -0,0 +1,127 @@ +# RIP加SVI配置 + +``` +网关:在同一网络下是不需要用到网关 而在需要访问另一个网络时用到网关来转发数据、数据包` `实现VLAN间互通就两种方法:一种是三层交换机SVI 一种是单臂路由 +``` + +![alt text](https://img2.imgtp.com/2024/05/08/pzfJqZD5.png) + +### 配置交换机 + +``` +Switch>enable +Switch#configure terminal +Switch(config)#vlan 10 -- 创建VLAN10、VLAN20 +Switch(config-vlan)#exit +Switch(config)#vlan 20 +Switch(config-vlan)#exit +Switch(config)#interface range fastEthernet 0/1-2 -- 将端口加入到对应的VLAN中并开启端口 +Switch(config-if-range)#switchport mode access -- 主机与交换机连接链路设置为接入模式 +Switch(config-if-range)#switchport access vlan 10 +Switch(config-if-range)#no shutdown +Switch(config-if-range)#exit +Switch(config)#interface range fastEthernet 0/3-4 +Switch(config-if-range)#switchport mode access +Switch(config-if-range)#switchport access vlan 20 +Switch(config-if-range)#no shutdown +Switch(config-if-range)#exit +Switch(config)#interface gigabitEthernet 0/2 -- 交换机与交换机之间的链路设置为中继模式 +Switch(config-if)#switchport mode trunk +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)# +``` + +### 配置三层交换机 + +``` +Switch>enable +Switch#configure terminal +Switch(config)#ip routing -- 三层开启路由功能 +Switch(config)#vlan 10 -- 创建VLAN10、VLAN20 +Switch(config-vlan)#exit +Switch(config)#vlan 20 +Switch(config-vlan)#exit +Switch(config)#interface vlan 10 -- 每个VLAN配置相应网关以及子网掩码并开启端口 +Switch(config-if)#ip addr 192.168.10.1 255.255.255.0 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface vlan 20 +Switch(config-if)#ip addr 192.168.20.1 255.255.255.0 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface gigabitEthernet 0/2 +Switch(config-if)#switchport trunk encapsulation dot1q -- 交换机与交换机之间的链路设置为中继模式(三层注意先封装) +Switch(config-if)#switchport mode trunk +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#interface gigabitEthernet 0/1 -- 交换机与路由器连接(三层交换机默认为二层端口要开启路由端口) +Switch(config-if)#no switchport +Switch(config-if)#ip address 10.10.10.1 255.255.255.0 +Switch(config-if)#no shutdown +Switch(config-if)#exit +Switch(config)#route rip -- 配置RIP动态路由协议将信息传递给附近的端口 +Switch(config-router)#version 2 +Switch(config-router)#network 10.10.10.0 +Switch(config-router)#network 192.168.10.0 +Switch(config-router)#network 192.168.20.0 +Switch(config-router)#do wr m +Building configuration... +[OK] +``` + +### 路由器配置 + +- 将R1、R2的每个端口配置IP地址以及子网掩码并开启端口 +- 在R1、R2路由器配置RIP动态路由协议将信息传递给附近的端口 + +### 配置路由器一 + +``` +Router>enbale +Router#configure terminal +Router(config)#interface gigabitEthernet 0/1 +Router(config-if)#ip address 10.10.10.2 255.255.255.0 +Router(config-if)#no shutdown +Router(config-if)#exit +Router(config)#interface gigabitEthernet 0/0 +Router(config-if)#ip address 192.168.30.1 255.255.255.0 +Router(config-if)#no shutdown +Router(config-if)#exit +Router(config)#interface gigabitEthernet 0/2 +Router(config-if)#ip address 172.16.88.13 255.255.255.0 +Router(config-if)#no shutdown +Router(config-if)#exit +Router(config)#route rip +Router(config-router)#version 2 +Router(config-router)#network 10.10.10.0 +Router(config-router)#network 192.168.30.0 +Router(config-router)#network 172.16.88.0 +Router(config-router)#do wr m +Building configuration... +[OK] +``` + +### 配置路由器二 + +``` +Router>enable +Router#configure terminal +Router(config)#interface gigabitEthernet 0/1 +Router(config-if)#ip address 172.16.88.180 255.255.255.0 +Router(config-if)#no shutdown +Router(config-if)#exit +Router(config)#interface gigabitEthernet 0/0 +Router(config-if)#ip address 192.168.40.1 255.255.255.0 +Router(config-if)#no shutdown +Router(config-if)#exit +Router(config)#route rip +Router(config-router)#version 2 +Router(config-router)#network 172.16.88.0 +Router(config-router)#network 192.168.40.0 +Router(config-router)#do wr m +Building configuration... +[OK] +``` + +配置完成后进入主机中测试链路(此时网关以及主机都能ping通(且线路是绿灯`注意绿灯不代表一定是能通`)) \ No newline at end of file -- Gitee From 4d43530c9483b2f937bd4eb990a0fa4d852fa4f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Wed, 15 May 2024 02:17:12 +0000 Subject: [PATCH 14/17] =?UTF-8?q?20240509=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- "\347\216\213\345\202\262\345\263\260/20240509.md" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240509.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240509.md" "b/\347\216\213\345\202\262\345\263\260/20240509.md" new file mode 100644 index 0000000..9a68798 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240509.md" @@ -0,0 +1,14 @@ +#### OSPF,是目前网络中应用最广泛的路由协议之一 + +#### OSPF,适用于中大型网络 + +#### 路由器通过路由选择协议建立了一个正确、稳定的路由表后,每当收到IP分组时,会将其沿着一条从源结点到达目的结点的最佳路径进行转发,大致过程如下: + +1、目的IP地址,目的网络 2、达目的网络的下一跳路由器的IP地址,将该IP分组 3、当下一跳路由器接收到该IP分组后,进行类似处理并转发,IP分 4、若目的网络是与路由器的端口直连的,则直接将IP分组转发到路 5、若在路由表中既没有下一跳路由地址,也没有目的端口,则将IP分组 6、若没有设置默认路由或在默认路由中仍没有该目的网络的路由信息,则直接将该IP分组丢弃。 + +``` +启用OSPF协议,从属OSPF进程ID=1 +Router(config)#route ospf 1 +Router(config-router)#net 192.168.10.0 0.0.0.255 area 0 +Router(config-router)#net 20.20.11.0 0.0.0.255 area 0 +``` \ No newline at end of file -- Gitee From 7df318793915c9adaf5214f78b114fd0df098f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Wed, 15 May 2024 02:17:53 +0000 Subject: [PATCH 15/17] =?UTF-8?q?20240510=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- "\347\216\213\345\202\262\345\263\260/20240510.md" | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240510.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240510.md" "b/\347\216\213\345\202\262\345\263\260/20240510.md" new file mode 100644 index 0000000..65d0718 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240510.md" @@ -0,0 +1,3 @@ +### 注意事项 + +1、配置ospf的所需ip网段 2、三层交换机记得IP routing 3、IP 地址得配置正确 \ No newline at end of file -- Gitee From b69c4bdd5503a46eb419df363beb1809548a8dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Wed, 15 May 2024 02:18:17 +0000 Subject: [PATCH 16/17] =?UTF-8?q?20240511=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- "\347\216\213\345\202\262\345\263\260/20240511.md" | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240511.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240511.md" "b/\347\216\213\345\202\262\345\263\260/20240511.md" new file mode 100644 index 0000000..80e5b2c --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240511.md" @@ -0,0 +1,11 @@ +###### 1、先下载markdown-blog-v1.1.1-windows-amd64 + +###### 2、打开Tabby或者cmd + +###### 3、进入你文件下载的地方,点开文件属性就可以查看到 + +###### 4、在markdown-blog-v1.1.1-windows-amd64内创建一个文件夹,把自己的笔记导入进去 + +###### 5、./markdown-blog web(运行) + +###### 6、查看效果 \ No newline at end of file -- Gitee From b5767b759e4cebc7a2e3bc5f393fd1de8c798249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=82=B2=E5=B3=B0?= <11802260+wang-aofen@user.noreply.gitee.com> Date: Wed, 15 May 2024 02:18:40 +0000 Subject: [PATCH 17/17] =?UTF-8?q?20240513=E7=8E=8B=E5=82=B2=E5=B3=B0.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王傲峰 <11802260+wang-aofen@user.noreply.gitee.com> --- .../20240513.md" | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 "\347\216\213\345\202\262\345\263\260/20240513.md" diff --git "a/\347\216\213\345\202\262\345\263\260/20240513.md" "b/\347\216\213\345\202\262\345\263\260/20240513.md" new file mode 100644 index 0000000..81f9598 --- /dev/null +++ "b/\347\216\213\345\202\262\345\263\260/20240513.md" @@ -0,0 +1,124 @@ +# [www.yating.top](https://gitee.com/link?target=http%3A%2F%2Fwww.yating.top) + +#### 先下载node.js(去cmd npm -v)去查看npm有没有下载 + +#### 1、创建一个vitpress的文件夹 + +#### 2、在vscode打开,打开终端,输入 npx vitepress init,选择yes或者no + +#### 3、会生成一个文件夹,里边有package.json的文件,文件内容如下: + +``` +{ + "scripts": { + "docs:dev": "vitepress dev no", + "docs:build": "vitepress build no", + "docs:preview": "vitepress preview no" + } +} +``` + +#### 4、就可以在config.mts里边开始进行编写 + +``` +import { defineConfig } from 'vitepress' + +// https://vitepress.dev/reference/site-config +export default defineConfig({ + title: "今天你学习了吗", + description: "", + themeConfig: { + // https://vitepress.dev/reference/default-theme-config + nav: [ + { text: '首页', link: '/' }, + { + text:'下拉菜单', + items: [ + { text: '名字', link: '对应的路径' }, + { text:'计算机基础',link:'/计算机基础/20240229-开学第一课笔记'}, + { text:'20240401-计算机网络基础',link:'/计算机网络基础/20240401-计算机网络基础'}, + + ] + } + ], + + sidebar: [ + { + text: '计算机基础', + collapsed: true, + items: [ + { text: '', link: '对应的路径' }, + { text:'20240229-开学第一课笔记',link:'/计算机基础/20240229-开学第一课笔记'}, + { text:'20240301-计算机基础笔记',link:'/计算机基础/20240301-计算机基础笔记'}, + { text: '20240302-计算机基础2笔记', link: '/计算机基础/20240302-计算机基础2笔记' }, + { text: '20240304-计算机基础3笔记', link: '/计算机基础/20240304-计算机基础3笔记' }, + ] + }, + { + text: '计算机网络基础', + collapsed: true, + items: [ + { text: '', link: '对应的路径' }, + { text:'20240401-计算机网络基础',link:'/计算机网络基础/20240401-计算机网络基础'}, + { text:'20240403-计算机网络基础2',link:'/计算机网络基础/20240403-计算机网络基础2'}, + { text: '220240407-计算机网络基础3', link: '/计算机网络基础/20240407-计算机网络基础3' }, + { text: '20240408-计算机网络基础4', link: '/计算机网络基础/20240408-计算机网络基础4' }, + { text: '20240410-计算机网络基础5', link: '/计算机网络基础/20240410-计算机网络基础5' }, + + ] + } + ], + + socialLinks: [ + { icon: 'github', link: 'https://github.com/vuejs/vitepress' } + ] + } +}) +``` + +#### 5、终端运行:去package.json运行npm run docs:dev + +#### 6、打包,把鼠标移到package.json的第二行点击运行脚本(打包成功会有一个dist的文件夹里边包含了你的笔记以及跳转文件等) + +#### 7、登入ssh root@域名.top + +##### 7.1:安装nginx(apt install nginx -y ) + +#### 8、退出ssh + +##### 8.1 scp -r dist的路径 主机名@域名或者IP地址 存放的路径地址 + +(例如我的就是:scp -r C:\Users\yat\Desktop\vitepress\docs.vitepress\dist [root@cyating.top](mailto:root@cyating.top):/var/www/www.cyating.top/) + +#### 9、再登入ssh + +##### 9.1 进入 cd /var/www + +##### 9.2创建目录:mkdir [www.cyating.top](https://gitee.com/link?target=http%3A%2F%2Fwww.cyating.top) + +##### 9.3 进入该目录 + +##### 9.4 cd /etc/nginx//conf.d/ ,打开nginx配置页面 + +##### 9.5 + +``` +server { + listen 80; + server_name www.cyating.top; //自己的域名 + + location / { + root /var/www/www.cyating.top/dist; //存放dist文件夹的路径 + try_files $uri $uri/ /index.html; + index index.html; + } + } +``` + +检查配置文件是否正确 + +#### 10.nginx -t + +服务重启 + +#### systemctl restart nginx Nginx \ No newline at end of file -- Gitee