华为交换机命令

时间:2024-02-29 13:25:12

 

[switcha-GigabitEthernet0/0/16]display interface
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Description:
Switch Port, PVID : 1, TPID : 8100(Hex), The Maximum Frame Length is 9216
IP Sending Frames\' Format is PKTFMT_ETHNT_2, Hardware address is 4c1f-cceb-7b23
Last physical up time : 2016-10-11 20:02:39 UTC-08:00
Last physical down time : 2016-10-11 19:57:40 UTC-08:00
Current system time: 2016-10-11 21:44:36-08:00
Hardware address is 4c1f-cceb-7b23
Last 300 seconds input rate 0 bytes/sec, 0 packets/sec
Last 300 seconds output rate 0 bytes/sec, 0 packets/sec
Input: 331415 bytes, 2785 packets
Output: 238 bytes, 2 packets
Input:
Unicast: 0 packets, Multicast: 2785 packets
Broadcast: 0 packets
Output:
Unicast: 0 packets, Multicast: 2 packets
Broadcast: 0 packets
Input bandwidth utilization : 0%
Output bandwidth utilization : 0%

 

 

 

[switcha]disp vlan
The total number of vlans is : 4
--------------------------------------------------------------------------------
U: Up; D: Down; TG: Tagged; UT: Untagged;
MP: Vlan-mapping; ST: Vlan-stacking;
#: ProtocolTransparent-vlan; *: Management-vlan;
--------------------------------------------------------------------------------

VID Type Ports
--------------------------------------------------------------------------------
1 common UT:GE0/0/1(U) GE0/0/2(D) GE0/0/3(D) GE0/0/4(D)
GE0/0/5(D) GE0/0/6(D) GE0/0/7(D) GE0/0/8(D)
GE0/0/9(D) GE0/0/10(D) GE0/0/11(D) GE0/0/12(D)
GE0/0/13(D) GE0/0/14(D) GE0/0/15(D) GE0/0/16(D)
GE0/0/17(D) GE0/0/18(D) GE0/0/19(D) GE0/0/20(D)
GE0/0/21(D) GE0/0/22(D) GE0/0/23(D) GE0/0/24(D)

2 common
3 common
100 common

VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------

1 enable default enable disable VLAN 0001
2 enable default enable disable VLAN 0002
3 enable default enable disable VLAN 0003
100 enable default enable disable VLAN 0100

 

 

 


[switcha]display version

Huawei Versatile Routing Platform Software
VRP (R) software, Version 5.110 (S5700 V200R001C00)
Copyright (c) 2000-2011 HUAWEI TECH CO., LTD

Quidway S5700-28C-HI Routing Switch uptime is 0 week, 0 day, 1 hour, 22 minutes

 

 


[switcha]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 2 Routes : 2

Destination/Mask Proto Pre Cost Flags NextHop Interface

127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0

 

 


[switcha]display current-configuration
#
sysname switcha
#
vlan batch 2 to 3 100
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
diffserv domain default
#
drop-profile default
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password simple admin
local-user admin service-type http
#
interface Vlanif1
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
#
interface GigabitEthernet0/0/3
#
interface GigabitEthernet0/0/4
#
interface GigabitEthernet0/0/5
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
#
interface GigabitEthernet0/0/24
#
interface NULL0
#
user-interface con 0
user-interface vty 0 4
#
return

[switcha]display saved-configuration

华为交换机基本配置命令
来源:弱电工程处 作者:布线专员 发布时间:2010-12-15
华为交换机基本配置命令

一、单交换机VLAN划分

命令 命令解释

system 进入系统视图

system-view 进入系统视图

quit 退到系统视图

undo vlan 20 删除vlan 20

sysname 交换机命名

disp vlan 显示vlan

vlan 20 创建vlan(也可进入vlan 20)

port e1/0/1 to e1/0/5 把端口1-5放入VLAN 20 中

disp vlan 20 显示vlan里的端口20

int e1/0/24 进入端口24

port access vlan 20 把当前端口放入vlan 20

undo port e1/0/10 表示删除当前VLAN端口10

disp curr 显示当前配置

二、配置交换机支持TELNET

system 进入系统视图

