6cz2aqmw23 发表于 2016-6-6 10:16:08

华为交换、路由器常见命令

华为交换、路由器常见命令

交换机命令
~~~~~~~~~~
dis cur                                        ;显示当前配置
display current-configuration                  ;显示当前配置
display interfaces                           ;显示接口信息
display vlan all                               ;显示路由信息
display version                              ;显示版本信息
super password                                       ;修改特权用户密码
sysname                                       ;交换机命名
interface ethernet 0/1                               ;进入接口视图
interface vlan x                               ;进入接口视图
ip address 10.65.1.1 255.255.0.0   ;配置VLAN的IP地址
ip route-static 0.0.0.0 0.0.0.0 10.65.1.2            ;静态路由=网关
rip                                                ;三层交换支持
local-user ftp
user-interface vty 0 4                               ;进入虚拟终端
authentication-mode password               ;设置口令模式
set authentication-mode password simple 222;设置口令
user privilege level 3                     ;用户级别
interface ethernet 0/1                               ;进入端口模式
int e0/1                                             ;进入端口模式
duplex {half|full|auto}                  ;配置端口工作状态
speed {10|100|auto}                  ;配置端口工作速率
flow-control                        ;配置端口流控
mdi {across|auto|normal}               ;配置端口平接扭接
port link-type {trunk|access|hybrid}   ;设置端口工作模式
port access vlan 3                  ;当前端口加入到VLAN
port trunk permit vlan {ID|All}        ;设trunk允许的VLAN
port trunk pvid vlan 3        ;设置trunk端口的PVID
undo shutdown                     ;激活端口
shutdown                               ;关闭端口
quit                               ;返回
vlan 3                                       ;创建VLAN
port ethernet 0/1                 ;在VLAN中增加端口
port e0/1                                 ;简写方式
port ethernet 0/1 to ethernet 0/4         ;在VLAN中增加端口
port e0/1 to e0/4                         ;简写方式
monitor-port <interface_type interface_num>       ;指定镜像端口
port mirror <interface_type interface_num>         ;指定被镜像端口
port mirror int_list observing-port int_type int_num ;指定镜像和被镜像
description string                              ;指定VLAN描述字符
description                                   ;删除VLAN描述字符
display vlan                                ;查看VLAN设置
stp {enable|disable}                                 ;设置生成树,默认关闭
stp priority 4096                             ;设置交换机的优先级
stp root {primary|secondary}                    ;设置为根或根的备份
stp cost 200                        ;设置交换机端口的花费
link-aggregation e0/1 to e0/4 ingress|both         ; 端口的聚合
undo link-aggregation e0/1|all                     ;始端口为通道号
isolate-user-vlan enable                  ;设置主vlan
isolate-user-vlan <x> secondary <list>        ;设置主vlan包括的子vlan
port hybrid pvid vlan <id>        ;设置vlan的pvid
port hybrid pvid                    ;删除vlan的pvid
port hybrid vlan vlan_id_list untagged  ;设置无标识的vlan
如果包的vlan id与PVId一致,则去掉vlan信息. 默认PVID=1。
所以设置PVID为所属vlan id, 设置可以互通的vlan为untagged.
----------------------------------------
路由器命令
~~~~~~~~~~
display version                              ;显示版本信息
display current-configuration                  ;显示当前配置
display interfaces                           ;显示接口信息
display ip route                               ;显示路由信息
sysname aabbcc                                 ;更改主机名
super passwrod 123456                        ;设置口令
interface serial0                              ;进入接口
ip address <ip> <mask|mask_len>      ;配置端口IP地址
undo shutdown                        ;激活端口
link-protocol hdlc                           ;绑定hdlc协议
user-interface vty 0 4
authentication-mode password
set authentication-mode password simple 222
user privilege level 3
quit
debugging hdlc all serial0                     ;显示所有信息
debugging hdlc event serial0                   ;调试事件信息
debugging hdlc packet serial0                  ;显示包的信息
静态路由:
ip route-static <ip><mask>{interface number|nexthop}
例如:
ip route-static 129.1.0.0 16 10.0.0.2
ip route-static 129.1.0.0 255.255.0.0 10.0.0.2
ip route-static 129.1.0.0 16 Serial 2
ip route-static 0.0.0.0 0.0.0.010.0.0.2
动态路由:
rip                                                ;设置动态路由
rip work                                             ;设置工作允许
rip input                                          ;设置入口允许
rip output                                           ;设置出口允许
network 1.0.0.0                           ;设置交换路由网络
network all                                    ;设置与所有网络交换
peer ip-address                                  ;
summary                                          ;路由聚合
rip version 1                                        ;设置工作在版本1
rip version 2 multicast                              ;设版本2,多播方式
rip split-horizon                        ;水平分隔
router id A.B.C.D                                    ;配置路由器的ID
ospf enable                                          ;启动OSPF协议
import-route direct                           ;引入直联路由
ospf enable area <area_id>                   ;配置OSPF区域
标准访问列表命令格式如下:
acl <acl-number>                   ;默认前者顺序匹配。
rule {permit|deny}
例:
acl 10
rule normal permit source 10.0.0.0 0.0.0.255
rule normal deny source any
扩展访问控制列表配置命令
配置TCP/UDP协议的扩展访问列表:
rule {normal|special}{permit|deny}{tcp|udp}source {<ip wild>|any}destination <ip wild>|any}

