迈普交换机基础操作


一、配置本地用户认证

全局配置模式下
configure terminal
创建用户,配置用户名为test用户,密码为test,权限为15级
username test privilege 15 password 0 test
打开本地认证方式
authentication line vty login local
配置特权密码testpassword
enable password level 15 testpassword
配置示例:

1
2
3
4
5
Switch>enable    
Switch#configure terminal
Switch(config)#username test privilege 15 password 0 test
Switch(config)#authentication line vty login local
Switch(config)#enable password level 15 testpassword

二、配置VLAN

全局配置模式下,创建vlan 10
Vlan 10
添加描述信息
name Bangong
配置示例:
Switch(config)#vlan 10
Switch(config-vlan10)#name bangong
三、端口加入VLAN
配置access类型端口
全局模式下进入端口配置模式
进入G0/1
interface gigabitethernet0/1
配置端口类型为access
switchport mode access
配置端口所属vlan
switchport access vlan 10
打开端口(如果端口关闭)
no shutdown
配置示例:

1
2
3
4
5
6
7
8
Switch#configure terminal     
Switch(config)#interface gigabitethernet 0/1
Switch(config-if-gigabitethernet0/1)#switchport mode access
Switch(config-if-gigabitethernet0/1)#switchport access vlan 10
Switch(config-if-gigabitethernet0/1)#no shutdown
Switch(config-if-gigabitethernet0/1)#exit
Switch(config)#exit
Switch#

配置trunk类型端口(trunk类型端口适用于交换机接交换机)
全局模式下进入端口配置模式
进入G0/48
interface gigabitethernet0/48
配置端口模式为trunk模式
switchport mode trunk
配置端口允许通过的VLAN
switchport trunk allowed vlan all
配置默认的pvid,不配置的情况下默认pvid为1
switchport trunk pvid vlan 1
配置示例:

1
2
3
4
5
6
7
8
9
Switch#configure terminal     
Switch(config)#interface gigabitethernet 0/48
Switch(config-if-gigabitethernet0/48)#switchport mode trunk
Switch(config-if-gigabitethernet0/48)#switchport trunk allowed vlan all
Switch(config-if-gigabitethernet0/48)#switchport trunk pvid vlan 1
Switch(config-if-gigabitethernet0/48)#no shutdown
Switch(config-if-gigabitethernet0/48)#exit
Switch(config)#exit
Switch#

三、配置接口 VLAN IP

全局模式下进入vlanif接口配置模式
进入vlan10 三层接口
interface vlan 10
配置IP地址 192.168.1.1 掩码255.255.255.0
ip address 192.168.1.1 255.255.255.0
配置示例:

1
2
3
4
5
6
Switch#configure terminal     
Switch(config)#interface vlan 10
Switch(config-if-vlan10)#ip address 192.168.1.1 255.255.255.0
Switch(config-if-vlan10)#exit
Switch(config)#exit
Switch#

四、配置静态默认路由

