设为首页 收藏本站
查看: 4541|回复: 4

[经验分享] 华为交换机命令行操作小结

  [复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-9-1 10:31:23 | 显示全部楼层 |阅读模式
                      华为交换机命令行操作小结
2016/8/30
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
一、基础
1、进入 system-view 模式
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]

2、更改交换机名称
[Huawei]sysname SW-ACC-CORE-1
[SW-ACC-CORE-1]

3、返回 user-view 模式
[SW-ACC-CORE-1]return
<SW-ACC-CORE-1>

4、查看配置
启动配置
<SW-ACC-CORE-1>display saved-configuration

当前配置
<SW-ACC-CORE-1>display current-configuration

5、保存配置
<SW-ACC-CORE-1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Aug 31 2016 09:50:33-08:00 SW-ACC-CORE-1 %%01CFM/4/SAVE(l)[0]:The user chose Y when
deciding whether to save the configuration to the device.
Now saving the current configuration to the slot 0.
Save the configuration successfully.
<SW-ACC-CORE-1>

6、用户和管理
1)配置密码
<SW-ACC-CORE-1>sys
[SW-ACC-CORE-1]aaa
[SW-ACC-CORE-1-aaa]local-user admin password cipher mypass
[SW-ACC-CORE-1-aaa]local-user admin privilege level 3
[SW-ACC-CORE-1-aaa]local-user admin service-type telnet terminal http
[SW-ACC-CORE-1-aaa]quit
[SW-ACC-CORE-1]user-interface vty 0 4
[SW-ACC-CORE-1-ui-vty0-4]authentication-mode aaa
[SW-ACC-CORE-1-ui-vty0-4]quit


测试:
<SW-ACC-BIZ-1>telnet 192.168.200.254
Trying 192.168.200.254 ...
Press CTRL+K to abort
Connected to 192.168.200.254 ...


Login authentication


Username:admin
Password:(输入:mypass)
Info: The max number of VTY users is 5, and the number
      of current VTY users on line is 1.
      The current login time is 2016-08-31 16:49:07.
<SW-ACC-CORE-1>


2)启用交换机的web服务
<SW-ACC-CORE-1>dir
找到web文件(以这个为例:s5700si-v200r003c00.001.web.7z),加载:
<SW-ACC-CORE-1>system-view
<SW-ACC-CORE-1>http server load s5700si-v200r003c00.001.web.7z
<SW-ACC-CORE-1>http secure-server enable
https://ip/

注:更改配置后,记得保存。


7、系统管理
1)版本
<SW-ACC-CORE-1>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, 0 hour, 15 minutes

2)时间
<SW-ACC-CORE-1>display clock
2016-08-31 16:56:31-08:00
Wednesday
Time Zone(China-Standard-Time) : UTC-08:00


二、VLAN
1、创建vlan
1)批量创建指定id的vlan
[SW-ACC-CORE-1]vlan batch 10 20 30 40

2)批量创建指定id范围的vlan
[SW-ACC-CORE-1]vlan batch 100 to 109


2、设置业务口的模式并加入vlan
[SW-ACC-CORE-1]interface GigabitEthernet 0/0/1
[SW-ACC-CORE-1-GigabitEthernet0/0/1]port link-type access
[SW-ACC-CORE-1-GigabitEthernet0/0/1]port default vlan 40
[SW-ACC-CORE-1-GigabitEthernet0/0/1]quit

如果想调整 link-type 为 trunk,怎么办?
[SW-ACC-CORE-1-GigabitEthernet0/0/1]port link-type trunk
Error: Please renew the default configurations.

此时应该这样操作:
因为端口已经加入了vlan,需要先undo:
[SW-ACC-CORE-1-GigabitEthernet0/0/1]undo port default vlan
[SW-ACC-CORE-1-GigabitEthernet0/0/1]port link-type trunk

运行多个vlan通过这个trunk链接:
[SW-ACC-CORE-1-GigabitEthernet0/0/1]port trunk allow-pass vlan 20 30



3、显示vlan
[SW-ACC-CORE-1-vlan20]display vlan
The total number of vlans is : 15
--------------------------------------------------------------------------------
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(U)      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)     

10   common  
20   common  TG:GE0/0/1(U)                                                      

30   common  TG:GE0/0/1(U)                                                      

40   common  
100  common  
101  common  
102  common  
103  common  
104  common  
105  common  
106  common  
107  common  
108  common  
109  common  

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

