目录:
1.交换机的基本配置
一、交换机的基本配置
1.思科设备的命令行基础 2.会对交换机进行基础配置 3.会通过telnet和ssh对交换机进行远程管理一、思科设备命令行基础
1.想要进入设备的命令行揭秘那
- 设备支持命令行
-
- 取查看设备上的接口,看是否有console
- 需要有console线
- 需要超级终端软件进行连接
-
- putty
-
- secret CRT
-
- xshell
2.命令行基础
- xshell
- 思科设备上的命令行模式
-
- 用户模式:查看统计信息(一般用的很少)
-
-
- 用户模式 ==> 特权模式
-
enable
en #简写
-
- 特权模式:查看并修改设备的配置(一般以查看居多)
-
-
- 特权模式 ==> 全局模式
-
configure terminal
conf t #简写
-
- 全局模式:针对设备的整体配置参数
-
-
- 全局模式 ⇒ 接口模式
-
interface fasternet0/1
int f0/1 #简写
-
- 接口模式:针对设备的接口修改配置参数
模式 | 符号 | 向下命令 |
---|---|---|
用户模式 | “>” | en |
特权模式 | “#” | conf t |
全局模式 | “(config)#” | int f0/1 |
接口模式 | "(config-if)# " | 向上都是exit |
-
- 进入对应模式都只能一级一级进入
-
- 返回对应模式,一级一级返回使用"exit",快速返回特权模式,用"end".
连接时,pc连接RS 232,交换机连接console接口
-
- 命令输错后进入
Switch>dfds
Translating "dfds"...domain server (255.255.255.255) % Name lookup aborted
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#no ip domain-lookup #在全局模式禁止域名解析
3.常见配置
- 给交换机配置一个主机名
Switch(config)#hostname smile
- 交换机里维护了一张MAC地址表,怎么查看
show mac-address-table
- 交换机的双工模式
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/1
Switch(config-if)#duplex half
#查看结果
Switch#show int f0/1
FastEthernet0/1 is up, line protocol is up (connected)
...
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Half-duplex, 100Mb/s #这一行看出改成功了
....
- 交换机的接口速率
Switch#conf t
Switch(config)#int f0/2
Switch(config-if)#speed 10
Switch(config-if)#end
Switch#show int f0/2 #查看f0/2接口
Full-duplex, 10Mb/s #可见调整成10Mb/s
- 配置console口密码
Switch#conf t
Switch(config)#line console 0
Switch(config-line)#password 154302
Switch(config-line)#login
二、通过远程管理方式连接交换机(telnet ssh)
Telnet
1.telnet时应用层协议,基于传输层TCP,默认端口号:23,采用明文密码方式,不是很安全,一般用内网管理。
2.ssh是应用层协议,基于传输层TCP,默认端口号:22,采用密文密码方式,相对比较安全,经常用于跨越互联网管理,也常用于远程管理Linux操作系统
3.思路
- 既然通过网络的方式进行管理设备,设备就必须配置ip地址,由于交换机上的接口都是交换接口,是不允许配置ip地址,直接为交换机的虚拟接口配置ip地址,默认情况下交换机的默认虚接口就是 vlan1 端口
Switch(config)#int vlan 1
Switch(config-if)#ip address 192.168.100.100 255.255.255.0
Switch(config-if)#no shutdown
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
- 配置设备的连接终端并直接设置密码,应用
Switch#conf t
smile(config)#line vty 0 4 #虚拟终端0-4
smile(config-line)#password 123
smile(config-line)#login #应用
- 创建连接用户名密码,配置设备的连接终端并应用
smile(config)#username dragon password smile
smile(config)#line vty 0 4
smile(config-line)#login local
login表示直接使用密码登陆,login local代表使用用户密码登陆
4.设置特权模式的密码(全局模式下)
#上面的密码是远程连接的密码, 下面的这两个密码是给特权用户的密码
#同时设置 明文 和 密文 密码,密文密码生效
smile(config)#enable password 1234 #明文
smile(config)#enable secret 4567 #密文
smile#show running-config #查看当前配置文件命令
Ssh
- 创建密钥对并进行
######保留问题
smile#erase startup-config
reload
#无法清空交换机设置
Switch(config)#int vlan 1
Switch(config-if)#ip add 192.168.100.100 255.255.255.0
sw3(config-if)#no shutdown #修改完一定保存!!!
#设置SSH相关内容
Switch#show ip ssh
Switch(config)#hostname SW1
SW1(config)#ip domain-name woniu.com
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]
SW1(config)#ip ssh time-out 120 #超时时间
SW1(config)#ip ssh authentication-retries 5 #认证失败次数
SW1(config)#line vty 0 4
sw3(config)#username lisi password 5656
SW1(config)#line vty 0 4
SW1(config-line)#login local
sw3(config)#enable secret 567576