都支持| in
<关键字> 的输出过滤方式。
用?
查看当前帮助。
思科在配置模式下要执行命令时应使用do
关键字。
业务高频
功能描述 | Cisco | H3C |
---|---|---|
查看MAC地址表 | show mac address-table | display mac-address |
查看ARP表 | show arp | display arp |
查看LLDP邻居 | show cdp neighbors detail | dis lldp neighbor-information <interface g1/0/48> verbose |
快速查看各端口信息(包括VLANIF) | show ip interface brief | display interface brief |
查看所有VLAN信息 | show vlan | display vlan all |
写入配置 | write | save |
查看当前配置 | show ru | dis current-configuration |
查看ACL配置 | show access-lists | dis acl all |
tftp备份配置/恢复配置 【首先备份】 | copy running-config tftp: / copy tftp: running-config 后write | tftp 192.168.2.2 put startup.cfg /tftp 192.168.2.2 get startup.cfg |
查看文件列表 | dir | dir |
端口安全
- 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 # 绑定之前备份地址+新地址
通常记录表
功能分类 | 功能描述 | Cisco | H3C |
---|---|---|---|
基础操作 | 进入特权模式/系统视图 | enable | system-view |
进入配置模式 | configure terminal | - | |
显示当前运行配置 | show running-config | display current-configuration | |
显示已保存的启动配置 | show startup-config | display saved-configuration | |
保存配置 | copy running-config startup-config 或 write | save | |
显示系统版本信息 | show version | display version | |
退出当前配置模式/返回上级视图 | exit | quit | |
退回用户视图 | end | return | |
设置设备主机名 | hostname <name> | sysname <name> | |
重启设备 | reload | reboot | |
取消/关闭当前设置 | no | undo | |
接口配置 | 进入指定接口视图 | interface <interface-type> <number> | interface <interface-type> <number> |
开启接口(取消关闭) | no shutdown | undo shutdown | |
关闭接口 | shutdown | shutdown | |
VLAN配置 | 创建VLAN | vlan <vlan-id> | vlan <vlan-id> |
进入VLAN接口视图 | interface vlan <vlan-id> | interface vlan <vlan-id> | |
配置端口为Access模式 | switchport mode access | port link-type access | |
将Access端口加入指定VLAN | switchport access vlan <vlan-id> | port access vlan <vlan-id> | |
配置端口为Trunk模式 | switchport mode trunk | port link-type trunk | |
允许特定VLAN通过Trunk端口 | switchport trunk allowed vlan <vlan-list> | port trunk permit vlan <vlan-list> | |
查看VLAN信息 | show vlan | display vlan | |
路由配置 | 查看路由表 | show ip route | display 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 arp | display arp | |
持续ping | ping <ip-address> repeat <count> | ping -c <count> <ip-address> | |
路径追踪 | traceroute <ip-address> | tracert <ip-address> | |
查看日志信息 | show logging | display logbuffer |