1    enable  default       enable  disable    VLAN 0001                        
10   enable  default       enable  disable    VLAN 0010                        
20   enable  default       enable  disable    VLAN 0020                        
30   enable  default       enable  disable    VLAN 0030                        
40   enable  default       enable  disable    VLAN 0040                        
100  enable  default       enable  disable    VLAN 0100                        
101  enable  default       enable  disable    VLAN 0101                        
102  enable  default       enable  disable    VLAN 0102                        
103  enable  default       enable  disable    VLAN 0103                        
104  enable  default       enable  disable    VLAN 0104                        
105  enable  default       enable  disable    VLAN 0105                        
106  enable  default       enable  disable    VLAN 0106                        
107  enable  default       enable  disable    VLAN 0107                        
108  enable  default       enable  disable    VLAN 0108                        
109  enable  default       enable  disable    VLAN 0109  


4、给指定vlan配置虚接口
[SW-ACC-CORE-1]interface Vlanif 20
[SW-ACC-CORE-1-Vlanif20]ip address 172.30.0.1 255.255.192.0
[SW-ACC-CORE-1-Vlanif20]quit
[SW-ACC-CORE-1]interface Vlanif 30
[SW-ACC-CORE-1-Vlanif30]ip address 172.30.64.1 255.255.192.0
[SW-ACC-CORE-1-Vlanif30]quit

同样的,可以给交换机配置管理IP(即vlan1):
[SW-ACC-CORE-1]interface Vlanif 1
[SW-ACC-CORE-1-Vlanif1]ip address 10.0.0.1 255.0.0.0
[SW-ACC-CORE-1-Vlanif1]quit


5、显示vlan接口信息
[SW-ACC-CORE-1]display ip interface Vlanif 20
Vlanif20 current state : UP
Line protocol current state : UP
The Maximum Transmit Unit : 1500 bytes
input packets : 0, bytes : 0, multicasts : 0
output packets : 0, bytes : 0, multicasts : 0
Directed-broadcast packets:
received packets:            0, sent packets:            0
forwarded packets:           0, dropped packets:           0
Internet Address is 172.30.0.1/18
Broadcast address : 172.30.63.255
TTL being 1 packet number:         0
TTL invalid packet number:         0
ICMP packet input number:          0
  Echo reply:                      0
  Unreachable:                     0
  Source quench:                   0
  Routing redirect:                0
  Echo request:                    0
  Router advert:                   0
  Router solicit:                  0
  Time exceed:                     0
  IP header bad:                   0
  Timestamp request:               0
  Timestamp reply:                 0
  Information request:             0
  Information reply:               0
  Netmask request:                 0
  Netmask reply:                   0
  Unknown type:                    0


四、网络
1、显示IP信息
[SW-ACC-CORE-1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 1

Interface                         IP Address/Mask      Physical   Protocol  
MEth0/0/1                         unassigned           down       down      
NULL0                             unassigned           up         up(s)     
Vlanif1                           10.0.0.1/8           up         up     
Vlanif20                          172.30.0.1/18        up         up        
Vlanif30                          172.30.64.1/18       up         up


2、显示路由信息   
[SW-ACC-CORE-1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 8        Routes : 8        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.0.0/16  Direct  0    0           D   10.0.0.1        Vlanif1
       10.0.0.1/32  Direct  0    0           D   127.0.0.1       Vlanif1
      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
     172.30.0.0/18  Direct  0    0           D   172.30.0.1      Vlanif20
     172.30.0.1/32  Direct  0    0           D   127.0.0.1       Vlanif20
    172.30.64.0/18  Direct  0    0           D   172.30.64.1     Vlanif30
    172.30.64.1/32  Direct  0    0           D   127.0.0.1       Vlanif30


3、ACL
[SW-ACC-CORE-1]acl ?
  INTEGER<2000-2999>  Basic access-list(add to current using rules)
  INTEGER<3000-3999>  Advanced access-list(add to current using rules)
  INTEGER<4000-4999>  Specify a L2 acl group
  INTEGER<5000-5999>  User defined access-list
  ipv6                ACL IPv6
  name                Specify a named ACL
  number              Specify a numbered ACL

1)创建
【流规则】
[SW-ACC-CORE-1]acl 3001
[SW-ACC-CORE-1-acl-adv-3001]rule deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255
[SW-ACC-CORE-1-acl-adv-3001]quit

【流分类】
[SW-ACC-CORE-1]traffic classifier tc1
[SW-ACC-CORE-1-classifier-tc1]if-match acl 3001
[SW-ACC-CORE-1-classifier-tc1]quit

【流行为】默认是permit
[SW-ACC-CORE-1]traffic behavior tb1
[SW-ACC-CORE-1-behavior-tb1]deny
[SW-ACC-CORE-1-behavior-tb1]quit

【流策略】
[SW-ACC-CORE-1]traffic policy tp1
[SW-ACC-CORE-1-trafficpolicy-tp1]classifier tc1 behavior tb1
[SW-ACC-CORE-1-trafficpolicy-tp1]quit


【在指定接口应用策略】
[SW-ACC-CORE-1]int GigabitEthernet 0/0/2
[SW-ACC-CORE-1-GigabitEthernet0/0/2]traffic-policy tp1 inbound
[SW-ACC-CORE-1-GigabitEthernet0/0/2]quit


【测试符合预期】
PC>ping 172.30.0.111

Ping 172.30.0.111: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!

PC>ping 172.30.64.222

Ping 172.30.64.222: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 172.30.64.222: bytes=32 seq=2 ttl=127 time=78 ms
From 172.30.64.222: bytes=32 seq=2 ttl=127 time=74 ms


2)查看ACL现状
【acl】
[SW-ACC-CORE-1]display acl 3001
Advanced ACL 3001, 1 rule
Acl's step is 5
rule 5 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255

