锐捷网络设备(交换机、路由器、防火墙)的常用命令整理。
一、基础命令
- 模式切换
enable # 进入特权模式configure terminal # 进入全局配置模式exit # 返回上一级模式end # 直接退出到特权模式
- 查看配置
show running-config # 查看当前运行配置show startup-config # 查看启动配置show version # 查看设备版本信息show interface [接口名] # 查看接口状态(如 GigabitEthernet 0/1)
- 保存配置
write # 保存配置到启动文件
二、交换机常用命令
1. VLAN 配置
vlan [VLAN ID] # 创建 VLAN
name [VLAN名称] # 为 VLAN 命名
interface vlan [VLAN ID] # 进入 VLAN 接口配置模式ip address [IP] [掩码] # 配置 VLAN 接口 IP(用于三层交换)
exit# 将端口加入 VLAN
interface [接口名] # 进入接口配置模式(如 GigabitEthernet 0/1)switchport mode access # 设置为接入模式switchport access vlan [VLAN ID] # 将端口加入指定 VLANswitchport mode trunk # 设置为 Trunk 模式switchport trunk allowed vlan [VLAN列表] # 允许 Trunk 通过的 VLAN(如 10,20)
2. 生成树协议(STP/MSTP)
spanning-tree mode mstp # 启用 MSTP 模式
spanning-tree mst configurationinstance 1 vlan 10,20 # 将 VLAN 映射到实例
exit
3. 端口聚合(LACP)
interface range [端口列表] # 选中多个端口(如 GigabitEthernet 0/1-2)channel-group [组号] mode active # 创建聚合组(LACP)
exit
interface port-channel [组号] # 进入聚合接口配置switchport mode trunk # 配置聚合接口为 Trunk
4. 端口安全
interface [接口名]port-security enable # 启用端口安全port-security max-mac-count [数量] # 限制最大 MAC 地址数
三、路由器常用命令
1. 接口 IP 配置
interface [接口名] # 进入接口配置(如 FastEthernet 0/0)ip address [IP] [掩码] # 配置接口 IPno shutdown # 启用接口
2. 静态路由
ip route [目标网络] [掩码] [下一跳IP/出接口] # 添加静态路由
3. 动态路由协议(OSPF)
router ospf [进程号] # 启用 OSPF 进程network [网络地址] [反掩码] area [区域号] # 宣告网络
4. NAT 配置
# 配置 NAT 地址池
ip nat pool [池名] [起始IP] [结束IP] netmask [掩码]# 配置 NAT 规则(PAT)
ip nat inside source list [ACL号] pool [池名] overload
interface [内网接口]ip nat inside
interface [外网接口]ip nat outside
四、防火墙常用命令
1. 安全区域(Zone)
zone [区域名] # 创建安全区域(如 trust、untrust)add interface [接口名] # 将接口加入区域
2. 安全策略
policy from [源区域] to [目标区域] # 创建策略action permit # 允许流量service [服务名] # 指定服务(如 HTTP、ICMP)exit
3. ACL 配置
ip access-list extended [ACL名称] # 创建扩展 ACLpermit ip [源IP] [目标IP] # 允许特定流量deny ip any any # 拒绝其他流量
4. VPN 配置(IPSec)
# 配置 IPSec 提议
ipsec proposal [提议名]esp encryption aes # 设置加密算法esp authentication sha1 # 设置认证算法
exit# 配置隧道接口
interface tunnel [编号]tunnel source [接口/IP] # 隧道源地址tunnel destination [IP] # 隧道目标地址
五、高级功能
1. QoS 配置
class-map [类名] # 定义流量分类match access-group [ACL号]
policy-map [策略名] # 定义 QoS 策略class [类名]bandwidth [百分比] # 分配带宽
interface [接口名]service-policy [策略名] # 应用策略到接口
2. SNMP 配置
snmp-server community [团体名] ro # 配置只读团体名
snmp-server host [IP] [团体名] # 指定 SNMP 管理服务器
3. 日志管理
logging host [IP] # 配置日志服务器
logging trap informational # 设置日志级别
六、故障排查
ping [IP] # 测试连通性
traceroute [IP] # 追踪路径
show arp # 查看 ARP 表
show mac-address-table # 查看 MAC 地址表(交换机)
show ip route # 查看路由表
show log # 查看日志