蜂群信服
蜂群信服
发布于 2024-09-01 / 15 阅读
0

Cisco开启WEB/Telnet/SSH管理交换机命令示例:

命令解析:请按需修改。

(密码有复杂度需求的话,配10位大小写+符号)

enable //先进入特权模式
conf t //再进入配置模式才能配置


vlan 254 //创建管理vlan254(管理vlan为自已定义,没规定的)

interface vlan 254 //进入管理vlanif接口254(vlanif接口才能配IP地址的)
ip address 192.168.254.1 255.255.255.0 //配置管理IP地址和掩码为 192.168.254.1 255.255.255.0(用来远程登陆的IP地址)
no shutdown //有些版本默认关闭,所以要no shutdown开启接口
exit //返回上一层菜单

ip route 0.0.0.0 0.0.0.0 192.168.254.254 //配置默认路由 下一跳(管理IP的默认网关)为192.168.254.254这样才可以与其它网段通信

no ip domain lookup //关闭动态域名查询
ip domain-name cisco //IP动态域名为cisco

crypto key generate rsa //ssh管理,需要生成本地秘钥对rsa
y //确认
512 //加密长度为512


ip http server //开启http服务
ip http secure-server //开启https服务
ip http authentication local //http认证为本地认证

username test privilege 15 password Admin@1234 //创建用户名为test用户权限为15密码为Admin@1234

line vty 0 4 //进入vty 0 4端口(这些端口是用来远程管理的,是虚拟口)
login local //认证模式为本地认证
transport input all //允许所有协议
exit //返回上一层菜单

interface GigabitEthernet 1/0/1 //进入GigabitEthernet 1/0/1(接管理电脑的端口)
switchport mode access //端口链路类型为access
switchport access vlan 254 //端口加入管理vlan254(电脑与管理IP同一个网段,所以端口要加入管理vlan)
exit //返回上一层菜单

interface GigabitEthernet 1/0/2 //进入GigabitEthernet 1/0/2
switchport trunk encapsulation dot1q //有些版本要先封装dot1q 有些不需要,提示出错可以忽略,不会生效
switchport mode trunk //端口链路类型为trunk(接交换机的口一般为trunk)
switchport trunk allowed vlan all //端口允许所有vlan通过
exit //返回上一层菜单

脚本命令:使用前请先做好备份,以防万一。

enable

conf t

vlan 254

interface vlan 254

ip address 192.168.254.1 255.255.255.0

no shutdown

exit

ip route 0.0.0.0 0.0.0.0 192.168.254.254

no ip domain lookup

ip domain-name cisco

crypto key generate rsa

y

512

ip http server

ip http secure-server

ip http authentication local

username test privilege 15 password Admin@1234

line vty 0 4

login local

transport input all

exit

interface GigabitEthernet 1/0/1

switchport mode access

switchport access vlan 254

exit

interface GigabitEthernet 1/0/2

switchport trunk encapsulation dot1q

switchport mode trunk

switchport trunk allowed vlan all

exit