配置ICMP协议的扩展访问列表:
rule {normal|special}{permit|deny}icmp source {<ip wild>|any]destination {<ip wild>|any]

扩展访问控制列表操作符的含义
equal portnumber                                        ;等于
greater-than portnumber                                        ;大于
less-than portnumber                                        ;小于
not-equal portnumber                                        ;不等
range portnumber1 portnumber2                                  ;区间
扩展访问控制列表举例
acl 101
rule deny souce any destination any
rule permit icmp source any destination any icmp-type echo
rule permit icmp source any destination any icmp-type echo-reply
acl 102
rule permit ip source 10.0.0.1 0.0.0.0 destination 202.0.0.1 0.0.0.0
rule deny ip source any destination any
acl 103
rule permit tcp source any destination 10.0.0.1 0.0.0.0 destination-port equal ftp
rule permit tcp source any destination 10.0.0.2 0.0.0.0 destination-port equal www

firewall enable
firewall default permit|deny
int e0
firewall packet-filter 101 inbound|outbound

地址转换配置举例
firewall enable
firewall default permit
acl 101                           ;内部指定主机可以进入e0
rule deny ip source any destination any
rule permit ip source 129.38.1.1 0 destination any
rule permit ip source 129.38.1.2 0 destination any
rule permit ip source 129.38.1.3 0 destination any
rule permit ip source 129.38.1.4 0 destination any
quit
int e0
firewall packet-filter 101 inbound
acl 102                           ;外部特定主机和大于1024端口的数据包允许进入S0
rule deny ip source any destination any
rule permit tcp source 202.39.2.3 0 destination 202.38.160.1 0
rule permit tcp source any destination 202.38.160.1 0 destination-port great-than
1024
quit
int s0
firewall packet-filter 102 inbound      ;设202.38.160.1是路由器出口IP。
nat outbound 101 interface   ;是Easy ip,将acl 101允许的IP从本接口出时变换源地址。
内部服务器地址转换配置命令(静态nat):
nat server global <ip> inside <ip> port        ;global_port不写时使用inside_port
nat server global 202.38.160.1 inside 129.38.1.1 ftp tcp
nat server global 202.38.160.1 inside 129.38.1.2 telnet tcp
nat server global 202.38.160.1 inside 129.38.1.3 www tcp

