都支持| in<关键字> 的输出过滤方式。 用?查看当前帮助。 思科在配置模式下要执行命令时应使用do关键字。

业务高频

功能描述CiscoH3C
查看MAC地址表show mac address-tabledisplay mac-address
查看ARP表show arpdisplay arp
查看LLDP邻居show cdp neighbors detaildis lldp neighbor-information <interface g1/0/48> verbose
快速查看各端口信息(包括VLANIF)show ip interface briefdisplay interface brief
查看所有VLAN信息show vlandisplay vlan all
写入配置writesave
查看当前配置show rudis current-configuration
查看ACL配置show access-listsdis acl all
tftp备份配置/恢复配置
【首先备份】
copy running-config tftp: / copy tftp: running-config 后writetftp 192.168.2.2 put startup.cfg /tftp 192.168.2.2 get startup.cfg
查看文件列表dirdir

端口安全

  • Cisco
# 进入特权模式
Switch> enable 
#进入全局配置模式
Switch> configure terminal 
# 进入接口模式
Switch(config)# interface <interface-id> # 例如 FastEthernet0/1 或 GigabitEthernet0/1
# 端口安全通常要求在Access模式的端口上配置
Switch(config-if)# switchport mode access 
# 开启端口安全
Switch(config-if)# switchport port-security 
#设定该端口允许学习的最大MAC地址数 默认为1
Switch(config-if)# switchport port-security maximum <数量> 
#------------------------------------------------------------------------------------------------
# 【Option1】使用Sticky自动学习并绑定MAC地址:
Switch(config-if)# switchport port-security mac-address sticky
# 【Option2】手动绑定特定的MAC地址
Switch(config-if)# switchport port-security mac-address <MAC地址>   # 例如 0000.1111.2222
#------------------------------------------------------------------------------------------------
#设置违规处理模式 静默丢弃/带记录的丢弃/禁用端口 默认为shutdown
Switch(config-if)# switchport port-security violation { protect | restrict | shutdown } 
#------------------------------------------------------------------------------------------------
#回到全局配置模式 exit 后:
#若端口因违规被关闭(err-disable),可先shutdown再no shutdown该接口,或配置自动恢复
Switch(config)# errdisable recovery cause psecure-violation  
# 设置恢复检测间隔,例如300秒
Switch(config)# errdisable recovery interval <秒数>   
  • H3C
# 进入系统视图
<H3C> system-view  
# 进入指定接口视图
[H3C] interface GigabitEthernet 1/0/1  
[H3C-GigabitEthernet1/0/1] port-security enable  # 启用端口安全功能
#------------------------------------------------------------------------------------------------
# 【Option1】autoLearn(自动学习) 此模式允许端口自动学习MAC地址并将其转换为安全MAC地址(Sticky MAC)
[H3C-GigabitEthernet1/0/1] port-security max-mac-count 2  # 设置该端口最大学习MAC地址数量为2
[H3C-GigabitEthernet1/0/1] port-security port-mode autolearn # 当端口工作于autoLearn模式后,无法更改端口安全允许的最大MAC地址数。
# 【Option2】secure(静态绑定)
[H3C-GigabitEthernet1/0/1] port-security mac-address security 0001-0001-0002 vlan 10
[H3C-GigabitEthernet1/0/1] port-security port-mode secure

对于已经autoLearn到max-mac-count之后又要新增设备的情况: Can't add the security MAC address for the number of security MAC addresses on the interface has reached the maximum.

[H3C-GigabitEthernet1/0/1] dis this  # (在终端外备份当前port-security配置)
[H3C-GigabitEthernet1/0/1] undo port-security port-mode     # 先关闭autoLearn
[H3C-GigabitEthernet1/0/1] port-security max-mac-count 3    # 调整对应数量
[H3C-GigabitEthernet1/0/1] port-security port-mode autolearn # 再次启用autoLearn
[H3C-GigabitEthernet1/0/1] port-security mac-address security sticky 0000-8544-d326 vlan 10 # 绑定之前备份地址+新地址

通常记录表

功能分类功能描述CiscoH3C
基础操作进入特权模式/系统视图enablesystem-view
进入配置模式configure terminal-
显示当前运行配置show running-configdisplay current-configuration
显示已保存的启动配置show startup-configdisplay saved-configuration
保存配置copy running-config startup-configwritesave
显示系统版本信息show versiondisplay version
退出当前配置模式/返回上级视图exitquit
退回用户视图endreturn
设置设备主机名hostname <name>sysname <name>
重启设备reloadreboot
取消/关闭当前设置noundo
接口配置进入指定接口视图interface <interface-type> <number>interface <interface-type> <number>
开启接口(取消关闭)no shutdownundo shutdown
关闭接口shutdownshutdown
VLAN配置创建VLANvlan <vlan-id>vlan <vlan-id>
进入VLAN接口视图interface vlan <vlan-id>interface vlan <vlan-id>
配置端口为Access模式switchport mode accessport link-type access
将Access端口加入指定VLANswitchport access vlan <vlan-id>port access vlan <vlan-id>
配置端口为Trunk模式switchport mode trunkport link-type trunk
允许特定VLAN通过Trunk端口switchport trunk allowed vlan <vlan-list>port trunk permit vlan <vlan-list>
查看VLAN信息show vlandisplay vlan
路由配置查看路由表show ip routedisplay ip routing-table
配置静态路由ip route <network> <mask> <next-hop>ip route-static <network> <mask> <next-hop>
配置默认路由ip route 0.0.0.0 0.0.0.0 <next-hop>ip route-static 0.0.0.0 0.0.0.0 <next-hop>
启用OSPF路由进程router ospf <process-id>ospf <process-id>
宣告OSPF网络network <network> <wildcard-mask> area <area-id>area <area-id> network <network> <wildcard-mask>
其他常用查看接口状态与配置show interface [<interface-type> <number>]display interface [<interface-type> <number>]
查看ARP表show arpdisplay arp
持续pingping <ip-address> repeat <count>ping -c <count> <ip-address>
路径追踪traceroute <ip-address>tracert <ip-address>
查看日志信息show loggingdisplay logbuffer