sysname 交换机命名

int vlan 1 进入VLAN 1

ip address 192.168.3.100 255.255.255.0 配置IP地址

user-int vty 0 4 进入虚拟终端

authentication-mode password (aut password) 设置口令模式

set authentication password simple 222 (set aut pass sim 222) 设置口令

user privilege level 3(use priv lev 3) 配置用户级别

disp current-configuration (disp cur) 查看当前配置

disp ip int 查看交换机VLAN IP配置

删除配置必须退到用户模式

reset saved-configuration(reset saved) 删除配置

reboot 重启交换机

三、跨交换机VLAN的通讯

在sw1上:

vlan 10 建立VLAN 10

int e1/0/5 进入端口5

port access vlan 10 把端口5加入vlan 10

vlan 20 建立VLAN 20

int e1/0/15 进入端口15

port access vlan 20 把端口15加入VLAN 20

int e1/0/24 进入端口24

port link-type trunk 把24端口设为TRUNK端口

port trunk permit vlan all 同上

在SW2上:

vlan 10 建立VLAN 10

int e1/0/20 进入端口20

port access vlan 10 把端口20放入VLAN 10

int e1/0/24 进入端口24

port link-type trunk 把24端口设为TRUNK端口

port trunk permit vlan all (port trunk permit vlan 10 只能为vlan 10使用)24端口为所有VLAN使用

disp int e1/0/24 查看端口24是否为TRUNK

undo port trunk permit vlan all 删除该句

四、路由的配置命令

system 进入系统模式

sysname 命名

int e1/0 进入端口

ip address 192.168.3.100 255.255.255.0 设置IP

undo shutdown 打开端口

disp ip int e1/0 查看IP接口情况

disp ip int brief 查看IP接口情况

user-int vty 0 4 进入口令模式

authentication-mode password(auth pass) 进入口令模式

set authentication password simple 222 37 设置口令

user privilege level 3 进入3级特权

save 保存配置

reset saved-configuration 删除配置(用户模式下运行)

undo shutdown 配置远程登陆密码

int e1/4

ip route 192.168.3.0(目标网段) 255.255.255.0 192.168.12.1(下一跳:下一路由器的接口) 静态路由

ip route 0.0.0.0 0.0.0.0 192.168.12.1 默认路由

disp ip rout 显示路由列表

华3C AR-18

E1/0(lan1-lan4)

E2/0(wan0)

E3/0(WAN1)

路由器连接使用直通线。wan0接wan0或wan1接wan1

计算机的网关应设为路由器的接口地址。

五、三层交换机配置VLAN-VLAN通讯

sw1(三层交换机):

system 进入视图

sysname 命名

vlan 10 建立VLAN 10

vlan 20 建立VLAN 20

int e1/0/20 进入端口20

port access vlan 10 把端口20放入VLAN 10

int e1/0/24 进入24端口

port link-type trunk 把24端口设为TRUNK端口

port trunk permit vlan all (port trunk permit vlan 10 只能为vlan 10使用)24端口为所有VLAN使用

sw2:

vlan 10

int e1/0/5

port access vlan 10

int e1/0/24

port link-type trunk 把24端口设为TRUNK端口

port trunk permit vlan all (port trunk permit vlan 10 只能为vlan 10使用)24端口为所有VLAN使用

sw1(三层交换机):

int vlan 10 创建虚拟接口VLAN 10

ip address 192.168.10.254 255.255.255.0 设置虚拟接口VLAN 10的地址

int vlan 20 创建虚拟接口VLAN 20

ip address 192.168.20.254 255.255.255.0 设置虚拟接口IP VLAN 20的地址

注意:vlan 10里的计算机的网关设为 192.168.10.254

vlan 20里的计算机的网关设为 192.168.20.254

六、动态路由RIP

R1:

int e1/0 进入e1/0端口

ip address 192.168.3.1 255.255.255.0 设置IP

int e2/0 进入e2/0端口

ip adress 192.168.5.1 255.255.255.0 设置IP

rip 设置动态路由

network 192.168.5.0 定义IP

network 192.168.3.0 定义IP

disp ip rout 查看路由接口

R2:

int e1/0 进入e1/0端口