设有公网IP:202.38.160.101~202.38.160.103 可以使用。             ;对外访问(原例题)
nat address-group 202.38.160.101 202.38.160.103 pool1   ;建立地址池
acl 1
rule permit source 10.110.10.0 0.0.0.255          ;指定允许的内部网络
rule deny source any
int serial 0
nat outbound 1 address-group pool1            ;在s0口从地址池取出IP对外访问
nat server global 202.38.160.101 inside 10.110.10.1 ftp tcp
nat server global 202.38.160.102 inside 10.110.10.2 www tcp
nat server global 202.38.160.102 8080 inside 10.110.10.3 www tcp
nat server global 202.38.160.103 inside 10.110.10.4 smtp udp
PPP设置:
link-protocol ppp                                  ;默认的协议
PPP验证:
主验方:pap|chap
local-user q2 password {simple|cipher} hello          ;路由器1
interface serial 0
ppp authentication-mode {pap|chap}
ppp chap user q1                              ;pap时,没有此句
pap被验方:
interface serial 0                                    ;路由器2
ppp pap local-user q2 password {simple|cipher} hello
chap被验方:
interface serial 0                                    ;路由器2
ppp chap user q2                              ;自己路由器名
local-user q1 password {simple|cipher} hello;对方路由器名
帧中继frame-relay    (二分册6-61)
fr switching
int s1
ip address 192.168.34.51 255.255.255.0
link-protocol fr                                 ;封装帧中继协议
fr interface-type dce
fr dlci 100
fr inarp
fr map ip 192.168.34.52 dlci 100
int s1
ip address 192.168.34.52 255.255.255.0
link-protocol fr
fr interface-type dte
fr dlci 100
fr inarp
fr map ip 192.168.34.51 dlci 100
帧中继监测
display fr lmi-info[]interface type number]
display fr map
display fr pvc-info
display fr dlci-switch
display fr interface
reset fr inarp-info
debugging fr all
debugging fr arp
debugging fr event
debugging fr lmi

启动ftp服务:
local-user ftp password {simple|cipher} aaa service-type ftp
ftp server enable
路由器基本配置命令举例
sysname router_name 命名路由器(或交换机)
delete 删除Flash ROM中的配置
save 将配置写入Flash ROM
interface serial 0 进入接口配置模式
quit 退出接口模式到系统视图
shutdown/undo shutdown 关闭/重启接口
ip address ip_address subnet_mask 为接口配置IP地址和子网掩码
display version 显示VRP版本号
display current-configuration 显示系统运行配置信息
display interfaces 显示接口配置信息
display ip routing 显示路由表
ping ip_address 测试网络连通性
tracert ip_address 测试数据包从主机到目的地所经过的网关
debug all 打开所有调试信息
undo debug all 关闭所有调试信息
info-center enable 开启调试信息输出功能
info-center console dubugging 将调试信息输出到PC
info-center monitor dubugging 将调试信息输出到Telnet终端或哑终端