【classifier】
[SW-ACC-CORE-1]display traffic classifier user-defined
  User Defined Classifier Information:
   Classifier: tc1
    Operator: AND
    Rule(s) : if-match acl 3001

Total classifier number is 1

【behaviour】
[SW-ACC-CORE-1]display traffic behavior user-defined
  User Defined Behavior Information:
    Behavior: tb1
      Deny

Total behavior number is 1

【policy】
[SW-ACC-CORE-1]display traffic policy user-defined
  User Defined Traffic Policy Information:
  Policy: tp1
   Classifier: tc1
    Operator: AND
     Behavior: tb1
      Deny

Total policy number is 1

【applied-record】
[SW-ACC-CORE-1]display traffic-policy applied-record
#
-------------------------------------------------
  Policy Name:   tp1
  Policy Index:  1
     Classifier:tc1     Behavior:tb1
-------------------------------------------------
*interface GigabitEthernet0/0/2
    traffic-policy tp1 inbound  
      slot 0    :  success
-------------------------------------------------
  Policy total applied times: 1.
#


3)管理acl
【增加1条规则】
[SW-ACC-CORE-1]acl 3001
[SW-ACC-CORE-1-acl-adv-3001]rule deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255
[SW-ACC-CORE-1-acl-adv-3001]display acl 3001
Advanced ACL 3001, 2 rules
Acl's step is 5
rule 5 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255

rule 10 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255

【测试符合预期】
PC>ping 172.30.0.111
Ping 172.30.0.111: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!

PC>ping 172.30.64.222
Ping 172.30.64.222: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!



【删除1条规则】
[SW-ACC-CORE-1-acl-adv-3001]undo rule 5
[SW-ACC-CORE-1-acl-adv-3001]display acl 3001
Advanced ACL 3001, 1 rule
Acl's step is 5
rule 10 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255

【测试符合预期】
PC>ping 172.30.0.111
Ping 172.30.0.111: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 172.30.0.111: bytes=32 seq=2 ttl=127 time=62 ms
From 172.30.0.111: bytes=32 seq=2 ttl=127 time=64 ms

PC>ping 172.30.64.222
Ping 172.30.64.222: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!



【再增加1条规则】
[SW-ACC-CORE-1-acl-adv-3001]rule deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255
[SW-ACC-CORE-1-acl-adv-3001]display acl 3001
Advanced ACL 3001, 2 rules
Acl's step is 5
rule 10 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.64.0 0.0.63.255

rule 15 deny ip source 10.50.200.0 0.0.0.255 destination 172.30.0.0 0.0.63.255

注:rule id 递增的step为5,由于之前删除了id=5的rule,再新增则变成了15,如果先清空了这里规则,则还是从id=5开始递增。





wKiom1fGnITjeXFHAADY-bmQQnI107.jpg
                   


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-266086-1-1.html 上篇帖子: Win 10 x64 版本安装华为 ENSP 模拟器 下篇帖子: H3C光纤端口未开启故障案例 华为交换机

尚未签到

发表于 2016-10-10 19:59:20 | 显示全部楼层
整理的很好,学习了

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

累计签到:7 天
连续签到:1 天
发表于 2016-10-12 07:07:52 | 显示全部楼层
确实有用!谢谢分享!!!

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

累计签到:5 天
连续签到:1 天
发表于 2016-10-12 10:05:08 | 显示全部楼层
thanks share

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表