ip address 192.168.4.1 255.255.255.0 设置IP

int e2/0 进入e2/0端口

ip adress 192.168.5.2 255.255.255.0 设置IP

rip 设置动态路由

network 192.168.5.0 定义IP

network 192.168.4.0 定义IP

disp ip rout 查看路由接口

(注意:两台PC机的网关设置PC1 IP:192.168.3.1 PC2 IP:192.168.4.1)

七、IP访问列表

int e1/0

ip address 192.168.3.1 255.255.255.0

int e2/0

ip address 192.168.1.1 255.255.255.0

int e3/0

ip address 192.168.2.1 255.255.255.0

acl number 2001 (2001-2999属于基本的访问列表)

rule 1 deny source 192.168.1.0 0.0.0.255 (拒绝地址192.168.1.0网段的数据通过)

rule 2 permit source 192.168.3.0 0.0.0.255(允许地址192.168.3.0网段的数据通过)

以下是把访问控制列表在接口下应用:

firewall enable

firewall default permit

int e3/0

firewall packet-filter 2001 outbound

disp acl 2001 显示信息

undo acl number 2001 删除2001控制列表

扩展访问控制列表

acl number 3001

rule deny tcp source 192.168.3.0 0.0.0.255 destination 192.168.2.0 0.0.0.255 destination-port eq ftp

必须在r-acl-adv-3001下才能执行

rule permit ip source an destination any (rule permit ip)

int e3/0

firewall enable 开启防火墙

firewall packet-filter 3001 inbound

必须在端口E3/0下才能执行

八、命令的标准访问IP列表(三层交换机):

允许A组机器访问服务器内资料,不允许访问B组机器(服务器没有限制)

sys

vlan 10

name server

vlan 20

name teacher

vlan 30

name student

int e1/0/5

port access vlan 10

int e1/0/10

port access vlan 20

int e1/0/15

port access vlan 30

int vlan 10

ip address 192.168.10.1 255.255.255.0

undo sh

int vlan 20

ip address 192.168.20.1 255.255.255.0

int vlan 30

ip address 192.168.30.1 255.255.255.0

acl number 2001

rule 1 deny source 192.168.30.0 0.0.0.255

rule 2 permit source any

disp acl 2001 查看2001列表

int e1/0/10

port access vlan 20

packet-filter outbound ip-group 2001 rule 1

出口

九、允许A机器访问B机器的FTP但不允许访问WWW,C机器没有任何限制。

vlan 10

vlan 20

vlan 30

int e1/0/5

port access vlan 10

int e1/0/10

port access vlan 20

int e1/0/15

port access vlan 30

int vlan 10

ip address 192.168.10.1 255.255.255.0

undo sh

int vlan 20

ip address 192.168.20.1 255.255.255.0

int vlan 30

ip address 192.168.30.1 255.255.255.0

acl number 3001

rule 1 deny tcp source 192.168.30.0 0.0.0.255 destination 192.168.10.0 0.0.0.255 destination-port eq www

int e1/0/15

packet-filter inbound ip-group 3001 rule 1

进口

十、NAT地址转换(单一静态一对一地址转换)

R1:

sys

sysname R1

int e1/0

ip address 192.168.3.1 255.255.255.0

int e2/0

ip address 192.1.1.1 255.255.255.0

R2:

sys

sysname R2

int e2/0

ip address 192.1.1.2 255.255.255.0

int e1/0

ip address 10.80.1.1 255.255.255.0

回到R1:

nat static 192.168.3.1 192.1.1.1

int e2/0

nat outbound static

ip route 0.0.0.0 0.0.0.0 192.1.1.2

十一、NAT内部整网段地址转换

R1:

sys

sysname R1

int e1/0

ip address 192.168.3.1 255.255.255.0

int e2/0

ip address 192.1.1.1 255.255.255.0

acl number 2008

rule 0 permit source 192.168.3.0 0.0.0.255

rule 1 deny

quit

int e2/0

nat outbound 2008

quit

ip route-static 0.0.0.0 0.0.0.0 192.1.1.2 preference 60

下一个路由接口地址

R2:

sys

sysname R2

int e2/0