换机配置命令举例(大括号{}中的选项为单选项,斜体字部分为参数值



super password password 修改特权模式口令
sysname switch_name 命名交换机(或路
interface ethernet 0/1 进入接口视图
quit 退出系统视图
duplex {half|full|auto} 配置接口双工工
speed {10|100|auto} 配置接口速率
flow-control 开启流控制
mdi {across|normal|auto} 配置MDI/MDIX
shutdown/undo shutdown 关闭/重启端口





VLAN基本配置命令(以Quidway S3026为例) vlan 3 创建并进入VLAN配置模式,缺省时系统将
所有端口加入VLAN 1,这个端口既不能被创建也不能被删除。
undo vlan 3 删除一个VLAN
port ethernet 0/1 to ethernet 0/4 给VLAN增加/删除以太网接口
port access vlan 3 将本接口加入到指定VLAN id port link-type {access|trunk|hybrid} 设置端口工作方式,access(缺省)不支持802.1q帧的传送,而trunk支持(用于Switch间互连),hybrid和trunk的区别在于trunk
只允许缺省VLAN的报文发送时不打标签,而hybrid允许多个VLAN报文发送时不打标签。




端口聚合配置命令
link-aggregation ethernet 0/7 to ethernet 0/10 {ingress|both} 配置端口聚合
Port_num1为端口聚合组的起始端口号,Port_num2为终止端口号
ingress为接口入负荷分担方式,both为接口出负荷分担方式。




STP基本配置命令
stp {enable|disable} 开启/关闭 STP 功能,默认关闭,开启后所有端口都参与STP 计算。
stp disable 关闭指定接口上的STP功能,如某些网络不存在环路可以关闭STP。




PPP配置命令
link-protocol ppp 封装PPP协议
ppp authentication-mode {pap|chap} 设置验证类型
local-user username password {simple|cipher} password 配置用户列表
- PAP验证配置:
主验证方
local-user username password {simple|cipher} password 配置用户列表
ppp authentication-mode pap
被验证方
ppp pap local-user username password {simple|cipher} password
- CHAP验证配置:
主验证方
local-user username password {simple|cipher} password 配置被验证方用户列表
ppp chap host hostname 配置本地名称
ppp authentication-mode chap
被验证方
local-user username password {simple|cipher} password 配置主验证方用户列表
ppp chap user username 配置本地名称




MP配置命令
ppp mp 封装MP协议
ppp mp user username bind virtual-template number 建立用户与虚拟模板的对应关系
interface virtual-template number 配置虚拟接口模板
ppp mp max-bind number 设置虚拟模板最大绑定数(1-100)




帧中继配置命令
link-protocol fr {mfr|ietf|nonstandard} 封装帧中继协议:IETF、Cisco兼容
fr interface-type {dte|dce|nni} 配置帧中继接口类型,NNI为帧中继交换机之间的接口。若配为DCE或NNI,则须先使能fr switching。
fr lmi type {q933a|ansi|cisco-compatible} 配置LMI协议类型
fr dlci dlci_number 配置一条本地虚电路号
fr map {ip|ipx} protocol-address dlci dlci_number 建立本地DLCI到对端协议地址的映射
fr inarp 配置Inverse ARP动态映射
interface type number.subinterface_number 创建并进入子接口配置模式










RIP协议配置命令
display rip 显示RIP配置信息
rip 启动并进入RIP配置模式
network {network_number|all} 在指定网络上使能RIP
peer ip_address 配置报文的定点传送
rip version {1|2 } 指定RIP版本及传送方式
rip work 指定接口工作状态(同rip input,rip output)
auto-summary 配置RIP-2路由聚合
rip authentication simple password 配置RIP-2明文认证密码
rip authentication md5 key-string string 配置RIP-2 MD5密文认证密码串
rip authentication md5 type {nonstandard-compatible|usual} 指定MD5类型
debugging rip packet 打开RIP调试开关
info-center console 将调试信息输出到PC




静态路由配置命令
ip route ip_address subnet_mask {interface_name|gateway_address}
[命令说明] reject:任何去往该目的地的报文均被丢弃,通知源主机不可达。
black_bone:任何去往该目的地的报文均被丢弃,不通知源主机。
当只有下一跳的接口是PPP或HDLC接口才能写interface_name,如Serial0,否则只能写gateway_address(下一跳地址)。
[命令举例] ip route 129.1.0.0 16 10.0.0.2
ip route 129.1.0.0 255.255.0.0 10.0.0.2
ip route 129.1.0.0 16 Serial2
ip route 0.0.0.0 0.0.0.0 10.0.0.2 配置缺省路由。






OSPF配置命令
router id ip_address 配置Router ID
ospf enable 启用OSPF协议
ospf enable area area_id 配置当前接口所属的OSPF区域
页: [1]
查看完整版本: 华为交换、路由器常见命令