华为交换机命令学习
一、基础配置命令学习
1、用户模式
登陆设备后,直接进入用户模式, 尖括号表示用户模式 ,在这个模式下只能执行少量查看配置的命令;
2、视图模式
用户模式下,输入system-view或者sys进入视图模式, 方括号表示视图模式 ,可执行设备全局配置的命令;system-view Enter system view, return user view with Ctrl+Z. [Huawei] 123
3、交换机改名[Huawei]sysname switch01 #改交换机名字 [switch01] Oct 16 2020 16:02:51-08:00 switch01 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011 .5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095. 12345
Oct 16 2020 16:02:51-08:00 switch01 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4,the change loop count is 0, and the maximum number of records is 4095.
这个提示信息,比较烦人。每次更改了什么配置都会显示出来,影响调试。可以使用下面的命令关闭掉 undo terminal monitor 1
4、进入接口[switch01]int g0/0/1 [switch01-GigabitEthernet0/0/1] 12
5、退出此端口q 1
二、创建vlan并将端口加入vlan
1、创建vlan
创建单个vlan [HUAWEI]vlan 10 #创建vlan10,创建后会自动进入vlan10 [HUAWEI-vlan2]q 12
批量创建vlan [HUAWEI]vlan batch 3 to 10 #批量建立vlan,3-10 Info: This operation may take a few seconds. Please wait for a moment...done. [HUAWEI] #批量建立vlan后不会进入vlan 123
2、更改端口的链接类型
由于华为交换机的端口出厂时默认都是 hybrid类型 或auto类型 的,所以无法立即加入vlan,需要更改端口的link-type 后,才可以加入vlan。单个端口更改方式如下:[HUAWEI]int g0/0/1 [HUAWEI-GigabitEthernet0/0/1]port link-type access 12
为何要选择access类型?? 因为我们是终端PC与交换机相连,要求PC只能只能和上级交换机通信,所以必须只属于1个vlan 以太网端口的链路类型有三种:
Access 类型:端口只能属于1 个VLAN,一般用于交换机与终端用户之间的连接;Trunk 类型:端口可以属于多个VLAN,可以接收和发送多个VLAN 的报文,一般用于交换机 之间的连接;Hybrid 类型:端口可以属于多个VLAN,可以接收和发送多个VLAN 的报文,可以用于交换 机之间连接,也可以用于连接用户的计算机。Hybrid 端口可以允许多个VLAN 的报文发送时不携带标签,而Trunk 端口只允许缺省VLAN 的报文,发送时不携带标签。 trunk 端口用于交换机相连,pvid必须一致 。access 类型只能属于1 个vlan规模较大的企业局域网,不建议使用vlan1,所以trunk端口不允许vlan1通过
3、端口加入vlan[HUAWEI-GigabitEthernet0/0/1] port default vlan 10 #端口1加入vlan10 1
以上的操作是单个操作,如果配置端口比较多就很麻烦,下面我们来批量操作。
4、端口的批量操作——端口组
原理就是创建一个端口组,把要更改的端口加入到端口组中,然后统一更改类型加入vlan。也可以理解为群组端口,统一配置类型加入vlan.
批量更改,先更改端口类型,再统一加入某个vlan,如下: port-group pokes #pokes是端口组名 [swh-port-group-pokes]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2 port link-type access 设置为access模式 port default vlan 3 加入vlan3 [swh]vlan 10 #创建vlan10 [swh-vlan10]q [swh]port-group pokes #pokes是端口组名 [swh-port-group-pokes]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2 #把1、2两个端口加入到端口组中 [swh-port-group-pokes]port link-type access #更改组的端口类型 [swh-GigabitEthernet0/0/1]port link-type access #自动生成行 [swh-GigabitEthernet0/0/2]port link-type access #自动生成行 [swh-port-group-pokes]port default vlan 10 #端口组加入vlan10 [swh-GigabitEthernet0/0/1]port default vlan 10 #自动生成行 [swh-GigabitEthernet0/0/2]port default vlan 10 #自动生成行 12345678910111213141516
5、vlan的查看
全局查看vlan信息[swh]dis vlan #查看vlan信息 The total number of vlans is : 2 -------------------------------------------------------------------------------- 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/3(U) GE0/0/4(U) 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 UT:GE0/0/1(U) GE0/0/2(U) VID Status Property MAC-LRN Statistics Description -------------------------------------------------------------------------------- 1 enable default enable disable VLAN 0001 10 enable default enable disable VLAN 0010 12345678910111213141516171819202122232425
查看端口与vlan对应关系[swh]display port vlan Port Link Type PVID Trunk VLAN List ------------------------------------------------------------------------------- GigabitEthernet0/0/1 access 10 - GigabitEthernet0/0/2 access 10 - GigabitEthernet0/0/3 hybrid 1 - GigabitEthernet0/0/4 hybrid 1 - GigabitEthernet0/0/5 hybrid 1 - GigabitEthernet0/0/6 hybrid 1 - GigabitEthernet0/0/7 hybrid 1 - GigabitEthernet0/0/8 hybrid 1 - GigabitEthernet0/0/9 hybrid 1 - GigabitEthernet0/0/10 hybrid 1 - GigabitEthernet0/0/11 hybrid 1 - GigabitEthernet0/0/12 hybrid 1 - GigabitEthernet0/0/13 hybrid 1 - GigabitEthernet0/0/14 hybrid 1 - GigabitEthernet0/0/15 hybrid 1 - GigabitEthernet0/0/16 hybrid 1 - GigabitEthernet0/0/17 hybrid 1 - GigabitEthernet0/0/18 hybrid 1 - GigabitEthernet0/0/19 hybrid 1 - GigabitEthernet0/0/20 hybrid 1 - GigabitEthernet0/0/21 hybrid 1 - GigabitEthernet0/0/22 hybrid 1 - GigabitEthernet0/0/23 hybrid 1 - GigabitEthernet0/0/24 hybrid 1 - 123456789101112131415161718192021222324252627
6、允许所有vlan通过[switch01-port-group-link-type]port trunk allow-pass 1
三、首次登入交换机或路由器
第一次上电和恢复出厂是一样的,我们先说一下恢复出厂设置。
1、恢复出厂设置
注意Y和N的选项,不要输错。 reset saved-configuration Warning: The action will delete the saved configuration in the device. The configuration will be erased to reconfigure. Continue? [Y/N]:y reboot Info: The system is now comparing the configuration, please wait. Warning: The configuration has been modified, and it will be saved to the next startup saved-configuration file . Continue? [Y/N]:n Info: If want to reboot with saving diagnostic information, input "N" and then execute "reboot save diagnostic-information". System will reboot! Continue?[Y/N]:y 12345678910
2、设置新密码
新交换机第一次上电,或恢复出厂设置后,要求设置新密码出厂自带的用户名是admin,密码是 admin@huawei.com Login authentication Username:admin Password: Warning: The default password poses security risks. The password needs to be changed. Change now? [Y/N]: y Please enter old password: Please enter new password: --------------输入密码时没有任何显示 Please confirm new password: The password has been changed successfully. 1234567891011
3、首次保存配置
第一次保存设置时,需输入文件名,只需按回车 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]: May 28 2019 10:57:52 HUAWEI %%01CFM/4/SAVE(s)[1]:The user chose Y when deciding whether to save the configuration to the device. flash:/vrpcfg.zip exists, overwrite?[Y/N]:y May 28 2019 10:57:54 HUAWEI %%01CFM/4/OVERWRITE_FILE(s)[2]:When deciding whether to overwrite the configuration file vrpcfg.zip, the user chose Y. Now saving the current configuration to the slot 0...... Save the configuration successfully. 123456789
4、设置日期和时间clock datetime 10:46:30 2019-05-28 1
设置console口的连接方式,可设置为无,仅密码,用户名密码等方式 [HUAWEI]user-interface console 0 [HUAWEI-ui-console0]authentication-mode ? aaa AAA authentication, and this authentication mode is recommended none Login without checking password Authentication through the password of a user terminal interface [HUAWEI-ui-console0]set authentication password [HUAWEI-ui-console0]set authentication password cipher administrator 123456789
5、开启必要的服务和功能
开启telnet服务,stp功能,http服务 [HUAWEI]telnet server enable #开启telnet服务 [HUAWEI]stp mode rstp #设置stp模式为rstp [HUAWEI]stp enable #开启stp功能 [HUAWEI]http server enable #开启http服务(默认就是开启的) 1234
6、设置vty,telnet登录[HUAWEI]user-interface maximum-vty 15 #vty界面最大值15 authentication-mode password #认证模式设置为仅需密码,也可设置为aaa模式 user privilege level 15 #用户权限级别15(非常重要) set authentication password cipher $1a$IZ,o~LZ$Z.$GHlQ-zn9-Gn<*8(yp-@F#6wmH;M%L#($PXNa.:$---此处是密码,输入时是明文,根据需要设置 history-command max-size 256 #命令行最大历史记录 idle-timeout 6 0 #用户超时时间6分0秒 screen-length 100 #屏幕长度100行 protocol inbound telnet #允许telnet协议进入(非常重要) 123456789
7、设置一个用户用于网页登录[HUAWEI]aaa [HUAWEI-aaa]dis local-user ---------------------------------------------------------------------------- User-name State AuthMask AdminLevel ---------------------------------------------------------------------------- admin A MH 15 ---------------------------------------------------------------------------- Total 1 user(s) [HUAWEI-aaa]undo local-user admin Error: Have user(s) online, can not be deleted. [HUAWEI-aaa]quit 1234567891011
由于第一次登录时,console口要求用户名密码登录,所以无法删除本地用户admin,此时可退到<>视图,保存设置,退出交换机,再重新登录。由于我们已经将console口的认证方式改为仅需密码,所以可以再次进入aaa,删除用户admin。删除后,再建立admin,权限,服务类型等,均可由我们自己控制。 [HUAWEI]aaa [HUAWEI-aaa]undo local-user admin [HUAWEI-aaa]local-user admin password irreversible-cipher administrator idle-timeout 6 0 #administrator为密码,根据需要设置 Info: Add a new user. [HUAWEI-aaa]local-user admin service-type http [HUAWEI-aaa]local-user admin privilege level 15 Warning: This operation may affect online users, are you sure to change the user privilege level ?[Y/N]y [HUAWEI-aaa]local-user admin ftp-directory flash: 12345678
如遇更新版本的交换机软件,telnet服务要求必须是aaa认证(用户名密码认证),可按上面所述再建立一个用户,service-type设置为telnet。
8、关闭交换机自动弹出配置改变告警
输入配置命令后设备会提示如下类似信息:
DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 64, and the maximum number of records is 1.
这个是配置改变的告警提示信息,不是错误信息,可以配置如下命令屏蔽此信息: [HUAWEI]info-center source DS channel console trap level warning state off 1
四、设置链路聚合[HUAWEI]interface Eth-Trunk 1 [HUAWEI-Eth-Trunk1]port link-type trunk Info: This operation may take a few seconds. Please wait for a moment...done. [HUAWEI-Eth-Trunk1]port trunk pvid vlan 10 [HUAWEI-Eth-Trunk1]port trunk allow-pass vlan 2 to 4000 Info: This operation may take a few seconds. Please wait a moment....done. [HUAWEI-Eth-Trunk1]undo port trunk allow-pass vlan 1 Info: This operation may take a few seconds. Please wait a moment...done. [HUAWEI-Eth-Trunk1]dis this # interface Eth-Trunk1 port link-type trunk port trunk pvid vlan 10 undo port trunk allow-pass vlan 1 port trunk allow-pass vlan 2 to 4000 # return 1234567891011121314151617
以上命令建立一个聚合端口,并设置了端口的属性 [HUAWEI]interface GigabitEthernet 0/0/25 [HUAWEI-GigabitEthernet0/0/25]eth-trunk 1 Info: This operation may take a few seconds. Please wait a moment...done. 123
以上命令将G 0/0/25端口加入聚合端口eth-trunk 1,无需更多设置。可将更多的端口加入聚合端口。
五、交换机DHCP
开启DHCP功能,设置地址池,并应用 [HUAWEI]dhcp enable ip pool 192.168.2.0 #建立一个地址池,名为192.168.2.0 gateway-list 192.168.2.254 #设置网关地址 network 192.168.2.0 mask 255.255.255.0 #设置网段 excluded-ip-address 192.168.2.251 192.168.2.253 #设置不参与分配的IP地址范围 lease day 0 hour 0 minute 30 #设置租期时长 dns-list 114.114.114.114 8.8.8.8 #设置dns地址 [HUAWEI]interface Vlanif 2 #进入vlanif 2 [HUAWEI-Vlanif2]ip address 192.168.2.254 24 #给vlanif 2 设置IP地址(就是上面地址池的网关地址) [HUAWEI-Vlanif2]dhcp select global #DHCP选择全局,会自动匹配地址池 1234567891011121314
六、开启流控制功能,限制某些网段互链
主要是限制访客网与办公网、财务网互访 [HUAWEI]acl number 3001 #添加一个高级ACL,可控制源地址和目的地址 Info: When the ACL that is referenced by SACL is modified, the SACL will be dynamically updated. During the update, these SACL will become invalid temporarily. [HUAWEI-acl-adv-3001]rule 1000 deny ip source 172.16.0.0 0.0.255.255 destination 192.168.0.0 0.0.255.255 [HUAWEI-acl-adv-3001]rule 1100 deny ip source 172.16.0.0 0.0.255.255 destination 175.40.0.0 0.0.255.255 [HUAWEI-acl-adv-3001]quit 12345
注意源地址和目的地址的反向掩码 [HUAWEI]traffic-filter inbound acl 3001 #在全局层面应用ACL 3000里面的规则 1
2022年的现在,OPPOfindx3还值得买吗?传送直达httpsu。jd。comWKoRceQOPPOFindX38128GB版本,京东目前售价3199元。有2张80050优惠券的话可做到3099元优惠券是自动弹出来,没有的可
目前最便宜的4款二手机皇,优点各不相同,最高降价5000元买二手机曾经是预算低的性价比之选,而如今随着靠谱的平台出现,也成为一种合理的投资。今天就来给大家推荐四款性价比超高的四款二手手机,买新不买旧在它们身上一点也不灵验,曾经的机皇也能轻
iQOONeo6和iQOONeo5S到底有什么不同?iQOONeo5还值得购买吗?iQOONeo系列终于发布新机了,去年iQOO并没有直接推出Neo6这款产品,而是选择在iQOONeo5的基础上进行了小幅度升级,推出了iQOONeo5S。今年4月份iQOO终于推
信息技术让教育进入循证时代近年来,随着5G大数据人工智能物联网等新一代信息技术全面深度地进入教育领域,教育正在从一个经验主导的时代走向证据主导的时代循证时代,这必将深刻影响并改变教育的面貌。对教师而言,它让
2000亿巨头也入局了中国基金报记者李智最壕A股公司工业富联又有大动作。4月12日,富士康工业互联网股份有限公司于天津投资成立私募公司,私募行业再迎重量级企业入局。富士康于天津投资成立私募公司天眼查数据
小鹏汽车P5量产车中最早使用激光雷达后续拥有城市NGP功能还能躺平看电影和睡觉等等,将这些骚操作到一起,你会想到什么车?是一辆售价30W的豪车?还是一辆大空间SUV?如果你这么想,方向就错了。
100人署名的AI综述被指抄袭,智源研究院发布初步调查结果并致歉量子通信1100公里!我国科学家创造量子直接通信最远纪录我国科学家近日设计出一种相位量子态与时间戳量子态混合编码的量子直接通信新系统,成功实现100公里的量子直接通信。100公里,
界读丨库克降价策略失败!最便宜iPhone没人买欧界报道近几年,我们看到了一个更接地气的苹果,原本价格高得吓人的产品也开始变得略微友好,这是库克坚持降价策略的结果。苹果实行降价策略的根本原因,还是因为安卓手机的冲击。随着三星华为
疯狂过后,便是一堆烂摊子老狗以负责任客观理性的态度分享自己的市场观点,并有自己独特的市场观点文章中的数据和信息来自公共新闻和新闻。然而,无法保证信息的准确性和完整性。内容仅供参考,不构成任何投资建议。如今
开发一个购物app要多久,要多少钱?首先,这个问题在没有给出详细描述的情况下,跟问买一个房子需要多少钱一样,答案是非常多的,所以在回答这个问题时,需要根据不同的需求场景进行分别阐述。随着当前互联网在消费端已经逐渐进入
这部用了快四年的手机,我为什么舍不得换?最近看到一篇文章,标题是为什么现在年轻人都不愿意换手机,将原因归结为CPU性能过剩,如果不玩游戏的话,几年前的机器也够用。而我有一部用了快四年的华为Mate20X,一直也舍不得换掉