ip address 192.1.1.2 255.255.255.0

int e1/0

ip address 10.80.1.1 255.255.255.0

NAT地址池配置:

R1:

sys

sysname R1

int e1/0

ip address 192.168.3.1 255.255.255.0

int e2/0

ip address 192.1.1.1 255.255.255.0

nat address-group 1 192.1.1.1 192.1.1.5 配置地址池

undo address-group 1 删除地址池

acl number 2001 创建访问列表

rule permit source 192.168.1.0 0.0.0.255

允许192.168.1.0/24网段地址转换(ethernet2/0指路由器wan口):

int e2/0

nat outbound 2001 address-group 1 启用协议

ip route 0.0.0.0 0.0.0.0 192.1.1.2 默认路由

R2:

sys

sysname R2

int e1/0

ip address 10.80.1.1 255.255.255.0

int e2/0

ip address 192.1.1.2 255.255.255.0

AR18-22-8配置命令

一、vlan配置

1、vlan划分方案

-------------------------------------------------- ------------------

| 部门 | vlan名 | ip地址 | 端口分配 |

-------------------------------------------------- ------------------

| J室 | vlan10 | 192.168.10.1/24 | ethernet 3/1 |

| K室 | vlan20 | 192.168.20.1/24 | ethernet 3/2 |

| C室 | vlan30 | 192.168.30.1/24 | ethernet 3/3 |

| Server | vlan40 | 192.168.0.1/24 | ethernet 3/{4,5,6} |

-------------------------------------------------- ------------------

2、显示vlan信息的命令

显示指定VLAN 的相关信息。display vlan vid

显示指定VLAN 配置的最大处理报文数目。display vlan max-packet-process vid

显式指定VLAN 的报文统计信息,包括接收和发送的报文数目。display vlan statistics vid vid

显示某个接口的VLAN 配置信息。display vlan interface interface-type interface-num

清除指定VLAN 的报文统计信息。reset vlan statistics vid vid

3、配置物理端口

配置路由器,进入Ethernet 端口视图,指定端口的链路类型,把端口加入到指定vlan中,注意access端口加入的vlan不能是vlan1。

# 配置Ethernet3/1

<H3C> system-view

H3C interface ethernet 3/1 进入端口1

H3C-Ethernet3/1 port link-type access 设置端口类型为access

H3C-Ethernet3/1 port access vlan 10 把该端口加到vlan10中

H3C-Ethernet3/1 quit

# 配置Ethernet3/2

H3C interface ethernet 3/2

H3C-Ethernet3/2 port link-type access

H3C-Ethernet3/2 port access vlan 20

H3C-Ethernet3/2 quit

# 配置Ethernet3/3

H3C interface ethernet 3/3

H3C-Ethernet3/3 port link-type access

H3C-Ethernet3/3 port access vlan 30

H3C-Ethernet3/3 quit

# 配置Ethernet3/4

H3C interface ethernet 3/4

H3C-Ethernet3/4 port link-type access

H3C-Ethernet3/4 port access vlan 40

H3C-Ethernet3/4 quit

# 配置Ethernet3/5

H3C interface ethernet 3/5

H3C-Ethernet3/5 port link-type access

H3C-Ethernet3/5 port access vlan 40

H3C-Ethernet3/5 quit

# 配置Ethernet3/6

H3C interface ethernet 3/6

H3C-Ethernet3/6 port link-type access

H3C-Ethernet3/6 port access vlan 40

H3C-Ethernet3/6 quit

4、配置虚拟端口

VLAN之间要实现互通,需要配置相应的以太网子接口,即VLAN 对应的路由接口,创建并进入相应的子接口视图,为其配置相应的封装协议和关联的VLAN ID,及IP 地址和掩码,ethernet 3/0 是三层虚拟端口。

# 配置Ethernet 3/0.1

H3C interface ethernet 3/0.1 创建并进入子接口

H3C-Ethernet3/0.1 vlan-type dot1q vid 10 设置以太网子接口的封装类型以及相关联的VLAN ID

H3C-Ethernet3/0.1 ip address 192.168.10.1 255.255.255.0

H3C-Ethernet3/0.1 quit

# 配置Ethernet 3/0.2

