diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-05.06\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\345\237\272\347\241\200.md" "b/05\346\237\257\346\230\200\345\220\253/2024-05.06\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\345\237\272\347\241\200.md" new file mode 100644 index 0000000000000000000000000000000000000000..d3a5536ffb815af6673a7e580584caf33dc89453 --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-05.06\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\345\237\272\347\241\200.md" @@ -0,0 +1,69 @@ +## 1.创建拓扑图 + +## 2.给两端设置好IP地址 + + - 1.Pc机可以直接设置 + + - 2.交换机因为是二层网络设备,要通过给默认的VLAN1这个接口设置ip(设置后,所有的接口都共享一个IP地址) + +```js +Switch(config)#interface vlan 1 // 进入vlan1接口 +Switch(config-if)#no shut // 开启这个接口 +%LINK-5-CHANGED: Interface Vlan1, changed state to up +%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up +Switch(config-if)#ip address 192.168.10.2 255.255.255.0 // 给vlan1配置ip地址,注意不要忘记子网掩码 +``` +## 3.修改主机名为默认名称以外的名称 +```js +Switch(config)#hostname SW03 // 修改主机名称为SW03 +SW03(config)# // 观察提示符已经改变了 +``` +## 4.给交接机设置域名 +```js +SW03(config)#ip domain-name mdd.com // ip domain-name 域名 +//SW03(config)#no ip domain-lookup 取消默认的域名解析功能,避免在特权模式下,输错命令导致卡死 + +// 以上两步得到一个完整的域名:SW03.qq.com +``` +## 5.创建RSA的KEYS +```js +SW03(config)#crypto key generate rsa // 以RSA算法生成KEY +The name for the keys will be: SW03.mdd.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 // 密钥长度,最大2048,越大越安全 +% Generating 2048 bit RSA keys, keys will be non-exportable...[OK] +``` +## 6.开启SSH的v2版本 +```js +SW03(config)#ip ssh version 2 // 以版本2开启SSH功能,前提已经做了3,4,5步 +SW03(config)#line vty 0 15 // 开启虚拟线路 (0-15),这里是开了所有,并进入线路模式 +SW03(config-line)#login local // 开启本地用户登录模式 +SW03(config-line)#transport input ssh // 允许SSH协议使用虚拟线路,允许的选项:all 允许所有,none 禁用所有 +SW03(config-line)#exit // 退出到全局模式 +SW03(config)#username admin password 123 // 创建本地用户admin并设置密码为123 +``` +## 7.默认情况下,特权密码是关闭了,且SSH又需要开启,所以在交换机要开启Enable的密码 +```js +// SW03(config)#enable password 666 以明文形式设置密码 +SW03(config)#enable secret 777 // 以密文形式设置密码 +SW03(config)#service password-encryption // 以全局加密的模式对所有密码加密 +``` +## 8.保存配置 +```js +SW03(config)#exit // 退到特权模式 +SW03# +%SYS-5-CONFIG_I: Configured from console by console +SW03#write memory // 保存设置,简写为w +Building configuration... +[OK] +``` +# 如何用PC机登录交换机的SSH +ssh [-l login_name] [-p port_number] [-i identity_file] remote_host 其中: + +remote_host:要连接的远程主机地址; -l:指定登录用户名,如果不指定,将使用本地登录用户名; -p:指定远程 SSH 服务器监听的端口号,默认为 22; -i:指定身份验证文件(公钥),用于身份验证,也可以通过密码进行身份验证。 +```js +C:\>ssh -l(不是1) admin 192.168.100.1 // 使用ssh 指定 用户为admin 登录 192.168.100.1 主机 +``` \ No newline at end of file diff --git "a/05\346\237\257\346\230\200\345\220\253/2024-05.07\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\345\237\272\347\241\200.md" "b/05\346\237\257\346\230\200\345\220\253/2024-05.07\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\345\237\272\347\241\200.md" new file mode 100644 index 0000000000000000000000000000000000000000..beb3c62bbff970a429116adac10ba8beadb054ad --- /dev/null +++ "b/05\346\237\257\346\230\200\345\220\253/2024-05.07\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\345\237\272\347\241\200.md" @@ -0,0 +1,60 @@ +## 交换机的生成树协议配置 + +- Switch0和Switch1配置 + +```js +Switch>en +Switch#show spanning-tree //査看交换机生成树运行状态 +Switch#show spanning-tree summary //査看生成树的配置信息 +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 range f0/23-24 +Switch(config-if)#switch mode trunk +Switch(config-if)#exit +Switch(config)#spanning-tree mode rapid-pvst //指定生成树协议的类型为RSTP +Switch(config)#end +Switch#show spanning-tree //判断根交换机、端口角色、端口状态等 +``` + +- 链路测试 + +```js +PC0(命令提示符CMD下) +ping 192.168.1.4 //链路通 +Switch0 +Switch>en +Switch#conf t +Switch(config)#inter f0/23 //关闭主链路上的端口 +Switch(config-if)#shutdown +PC0(命令提示符CMD下) +ping 192.168.1.4 //链路通 +//备份链路标记由×变为绿色,表明备份链路已启用 +``` + + +## 交换机的端口聚合配置 + +- Switch0和Switch1配置 +```js +Switch>en +Switch#conf t +Switch(config)#inter range f0/23-24 +Switch(config-if-range)#switch mode trunk //将端口配置为Trunk模式 +Switch(config-if-range)#channel-group 1 mode on //加入链路组1并开启 +Switch(config-if-range)#ex +Switch(config)#port-channel load-balance dst-ip //按目的IP地址来实现负载均衡 +Switch(config)#ex +Switch#show etherchannel summary //显示以太通道信息 +Switch#show interfaces etherchannel //显示聚合端口信息 +``` + +- PC0(命令提示符CMD下) +```js +ping 192.168.1.3 //链路通 +ping 192.168.1.4 //链路通 +``` \ No newline at end of file