全局配置模式下,配置默认路由的下一跳为192.168.1.2
ip route 0.0.0.0 0.0.0.0 192.168.1.2
静态路由配置和默认路由配置命令一样,命令中前0.0.0.0 代表网络号,后面一个0.0.0.0代表掩码。这8个0则能代表所有网段。代码一个24未掩码的网段表示:192.168.2.0 255.255.255.0
配置静态路由:
ip route 192.168.2.0 255.255.255.0 192.168.1.2
配置示例:
Switch(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2

五、配置生成树选项

生成树配置需要结合当地网络进行配置,要所有运行在一个拓扑能开启生成树功能的交换机,生成树配置一样。如果不知道在运行的生成树实例的情况下,建议暂时不配置生成树,避免生成树造成冲突。
全局模式下开启生成树功能
spanning-tree enable
全局模式下关闭生成树功能
no spanning-tree enable
配置生成树模式为mstp
spanning-tree mode mstp
进入多实例生成树MSTP配置
spanning-tree mst configuration
配置生成树域名test
region-name test
配置实例1包含vlan10
instance 1 vlan 10
配置实例2包含vlan20
instance 2 vlan 20
激活生成树配置
active configuration pending
不包含实例中的vlan,全部属于默认实例0,如vlan1默认属于实例0
配置示例:

1
2
3
4
5
6
7
8
9
10
Switch#configure terminal     
(config)#spanning-tree enable
Switch(config)#spanning-tree mode mstp
Switch(config)#spanning-tree mst configuration
Switch(config-mst)#region-name test
Switch(config-mst)#instance 1 vlan 10
Switch(config-mst)#instance 2 vlan 20
Switch(config-mst)#active configuration pending
Switch(config-mst)#exit
Switch(config)#

六、配置ACL访问控制策略

进入acl配置模式
ip access-list standard 100 #数字可配置1-1000,基础ACL配置,供电网络中采用基础acl#
配置一条允许23.50.0.99主机
10 permit host 23.50.6.99
配置一条允许23.50.6.0网段
20 permit 23.50.6.0 255.255.255.0
剩余的全部禁止
30 deny any
配置acl注意匹配规则是从上往下匹配,比如deny any已经拒绝了除10,20匹配到的,剩余的都是禁止。这时候40 permit 23.50.7.0 0.0.0.255,则该策略不生效,23.50.7.0网段还是被全部禁止。
配置示例:

1
2
3
4
Switch(config)#ip access-list standard 100    
Switch(config-std-nacl)#10 permit host 23.50.6.99
Switch(config-std-nacl)#20 permit 23.50.6.0 255.255.255.0
Switch(config-std-nacl)#30 deny any

七、配置SSH远程登陆

全局开启ssh服务
ip ssh server
进入配置交换机的vty接口模式下,下面相当于可以同时5个人登陆这台交换机
user-interface vty 0 4
配置远程登陆的认证模式为AAA,即为本地用户认证
login local
设置超时5分钟自动断开回话
exec-timeout 5 0
配置只允许ssh方式登陆交换机
Protocol input ssh
配置示例:

1
2
3
4
5
6
7
Switch(config)#line vty 0 4    
Switch(config-line)#login local
Switch(config-line)#exec-timeout 5 0
Switch(config-line)#protocol input ssh
Switch(config-line)#privilege level 0
Switch(config-line)#exit
Switch(config)#

八、配置时钟同步和时区

全局模式下配置时区为北京时区(加8小时)
clock timezone beijin 8
全局模式下配置时钟服务器10.109.192.5为第一个时钟服务器
ntp server 10.109.192.5
全局模式下配置时钟服务器10.109.192.43为备用时钟服务器
ntp server 10.109.192.43
配置示例:

1
2
3
4
Switch#configure terminal     
Switch(config)#clock timezone beijin 8
Switch(config)#ntp server 10.109.192.5
Switch(config)#ntp server 10.109.192.5

九、备份和还原IOS

特权配置模式下进入文件操作管理
filesystem
交换机用户模式下通过tftp备份iso固件到23.50.6.99服务器
格式:copy file-system 本地固件文件名 tftp 服务器IP 远程文件名
copy file-system web-Spl-1.1.235.rom tftp 23.50.6.99 123.rom
交换机用户模式下通过tftp服务器还原IOS到交换机中
格式:copy tftp 服务器IP 远程文件名file-system 本地固件文件名
copy tftp 23.50.6.99 234 file-system 234
使用dir命令,查看交换机固件的文件名称
配置示例:

1
2
3
4
Switch#filesystem     
Switch(config-fs)#dir
Switch(config-fs)#copy file-system sp4-g-6.6.4.1.18(C).pck tftp 23.50.6.99 123.pck
Switch(config-fs)#copy tftp 23.50.6.99 123.pck file-system sp4-g-6.6.4.1.18(C).pck

Tftp服务器可以下载软件3CDaemon在电脑上运行即可。

十一、交换机常规巡检命令

查看三层接口Ip地址
show ip interface brief
查看二层接口状态信息
show interface switchport brief
查看交换机的mac地址表
show mac-address all
查看交换机的arp表
show arp
查看交换机的生成树状态
show spanning-tree
查看交换机版本
show version
查看交换机系统时间
show clock
查看交换机电源状态
show power
查看交换机cpu使用状态
show cpu monitor
查看交换机内存使用状态
show memory

本文作者: 光明常在
发布时间: 2020-02-03
最后更新: 2020-02-03
本文标题: 迈普交换机基础操作
本文链接: http://mmdav0.coding-pages.com/2020/maipu/
版权声明: 本作品采用 CC BY-NC-SA 4.0 许可协议进行许可,转载请注明出处!
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×