H3C interface ethernet 3/0.2

H3C-Ethernet3/0.2 vlan-type dot1q vid 20

H3C-Ethernet3/0.2 ip address 192.168.20.1 255.255.255.0

H3C-Ethernet3/0.2 quit

# 配置Ethernet 3/0.3

H3C interface ethernet 3/0.3

H3C-Ethernet3/0.3 vlan-type dot1q vid 30

H3C-Ethernet3/0.3 ip address 192.168.30.1 255.255.255.0

H3C-Ethernet3/0.3 quit

# 配置Ethernet 3/0.4

H3C interface ethernet 3/0.4

H3C-Ethernet3/0.4 vlan-type dot1q vid 40

H3C-Ethernet3/0.4 ip address 192.168.0.1 255.255.255.0

H3C-Ethernet3/0.4 quit

二、DHCP服务器配置

1、检测DHCP服务器

display dhcp server ip-in-use 查看地址池动态地址绑定信息

display dhcp server conflict 查看DHCP地址冲突的统计信息

display dhcp server statistics 查看DHCP服务器的统计信息

display dhcp servertree 查看DHCP地址池结构

2、具体配置

#公共配置(server和relay都适用)

<H3C> system-view 进入系统视图

H3C dhcp enable 使能DHCP服务

H3C dhcp server detect 使能伪DHCP服务器检测功能

#全局地址池配置

H3C dhcp select global interface ethernet 3/0.1 to ethernet 3/0.4 配置接口工作在DHCP Server模式,从全局地址池分配地址

H3C dhcp server ip-pool vlan10 创建全局地址池vlan10(最多支持128个全局地址池/路由器)

H3C-ip-pool network 192.168.10.0 mask 255.255.255.0 配置动态分配的IP地址范围(只可配置1个/地址池)

H3C-ip-pool expired day 7 hour 23 minute 59 配置租约

H3C-ip-pool domain-name pearl.cn 配置域名

H3C-ip-pool dns-list ip-address 192.168.0.6 202.106.0.20 202.106.196.115 配置DNS(最多8个/地址池)

H3C-ip-pool gateway-list ip-address 192.168.10.1 配置默认网关(最多8个/地址池)

H3C dhcp server forbidden-ip 192.168.10.1 192.168.10.10 配置保留IP地址范围(可配置多个/地址池)

H3C dhcp server relay information enable 使能DHCP Server支持option 82

#接口地址池配置

H3C dhcp select interface interface ethernet 3/0.1 to ethernet 3/0.4 (指虚拟接口还是指物理接口???)

配置多个接口工作在DHCP Server模式,从接口地址池分配地址,同时自动创建“接口地址池”

H3C dhcp server expired day 7 hour 23 minute 59 interface ethernet 3/0.1 to ethernet 3/0.4

H3C dhcp server domain-name pearl.cn interface ethernet 3/0.1 to ethernet 3/0.4

H3C dhcp server dns-list ip-address 192.168.0.6 202.106.0.20 202.106.196.115 interface ethernet 3/0.1 to ethernet 3/0.4

H3C interface ethernet 3/0.1

H3C-interface gateway-list ip-address 192.168.10.1

H3C dhcp server forbidden-ip 192.168.10.1 192.168.10.10 (是否接口模式下配??)

H3C dhcp server relay information enable

三、NAT配置

#配置地址池和访问控制列表:

H3C nat address-group 1 222.128.28.172 222.128.28.174

H3C acl number 2001

H3C-acl-basic-2001rule permit source 192.168.0.0 0.0.0.255

#允许192.168.0.0/24网段地址转换(ethernet3/0指路由器wan口):

H3C interface ethernet3/0

H3C-ethernet3/0 nat outbound 2001 address-group 1

#设置内部FTP服务器:

H3C-ethernet3/0 nat server protocol tcp global 222.128.28.171 inside 192.168.0.8 ftp

#设置内部www服务器1:

H3C-ethernet3/0 nat server protocol tcp global 222.128.28.171 inside 192.168.0.9 www

#设置内部www服务器2:

H3C-ethernet3/0 nat server protocol tcp global 222.128.28.171 8080 inside 192.168.0.10 www