华为路由交换机常用命令
常用系统命令display clock命令用来查看系统当前日期和时钟。
display diagnostic-information命令用来查看系统当前诊断信息。
display history-command命令用来查看当前终端上保存的历史命令。缺省情况下,显示最近10条历史命令。
display this命令用来查看系统当前视图的运行配置。
display version命令用来查看系统版本信息。
header命令用来设置用户登录设备时终端上显示的标题信息。
language-mode命令用来切换命令行接口的语言模式。缺省情况下,命令行接口的语言模式为英文模式。
quit命令用来从当前视图退回到较低级别视图,如果是用户视图,则退出系统。
return命令用来从除用户视图外的其它视图退回到用户视图。
sysname命令用来设置路由器的主机名。
system-view命令用来使用户从用户视图进入系统视图。
user-interface命令用来进入一个用户界面视图或多个用户界面视图。
user-interface maximum-vty命令用来设置登录用户的最大数目。
使用实例
# 配置VTY用户界面最大数目为7个。
1
2
<HUAWEI>system-view
user-interface maximum-vty 7
authentication-mode命令用来设置登录用户界面的验证方式。
# 使能本地密码验证。
1
2
3
<HUAWEI>system-view
user-interface vty 0
authentication-mode password
display user-interface命令用来查看用户界面信息。
idle-timeout命令用来设置用户界面断连的超时时间,即用户没有输入命令的时间。缺省情况下,用户界面断连的超时时间是10分钟。
使用实例
# 设置超时为1分钟30秒。
1
2
3
<HUAWEI>system-view
user-interface console 0
idle-timeout 1 30
display users命令用来查看每个用户界面的用户登录信息。
super命令用来使用户从当前级别切换到level级别。用户级别指登录用户的分类,共划分为16个级别,与命令级别对应,即不同级别的用户登录后,只能使用等于或低于自己级别的命令。
super password命令用来设置切换低级别用户到高级别用户的密码。
screen-length命令用来设置用户输入某一命令执行后终端屏幕每屏显示的行数。
screen-length temporary命令用来设置指定终端屏幕的临时显示行数。
dir命令用来显示路由器存储设备中的指定文件或目录的信息。
save命令用来保存当前配置信息到系统默认的存储路径中。
set save-configuration命令用来设置系统定时保存配置的功能。
compare configuration命令用来比较当前的配置与下次启动的配置文件内容是否一致。
display changed-configuration time命令用来查看最后一次配置变更的时间。
display current-configuration命令用来查看路由器当前生效的配置参数。
display saved-configuration命令用来查看路由器下次上电启动时所用的配置文件。
display startup命令用来查看与本次及下次启动相关的系统软件、配置文件名和PAF、License文件、补丁文件。
reset saved-configuration命令用来清除存储设备中路由器的启动配置文件。
check startup命令用来检查各种资源文件(PAF文件、License文件、补丁包、启动软件、配置文件)是否正确。
display cpu-usage命令用来查看CPU占用率的统计信息和配置信息。
display esn命令用来查看主用、备用主控板的设备序列号(Equipment Serial Number,ESN)。
display license命令用来查看License文件。
display license resource usage命令用来查看License文件中定义的资源项的使用情况。
reboot命令用来重启路由器。
startup license命令用来设置下次启动的License文件。
使用实例
# 设置下一次启动的License文件。
1
2
<HUAWEI>startup license cfcard:/license.txt
Info: Succeeded in setting main board resource file for system.
startup system-software命令用来配置系统下次启动时使用的系统软件文件名。
startup saved-configuration命令用来配置系统下次启动时使用的配置文件。
常用交换机命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
display current-configuration #显示当前配置
display interfaces #显示接口信息
display vlan all #显示vlan信息
display version #显示版本信息
super password #修改特权用户密码
interface ethernet 0/1 #进入接口视图
interface vlan x #进入vlanif接口视图
ip address 10.65.10.10 255.255.0.0 #配置VLAN的IP地址
ip route-static 0.0.0.0 0.0.0.0 10.65.10.254 #静态路由
local-user ftp
user-interface vty 0 4 #进入虚拟终端
authentication-mode password #设置口令模式
set authentication-mode password simple 888 #设置简单口令
user privilege level 3 #用户权限级别
duplex {half|full|auto} #配置端口工作状态
speed {10|100|auto} #配置端口工作速率
flow-control #配置端口流控
port link-type {trunk|access|hybrid} #设置端口工作模式
port access vlan 30 #当前端口加入到VLAN
port trunk permit vlan {ID|All} #设trunk允许的VLAN
port trunk pvid vlan 3 #设置trunk端口的PVID
vlan 3 #创建VLAN
port ethernet 0/1 #在VLAN中增加端口
port ethernet 0/1 to ethernet 0/4 #在VLAN中增加多个端口
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.
----------------------------------------
路由器命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
display version #显示版本信息
display current-configuration #显示当前配置
display interfaces #显示接口信息
display ip route #显示路由信息
sysname aabbcc #更改主机名
super passwrod 123456 #设置口令
interface serial0 #进入接口
ip address <ip> <mask|mask_len> #配置端口IP地址
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 #显示包的信息
静态路由
1
2
3
4
5
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
动态路由:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
配置RIP
rip #设置RIP动态路由
rip work #设置工作允许
rip input #设置入口允许
rip output #设置出口允许
network 1.0.0.0 #设置交换路由网络
network all #设置与所有网络交换
peer ip-address #设置邻居ip
summary #路由聚合
rip version 1 #设置工作在版本1
rip version 2 multicast #设版本2,多播方式
rip split-horizon #水平分隔
配置ospf
router id A.B.C.D #配置路由器的ID,同一个域内不能相同,一般使用loopback接口地址,稳定
ospf enable #启动OSPF协议
import-route direct #引入直联路由
ospf enable area <area_id> #配置OSPF区域
标准访问列表命令格式如下
acl <acl-number> ;默认前者顺序匹配。
rule {permit|deny}
例:
1
2
3
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 #区间扩展访问控制列表举例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
地址转换配置举例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
firewall enable
firewall default permit
acl 101
rule deny ip source any destination any
rule permit ip source 129.38.10.1 0 destination any
rule permit ip source 129.38.10.2 0 destination any
rule permit ip source 129.38.10.3 0 destination any
rule permit ip source 129.38.10.4 0 destination any
quit
int e0 #内部指定主机可以进入e0
firewall packet-filter 101 inbound
acl 102
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 #设202.38.160.1是路由器出口IP。#外部特定主机和大于1024端口的数据包允许进入S0
quit
int s0
firewall packet-filter 102 inbound
nat outbound 101 interface#是Easy ip,将acl 101允许的IP从本接口出时变换源地址。
内部服务器地址转换配置命令(静态nat):
1
2
3
4
nat server global <ip> inside <ip> port #global_port不写时使用inside_port
nat server global 202.38.160.1 inside 129.38.10.1 ftp tcp
nat server global 202.38.160.1 inside 129.38.10.2 telnet tcp
nat server global 202.38.160.1 inside 129.38.10.3 www tcp
设有公网IP:202.38.160.101~202.38.160.103 可以使用。 #对外访问nat
1
2
3
4
5
6
7
8
9
10
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
启动ftp服务:
1
2
local-user ftp password {simple|cipher} aaa service-type ftp
ftp server enable
66 很好
页:
[1]