神州数码交换机路由器命令汇总(最简输入版)解析
神州数码交换机路由器命令汇总(部分)
2016年3月23日星期三修改_________________________________________________________________________
注:本文档命令为最简命令,如不懂请在机器上实验
注:交换机版本信息:
DCRS-5650-28(R4) Device, Compiled on Aug 12 10:58:26 2013
sysLocation China
CPU Mac 00:03:0f:24:a2:a7
Vlan MAC 00:03:0f:24:a2:a6
SoftWare Version 7.0.3.1(B0043.0003)
BootRom Version 7.1.103
HardWare Version 2.0.1
CPLD Version N/A
Serial No.:1
Copyright (C) 2001-2013 by Digital China Networks Limited.
All rights reserved
Last reboot is warm reset.
Uptime is 0 weeks, 0 days, 1 hours, 42 minutes
路由器版本信息:
Digital China Networks Limited Internetwork Operating System Software
DCR-2659 Series Software, Version 1.3.3H (MIDDLE), RELEASE SOFTWARE
Copyright 2012 by Digital China Networks(BeiJing) Limited
Compiled: 2012-06-07 11:58:07 by system, Image text-base: 0x6004
ROM: System Bootstrap, Version 0.4.2
Serial num:8IRTJ610CA15000001, ID num:201404
System image file is "DCR-2659_1.3.3H.bin"
Digital China-DCR-2659 (PowerPC) Processor
65536K bytes of memory,16384K bytes of flash
Router uptime is 0:00:44:44, The current time: 2002-01-01 00:44:44
Slot 0: SCC Slot
Port 0: 10/100Mbps full-duplex Ethernet
Port 1: 2M full-duplex Serial
Port 2: 2M full-duplex Serial
Port 3: 1000Mbps full-duplex Ethernet
Port 4: 1000Mbps full-duplex Ethernet
Port 5: 1000Mbps full-duplex Ethernet
Port 6: 1000Mbps full-duplex Ethernet
一、交换机配置命令
1.基本配置
switch > en (enable )进入特权用户模式 switch # con (config) 进入全局配置模式
switch (config)# ho switch (hostname) 配置交换机名称 switch (config)# in e1/0/1 进入接口配置模式 switch (config -if -ethernet1/0/1)# ex
switch (config)# in vl 1 进入VLAN 配置模式
switch (config -if -vlan1)# ip ad 192.168.1.252 255.255.255.0 switch (config -if -vlan1)# ex
switch (config)# ena p 1234 配置交换机密码(不加密) switch (config)# ena p 7 1234 配置交换机密码(加密) switch (config)# vl 10 创建vlan switch (config -vlan10)#ex switch (config)# in vl 10
switch (config -if -vlan10)# ip ad 172.16.10.1 255.255.255.0 配置VLAN 地址
2.生成树技术
switch (config)# sp (spanning -tree) 启用全局生成树(默认mstp 生成树技术) switch (config)# sp mo stp/rstp /mstp (生成树/快速生成树/多生成树技术) switch (config)# sp ms 0 p 4096 设置交换机的优先级 默认32768 switch (config)# sh sp (show spanning -tree) 查看生成树
3.交换机Web 管理
switch (config)# ip ht ser
switch (config)# usern admin pa 1234 用户名和密码
4.交换机Telnet 管理
switch (config)# telnet -s e (telnet enable) 开启telnet 服务 switch (config)# usern admin pa 1234 用户名和密码
5.链路聚合(不需启动生成树)
switchA (config)# port -g 1 (prot -group) switchA (config)# in e1/0/1-2
switchA (config -port -range)# po 1 m on/active switchA (config -port -range)# ex switchA (config)# no port -g 1 删除组1
switchB (config)# port -g 2 switchB (config)# in e1/0/3-4
switchB (config -port -range)# po 2 m on/active switchB (config -port -range)# ex switchB (config)# no port -g 2 删除组2
6.交换机MAC 与IP 绑定
switch (config)# am e (am enable) 启用全局am 功能 switch (config)# in e1/0/1
switch (config_if_ethernet1/0/1)# am p (am port) 打开端口am 功能
switch (config_if_ethernet1/0/1)# am m (mac -ip -pool) 00-A0-D1-D1-07-FF 192.168.1.101 switch (config_if_ethernet1/0/1)# ex switch (config)# in e1/0/2
输入这条命令会出现: Invalid ENCRYPTED password! Please input the ENCRYPTED password with length 32 密码位数不够32位
switch (config_if_ethernet1/0/2)# no am p 解锁端口
7.交换机MAC与IP绑定
静态绑定
switch (config)# in e1/0/1
switch (config_if_ethernet1/0/1)# sw p (port-security) 开启绑定功能
switch (config_if_ethernet1/0/1)# sw p mac 00-a0-d1- d1-07-ff 添加静态MAC地址
switch (config_if_ethernet1/0/1)# sw p max 4 绑定MAC地址的个数(默认为1)
动态绑定
(实验中交换机没有动态绑定命令)
switch (config)# in e1/0/1
switch (config_if_ethernet1/0/1)# sw p (port-security) 开启绑定功能
switch (config_if_ethernet1/0/1)# sw port-security lock
switch (config_if_ethernet1/0/1)# sw port-security convert 将动态学习到绑定MAC的进行绑定
switch # sh port-s add 查看绑定的地址
8.交换机DHCP服务器配置
switch (config)# service dhcp 启用DHCP
switch (config)# ip dh po poolA定义地址池poolA
switch (dhcp-poolA- config)# netw (network-address) 192.168.1.0 24
switch (dhcp-poolA- config)# de (default-router) 192.168.1.254网关
switch (dhcp-poolA- config)# dn 60.191.244.5DNS服务器
switch (dhcp-poolA- config)# le 3租期3天
switch (dhcp-poolA- config)# ex
switch (config)# ip dh ex (excluded-add) 192.168.1.252 192.168.1.254 排除地址范围
9.保留地址(一个地址池中只能配一个IP-MAC的绑定)
switch (config)# ip dh po poolC
switch (dhcp-poolC- config)# ho 192.168.1.100 绑定的IP地址
switch (dhcp-poolC- config)# ha (hardware-add) 00-a0-d1- d1-07-ff 绑定的MAC地址
switch (dhcp-poolC- config)# de 192.168.1.254 网关
10.ACL访问控制列表
switchA (config)# ip ac s (standard) test命名标准IP访问列表
switchA (config-std-nacl-test)# d (deny) 192.168.100.0 0.0.0.255反子网掩码(路由器上为子网掩码)switchA (config-std-nacl-test)# d 192.168.200.0 0.0.0.255
switchA (config-std-nacl-test)# p (permit) a (permit any) 允许所有
switchA (config-std-nacl-test)# ex
switchA (config)# fir e (firewall enable) 开启ACL功能
switchA (config)# in e1/0/1
switchA (config-if-interface1/0/1)# ip ac (access-group) test in/out 进in出out (二层交换机上不支持out)11.配置时间范围
switchA (config)# time-r worktime
switchA (config-time-range)# p (periodic) weekd 9:0:0 to 18:0:0
12.VRRP虚拟路由器冗余协议
Master Backup
switchA (config)# router v 1 switchB (config_router)# router v 1
switchA (config_router)# v (virtual-ip) 192.168.1.254 switchB (config_router)# v 192.168.1.254 switchA (config_router)# i v 1 (interface vlan 1) switchB (config_router)# i v 1
switchA (config_router)# pri 110 switchB (config_router)# ena
switchA (config_router)# c (circuit-failover) v 10 20
switchA (config_router)# ena
13.DHCP中继
DHCP_relay (config)# service dhcp 全局开启DHCP服务
DHCP_relay (config)# ip fo u b (ip forward-protocol udp bootps) 全局开启转发
DHCP_relay (config)# in vl 10
DHCP_relay (config-if-vlan10)# ip h 172.16.1.1 转发到DHCP服务器地址
14.DHCP侦听
DHCP (config)# service dhcp
DHCP (config)# ip dh sn e 开启DHCP侦听功能
DHCP (config)# in e1/0/1
DHCP (config-if-ethernet1/0/1)# ip d s t (ip dhcp snooping trust)设置上联口为信任口
15.端口隔离
Switch (config)# is g test s i e1/0/1-2 (isolate-port group test switchport interface e1/0/1-2)
e1/0/1-2口不能互相通信,可以和其它端口通信。
16.端口镜像
Switch (config)# mo s1s i e1/0/1 both/rx/tx/access-l (monitor session 1 source interface e1/0/1) Switch (config)# mo s1d i e1/0/2 (monitor session 1 destination interface e1/0/2)
Source为被镜像的地址Destination为镜像到的地址both为全部流量rx为接收tx为发送
17.端口限速
Switch (config)# in e1/0/1
Switch (config-if-ethernet1/0/1)# ba c 10000 both/receive/transmit(bandwidth control)
18.ARP攻击防护
Switch (config)# in e1/0/1
Switch (config-if-ethernet1/0/1)# ar i192.168.1.254 (arp-guard ip) 绑定网关IP
Switch (config-if-ethernet1/0/1)# ex
Switch (config)# an e (anti-arpscan enable) 开启防ARP扫描
Switch (config)# an r e (anti-arpscan recovery enable) 开启自动恢复
Switch (config)# an r t 3600 (anti-arpscan recovery time) 设置自动恢复时间(单位:秒)
Switch (config)# in e1/0/1
Switch (config-if-ethernet1/0/1)# an t s (anti-arpscan trust supertrust-port) 设置上联口为超级信任端口19.QOS的PBR
Switch (config)# ip ac e route
Switch (config-ip-ext-nacl-route)# p ip 192.168.1.0 0.0.0.255 192.168.2.0 0.0.0.255
Switch (config-ip-ext-nacl-route)# ex
Switch (config)# cla map (class-map map)
Switch (config-classmap-map)# m a route (match access-group)
Switch (config-classmap-map)# ex
Switch (config)# pol map (policy-map)
Switch (config-policymap-map)# c map (class)
Switch (config-policymap-map-class-map)# se ip n 192.168.1.2 设置下一跳地址
Switch (config-policymap-map-class-map)# ex
Switch (config-policymap-map)# ex
Switch (config)# in e1/0/1
Switch (config-if-ethernet1/0/1)# ser input/output map 应用在接口下
20.清空交换机配置
Switch # set d (default)恢复出厂配置
Switch # wr (write)保存配置
Switch # rel (reload)重启交换机
_______________________________________________________________
二、路由器配置命令
1.基本配置
Router> ena 进入特权用户模式
Router# conf 进入全局配置模式
Router_config# in f0/0
Router_config_f0/0# ip ad 10.1.1.1 255.255.255.0配置路由器端口地址
2.路由器之间的连接
================================================================================默认HDLC封装
RA_config# in s0/2 (DCE/V35FC)
RA_config_s0/2# ip ad 192.168.1.1 255.255.255.0
RA_config_s0/2# ph sp 64000 (physical-layer speed) 配置端口速率(只在DCE端)
RB_config# in s0/1 (DTE/V35FC)
RB_config_s0/1# ip ad 192.168.1.2 255.255.255.0
================================================================================ PPP封装
RA_config# in s0/2 (DCE/V35FC)
RA_config_s0/2# ip ad 192.168.1.1 255.255.255.0
RA_config_s0/2# enc p PPP封装
RA_config_s0/2# ph sp 64000 配置端口速率(只在DCE端)
RB_config# in s0/1 (DTE/V35FC)
RB_config_s0/1# ip ad 192.168.1.2 255.255.255.0
RB_config_s0/1# enc p PPP封装
================================================================================ PPP封装CHAP认证
RA_config# u userb pa 123456 (username password)对方用户名和密码
RA_config# aa authe pp d local 本地认证
RA_config# in s0/2 (DCE/V35FC)
RA_config_s0/2# ip ad 192.168.1.1 255.255.255.0
RA_config_s0/2# enc p PPP封装
RA_config_s0/2# pp authe c CHAP认证
RA_config_s0/2# pp ch h usera 发送自己的用户名
RA_config_s0/2# pp ch p 123456 发送自己的密码
RA_config_s0/2# ph sp 64000 配置端口速率(只在DCE端)
RA发送的用户名和密码需与RB建立的用户名密码一致。
RB_config# u usera pa 123456 对方用户名和密码
RB_config# aa authe pp d local 本地认证
RB_config# in s0/1 (DTE/V35MT)
RB_config_s0/1# ip ad 192.168.1.2 255.255.255.0
RB_config_s0/1# enc p PPP封装
RB_config_s0/1# pp authe c CHAP认证
RB_config_s0/1# pp ch h userb 发送自己的用户名
RB_config_s0/1# pp ch p 123456 发送自己的密码
================================================================================ PPP封装PAP认证
配置方法同CHAP认证
RA_config_s0/2# enc p PPP封装
RA_config_s0/2# pp authe p PAP认证
RA_config_s0/2# pp pap s usera 123456 发送自己的用户名和密码
RB_config_s0/1# enc p
RB_config_s0/1# pp authe p
RB_config_s0/1# pp pap s userb 123456
================================================================================ 3.NAT地址转换
RouterA_config# ip ac s nat (ip access-list standard) 定义访问控制列表
RouterA_config_std_nacl# p 192.168.0.0 255.255.255.0 定义允许转换的地址范围
RouterA_config_std_nacl# ex
RouterA_config# ip n p poolA 192.168.1.10 192.168.1.20 255.255.255.0 定义转换地址池poolA RouterA_config# ip n i s l nat p poolA o (ip nat inside source list nat pool poolA overload)地址转换RouterA_config# in f0/0
RouterA_config_f0/0# ip n i 定义f0/0为内部接口
RouterA_config_f0/0# in s0/1
RouterA_config_s0/1# ip n o 定义s0/1为外部接口
4.静态路由
Router_config# ip route 10.1.2.0 (目标网段) 255.255.255.0(子网掩码)10.1.1.2 (转发地址)
Router_config# ip route 0.0.0.0 (目标网段) 0.0.0.0(子网掩码)10.1.1.2(转发地址)默认静态路由5.RIP动态路由
Router_config# router r 启用RIP路由
Router_config_rip# ve 2RIP路由版本号2
Router_config_rip# no a (auto-summary) 关闭路由自动汇总功能
Router_config_rip# net 10.1.1.0 255.255.255.0
Router_config_rip# net 10.1.2.0 255.255.255.0与路由器相连的网段
6.OSPF动态路由
Router_config# router o1启动ospf进程,进程号为1
Router_config_ospf_1# router- 1.1.1.1 (router-id) 设置路由器router-id
Router_config_ospf1# net 10.1.1.0 255.255.255.0 a 0网段、子网掩码和区域号
Router_config_ospf1# net 10.1.2.0 255.255.255.0 a 0第一个区域(即主干区域)区域号为0 Router_config_ospf1# [Ctrl+z] 退到特权模式快捷键Ctrl+Z
Router# sh ip ro 查看路由
7.ACL访问控制列表
标准访问控制列表
Router_config# ip ac s access
Router_config_std_nacl# den 192.168.1.0 255.255.255.0 (路由器为子网掩码)
Router_config_std_nacl# p a (permit any)
Router_config_std_nacl# ex
Router_config# in f0/0
Router_config_f0/0# ip ac access in/out应用在接口下
扩展访问控制列表
Router_config# ip ac e access
Router_config_std_nacl# den ip 192.168.1.0 255.255.255.0 192.168.2.0 255.255.255.0
Router_config_std_nacl# p ip a a (permit ip any any)
Router_config_std_nacl# ex
Router_config# in f0/0
Router_config_f0/0# ip ac access in/out应用在接口下
标准ACL绑定离目标近的接口,拓展ACL绑定离源地址近的接口。
关键字IP(包括ICMP、TCP和UDP)匹配任何Internet协议
TCP端口有ftp(21)、www(80)、login、telnet、smtp 、pop3 和pop2等
TCP端口有tftp、snmp、domain、syslog等
8.GRE隧道配置
RA配置
RA_config# in f0/0
RA_config_f0/0# ip ad 202.102.24.3 255.255.255.240
RA_config_f0/0# ex
RA_config# in t 1
RA_config_t1# ip ad 172.17.1.1 255.255.255.0
RA_config_t1# t so f0/0
RA_config_t1# t d 202.102.24.2
RB配置
RB_config# in f0/0
RB_config_f0/0# ip ad 202.102.24.2 255.255.255.240 RB_config_f0/0# ex
RB_config# in t 1
RB_config_t1# ip ad 172.17.1.2 255.255.255.0
RB_config_t1# t so f0/0
RB_config_t1# t d 202.102.24.3
RB_config_t1# ex
9.清空路由器配置
Router# del (delete)删除启动配置文件
Router# reb (reboot) 重启路由器
Router_config# date (显示)配置路由器日期和时间附件1:配置文件导入与导出
Ps:快捷键:Alt+F+L show run 之后再按一遍。