1、HCNA 入门部分一、命令行基础用户视图; Huawei系统视图逐级退出:quit; 完全退出:Ctrl+Z; 打断:Ctrl+C1、修改设备名称:Huaweisysname R12、配置系统时钟:设置所在时区:clock timezone beijing add 08:00:00设置当前时间:clock datetime 16:35:25 2018-03-29设置采用夏时制:clock daylight-saving-time3、配置标题消息:配置在用户登陆前显示的标题消息:R1header login information “welcome to R1“配置在用户登陆后显示的标题消息:R
2、1header shell information “no reboot R1“4、配置特定等级用户在特定视图具有特定命令:R1command-privilege level 15 view user save5、为 VRP系统创建账户(创建账户缺省是 level15,服务类型包括terminal):R1aaaR1-aaalocal-user admin privilege level 15 password cipher huaweiR1-aaalocal-user admin service-type terminal(用于指定账户的服务类型,默认是 ALL)6、在 console口配置使
3、用超级终端登录时的验证方式(缺省时不验证):R1user-interface console 0R1-ui-console0authentication-mode aaa7、用户界面:VTY 虚拟类型终端:R1user-interface vty 0 4R1-ui-vty0-4authentication-mode password(或者 aaa)8、配置登录的超时时间(缺省是 10分钟):R1user-interface console 0R1-ui-console0idle-timeout 5 09、指定终端屏幕临时显示的行数(缺省是 24行):R1user-interface conso
4、le 0R1-ui-console0screen-length 1010、历史命令缓冲区大小(缺省是 10行):R1user-interface console0R1-ui-console0history-command max-size 2011、配置只使用口令登录之后获取的权限:R1user-interface console 0R1-ui-console0user privilege level 1512、配置 IP地址:R1int g0/0/1R1-GigabitEthernet0/0/1ip add 192.168.1.1 24二、文件系统基础1、基本查询命令(1)查看当前目录:pw
5、d(2)查看当前目录下的文件列表:dir(3)查看文办文件:more .txt2、目录操作(1)创建目录:mkdir aaa(2)进入目录:cd aaa(3)删除目录:mkdir aaa3、文件操作(1)文件拷贝:copy flash:/dhcp/dhcp-duid.txt flash:/bbb/ Copy flash:/dhcp/dhcp-duid.txt to flash:/bbb/dhcp-duid.txt? (y/n)n:y(2)文件重命名:rename flash:/bbb/dhcp-duid.txt flash:/bbb/123.txtRename flash:/bbb/dhcp-
6、duid.txt to flash:/bbb/123.txt? (y/n)n:y(3)文件移动:move flash:/bbb/123.txt flash:/aaa/ Move flash:/bbb/123.txt to flash:/aaa/123.txt? (y/n)n:y(4)删除文件:delete flash:/aaa/123.txt Delete flash:/aaa/123.txt? (y/n)n:y(5)恢复被删除文件:undelete flash:/aaa/123.txt Undelete flash:/aaa/123.txt? (y/n)n:y(6)永久删除文件:delete
7、 /unreserved flash:/aaa/123.txt Warning: The contents of file flash:/aaa/123.txt cannot be recycled. Continue? (y/n)n:y4、管理配置文件(1)查看当前配置文件(RAM):R1display current-configuration(2)查看保存的配置文件(flash/SD 卡):R1display saved-configuration(3)保存配置:save(4)删除保存的配置文件,恢复出厂设置:delete flash:/vrpcfg.zip 或reset saved-c
8、onfiguration(5)系统启动文件的查询:display startup(6)修改系统启动后加载的配置文件:startup saved-configuration flash:/123.zip(7)修改系统启动系统文件:startup system-software 路径(8)比较配置文件:compare configuration5、修复存储设备:fixdisk flash: 6、格式化存储设备:format flash:三、VRP 系统管理1、升级路由器的 VRP系统:(1)在 FTP SERVER下准备更新的 VRP系统文件(2)实现路由器与 FTP SERVER的网络连接性(3
9、)在路由器的用户视图下连接到 FTP SERVER:ftp 192.168.1.2R1-ftpget 文件名 ( get下载,put 上传)startup system-software flash:文件名2、备份路由器的 VRP系统:(1)在 FTP SERVER下准备更新的 VRP系统文件(2)实现交换机与 FTP SERVER的网络连接性interface vlanif 1IP add 192.168.123.200.24(3)在交换机的用户视图下连接到 FTP SERVER: ftp 192.168.1.2ftpput 文件名四、修改丢失的口令(1)必须使用 console口连接设备,
10、(2)打开电源之后使用 Ctrl+B进入 BOOTROM菜单中(默认口令是 huawei) ;(3)在进入 BOOTROM MENU中,选择 5 (5. Enter filesystem submenu) ;(4)然后再选择 4 (4.Rename file from Flash);(5)选择 vrecfg.zip文件进行重命名(vrpcfg1.zip); (6)最后选择 6(6.Return to main menu) 回到 BOOTROM菜单,再选择 7 (7.Reboot) 重启设备;(7)设备重启之后将不能加载配置文件(即此时不需要验证口令就可登录 )此时可以在用户视图下再将之间重命名
11、的配置文件再修改成 vrpcfg.ziprename vrpcfg1.zip vrpcfg.zipRename flash:/vrpcfg1.zip to flash:/vrpcfg.zip ?Y/N:y_(8)在用户视图下使用 display saved-configuration 命令查看保存的配置文件,然后再将保存的配置文件拷贝到系统视图下执行,以加载到当前配置文件中;(9)修改验证的口令,并保存配置SW1aaasW1-aaalocal-user test password cipher 123456sw1user-interface console 0sW1-ui-consoleaut
12、hentication-mod ?aaa AAA authenticationnone Login without checkingpassword Authentication through the password of a user terminal五、交换网络基础(1)查看交换机 MAC地址表:S1display mac-address(2)配置接口的速率和双工(缺省是自动协商:就低不就高):S1interface Ethernet0/0/1S1-Ethernet0/0/1negotiation auto(3)手工修改速率和双工需要关闭自动协商:S1interface Etherne
13、t0/0/1S1-Ethernet0/0/1undo negotiation autoS1-Ethernet0/0/1speed 100S1-Ethernet0/0/1duplex (4)查看交换机接口状态:S1-Ethernet0/0/1display interface e0/0/1六、配置 STP1)配置交换机的 STP模式为 STPS1-4stp mode stp2)通过修改优先级,调整跟交换机的位置(缺省是 32768,推荐使用汇聚层交换机为跟交换机)S3stp priority ?INTEGER Bridge priority, in steps of 4096S3stp prio
14、rity 0S4stp priority 40963)通过配置端口开销选择 RP(1Gbps 端口在 STP中默认的开销是 20000)S4interface g0/0/4S4-GigabitEthernet0/0/4stp cost 100004)修改端口开销计算方式S4stp pathcost-standard ?dot1d-1998 IEEE 802.1D-1998dot1t IEEE 802.1Tlegacy Legacy5)通过配置端口优先级选择 RP(缺省是 128)S3int g0/0/3S3-GigabitEthernet0/0/3stp port priority 112S4
15、int g0/0/3S4-GigabitEthernet0/0/3stp cost 100006)检查 stp运行:S1display stpS1display stp briefdisplay stp interface g0/0/4七、配置 RSTP1)配置 STP模式为 RSTPS1stp mode rstp2)配置边缘端口S1int e0/0/1S1-Ethernet0/0/1stp edged-port enable3)配置根桥S3stp priority 0S4stp priority 40964)配置端口开销和优先级S4-GigabitEthernet0/0/4stp cost
16、S3-GigabitEthernet0/0/3stp port priority 5)配置根保护(在根桥连接接入层交换机的 DP上配置)S3int g0/0/1S3-GigabitEthernet0/0/1stp root-protection (S3 : g0/0/1、g0/0/2、S4:g0/0/1、g0/0/2)被配置为根保护的 DP端口接收到更优 BPDU时,端口要被置为Discarding(丢弃)状态6)配置 BPDU保护边缘端口一般用于连接 PC,不能接收到 BPDU,但如果攻击者恶意伪造BPDU发送到边缘端口,边缘端口会自动变为非边缘端口,并参与网络拓扑计算,引发网络的震荡。配置
17、 BPDU保护可以让边缘端口在接收到 BPDU时,端口直接被关闭,并通知到网管系统,端口需要背手工开启之后才能正常工作。S1/2stp bpdu-protection 7)配置环路保护当 AP端口所在链路发生故障,成为单向链路时可能产生环路,配置环路保护,可以解决该问题S1int g0/0/2S1-GigabitEthernet0/0/2stp loop-protection配置分公司访问到总部的服务器群R3int g0/0/0R3-GigabitEthernet0/0/0ip add 192.168.3.1 24R3int g0/0/2R3-GigabitEthernet0/0/2ip ad
18、d 192.168.13.3 24R3int Pos5/0/0R3-Pos5/0/0ip add 192.168.31.3 24R1int g0/0/2R1-GigabitEthernet0/0/2ip add 192.168.13.1 24R1int Pos5/0/0R1-Pos5/0/0ip add 192.168.31.1 24在 R3上配置到达服务器群的静态路由1)配置静态路由的负载均衡R3ip route-static 192.168.5.0 24 192.168.13.1R3ip route-static 192.168.5.0 24 192.168.31.12)配置静态浮动路由(
19、备份)R1ip route-static 192.168.3.0 24 192.168.13.3R1ip route-static 192.168.3.0 24 192.168.31.3 preference 100八、配置 RIPv1在华为路由器中启用 RIP时,缺省使用的进程 ID是 1,缺省的版本是 RIPv1 Compatible(即发送 RIPv1更新,可接收 RIPv1和 RIPv2)1、RIP 的基本配置1)RIPv1 的基本配置R1ripR1-rip-1version 1R1-rip-1network 192.168.5.0R1-rip-1network 192.168.1.0
20、R1-rip-1network 192.168.13.0R1-rip-1network 192.168.31.0R3rip R3-rip-1version 1R3-rip-1network 192.168.3.0R3-rip-1network 192.168.13.0R3-rip-1network 192.168.31.02)配置 RIPv2R3rip R3-rip-1version 2R1rip R1-rip-1version 22、RIP 的其他配置1)配置 RIP的水平分割(缺省已启用)R3int g0/0/2R3-GigabitEthernet0/0/2rip split-horizo
21、n display rip 1 interface g0/0/2 v2)配置 RIP的毒性反转(缺省未开启)水平分割和毒性反转同时启用时,毒性反转生效R3-GigabitEthernet0/0/2rip poison-reverse3)配置接口接收或发送路由时的偏移R3int Pos 5/0/0R3-Pos5/0/0rip metricout 3R3-Pos5/0/0rip metricin 34)配置 RIP在接口是否发送或接收 RIP报文R3int g0/0/0R3-GigabitEthernet0/0/0undo rip output R3-GigabitEthernet0/0/0und
22、o rip inputR1int g0/0/1R1-GigabitEthernet0/0/1undo rip output R1-GigabitEthernet0/0/1undo rip input 5)配置接口的静默R1ripR1-rip-1silent-interface g0/0/0检查参与 RIP进程的接口:R1display rip 1 interface 检查 RIP学习到的路由:display ip routing-table protocol rip查看 RIP的数据库display rip 1 database 查看 RIP进程dis rip 1九、OSPF1、OSPF 的基
23、本配置:R1undo rip 1R1ospf 1 router-id 1.1.1.1R1-ospf-1area 0R1-ospf-1-area-0.0.0.0network 192.168.5.0 0.0.0.255R1-ospf-1-area-0.0.0.0network 192.168.0.0 0.0.255.255R3undo rip 1R3ospf 1 rouR3ospf 1 router-id 3.3.3.3R3-ospf-1area 0R3-ospf-1-area-0.0.0.0network 192.168.3.1 0.0.0.0R3-ospf-1-area-0.0.0.0net
24、work 192.168.13.3 0.0.0.0R3-ospf-1-area-0.0.0.0network 192.168.31.3 0.0.0.02、OSPF 的其他配置:(1)配置接口的成本R3int pos5/0/0R3-Pos5/0/0ospf cost 10(2)配置接口的优先级(默认是 1):R3-GigabitEthernet0/0/2ospf dr-priority 10R1-GigabitEthernet0/0/2ospf dr-priority 0(3)配置 OSPF认证:R1int Pos 5/0/0R1-Pos5/0/0ospf authentication-mode
25、 md5 1 cipher 123456R3int Pos 5/0/0R3-Pos5/0/0ospf authentication-mode md5 1 cipher 1234563、检查 OSPF:(1)查看参与 OSPF进程的接口:R3dis ospf interface(2)查看 OSPF邻居:R3dis ospf peer (3)查看 OSPF建立的 IP路由表:R3dis ip routing-table protocol ospf十、DHCPDHCP接口地址池配置R3int g0/0/0R3-GigabitEthernet0/0/0ip add 10.0.3.1 24R3ospf
26、1R3-ospf-1area 0R3-ospf-1-area-0.0.0.0undo network 192.168.3.1 0.0.0.0R3-ospf-1-area-0.0.0.0network 10.0.3.0 0.0.0.255或R3-GigabitEthernet0/0/0ospf enable 1 area 0必须先创建区域 0R3dhcp enable R3int g0/0/0R3-GigabitEthernet0/0/0dhcp select interface R3-GigabitEthernet0/0/0dhcp server dns-list 192.168.5.1R3-
27、GigabitEthernet0/0/0dhcp server excluded-ip-address 10.0.3.7 10.0.3.254R3-GigabitEthernet0/0/0dhcp server lease day 1查看 DHCP SERVER数据库:dis dhcp server database 查看 IP地址池:dis ip pool DHCP全局地址池配置R3int g0/0/0R3-GigabitEthernet0/0/0undo dhcp select interface R3-GigabitEthernet0/0/0qR3ip pool R3R3-ip-pool
28、-R3network 10.0.3.0 mask 255.255.255.0R3-ip-pool-R3gateway-list 10.0.3.1R3-ip-pool-R3dns-list 192.168.5.1R3-ip-pool-R3excluded-ip-address 10.0.3.7 10.0.3.254R3-ip-pool-R3lease day 2R3-ip-pool-R3qR3int g0/0/0R3-GigabitEthernet0/0/0dhcp select global DHCP中继(Relay)配置DHCP SERVERint g0/0/0DHCP SERVER-Gig
29、abitEthernet0/0/0ip add 192.168.5.4 24DHCP SERVERdhcp enable DHCP SERVERip route-static 0.0.0.0 0 192.168.5.251DHCP SERVERip pool LAN1DHCP SERVER-ip-pool-LAN1network 10.0.1.0 mask 255.255.255.128DHCP SERVER-ip-pool-LAN1gateway-list 10.0.1.101DHCP SERVER-ip-pool-LAN1dns-list 192.168.5.1DHCP SERVER-ip
30、-pool-LAN1excluded-ip-address 10.0.1.6 10.0.1.100DHCP SERVER-ip-pool-LAN1excluded-ip-address 10.0.1.102 10.0.1.106DHCP SERVER-ip-pool-LAN1lease day 2DHCP SERVER-GigabitEthernet0/0/0dhcp select global R1dhcp enR1dhcp enable R1int g0/0/1R1-GigabitEthernet0/0/1ip add 10.0.1.101 25R1-GigabitEthernet0/0/
31、1dhcp select relay R1-GigabitEthernet0/0/1dhcp relay server-ip 192.168.5.4R1-GigabitEthernet0/0/1ospf enable 1 area 0十一、Telnet1)使用 password验证:R1user-interface vty 0 4R1-ui-vty0-4authentication-mode password Please configure the login password (maximum length 16):123456R1-ui-vty0-4set authentication
32、password cipher 123456R1-ui-vty0-4user privilege level 缺省是 0(2)使用 aaa验证R1user-interface vty 0 4R1-ui-vty0-4authentication-mode aaaR1aaaR1-aaalocal-user huawei password cipher 123456R1-aaalocal-user huawei service-type telnet R1-aaalocal-user huawei privilege level 15(3)配置 Router/Switch作为 SSH SERVERR
33、1stelnet server enable R1user-interface vty 0 4R1-ui-vty0-4authentication-mode aaaR1-ui-vty0-4protocol inbound sshR1aaaR1-aaalocal-user ssh1 password cipher 123456R1-aaalocal-user ssh1 service-type sshR1-aaalocal-user ssh1 privilege level 15(4)SSH SERVER的其他配置配置论证连接的重试次数,超过次数则断开连接(缺省是 3)R1ssh server authentication-retries 配置 SSH SERVER不兼容 SSH v1.x版本(默认兼容)R1undo ssh server compatible-ssh1x enable 修改 SSH端口号(缺省是 22)R1ssh server port 配置 SSH 密钥更换时间:R1ssh server rekey-interval