华为路由交换基础命令

一、基本配置(时间、名字、登录方式、账号密码)

1、密码登录:
	[Huawei]user-interface console 0			//进入管理控制口
	[Huawei-ui-console0]authentication-mode password
	Please configure the login password (maximum length 16):输入密码
	[Huawei-ui-console0]user privilege level ?		//设置特权等级
	[Huawei-ui-console0]idle-timeout 20 0		//设置空闲超时时间为20分钟,默认为10分钟
2、用户和密码登录:
	[Huawei]user-interface console 0			//进入管理控制口
	[Huawei-ui-console0]authentication-mode aaa
	[Huawei-ui-console0]quit
	[Huawei]aaa
	[Huawei-aaa]local-user huawei password cipher hw(密码)
	[Huawei-aaa]local-user huawei service-type terminal	//从终端登录
3、PC通过以太网口远程登录路由器
	[Huawei]user-interface vty 0 4
	[Huawei-ui-vty0-4]authentication-mode aaa
	[Huawei-ui-vty0-4]q
	[Huawei]aaa
	[Huawei-aaa]local-user huawei password cipher hw(密码)
	[Huawei-aaa]local-user huawei privilege level 3
	[Huawei-aaa]local-user huawei service-type telnet		//远程登录
4、设置超级密码
	[Huawei]super password level 3 cipher 123456(作用?)
5、登录标语
	[R1]header shell information "Welcome to HuaWei"
6、指定下次启动装载的配置文件
	startup saved-configuration iascfg.zip
7、设备重启后恢复为出厂配置
	factory-configuration reset
8、将路由器作为FTP服务器
	[R1]ftp server enable
	[R1]aaa
	[R1-aaa]local-user winda password cipher aqx123456(字母与数字的组合)
	[R1-aaa]local-user winda privilege level 15
	[R1-aaa]local-user winda service-type ftp
	[R1-aaa]local-user winda ftp-directory flash:	//指定目录
9、登录FTP服务器,并传送文件
	ftp 10.0.12.2
	User(10.0.12.2:(none)):huawei
	331 Password required for huawei.
	Enter password:
	230 User logged in.
	[R1-ftp]put portalpage.zip		//上传文件
	[R1-ftp]get portalpage.zip portal.zip	//下载文件并改名字
	delete /unreserved portal.zip	//彻底删除该文件
10、设置下次启动用的文件
	startup saved-configuration 文件名
11、删除保存的配置文件
	reset saved-configuration
	reboot
	Warning: All the configuration will be saved to the next startup configuration. 
	Continue ? [y/n]:n

二、路由IP配置

1、浮动静态路由
	[Huawei]ip route-static 192.168.1.0 24(目标网络) 192.168.2.1(下一跳IP) preference 80
2、描述接口
	[R1-Serial1/0/0]description this port connect to R2-S1/0/0
3、默认(缺省)路由
	[R1]ip route-static 0.0.0.0 0.0.0.0 10.0.13.3
4、使用带源参数的ping命令
	[R2]ping -a 10.0.2.2 10.0.3.3
5、配置从IP地址(解决RIPv1不连续子网)
	[R1-Serial1/0/0]ip add 10.0.23.2 sub
6、静态路由与BFD联动
	#激活BFD功能
	[R1]bfd
	[R1-bfd]quit

	#创建BFD会话,名称为ab(自定义),对端的IP地址为10.1.12.2
	[R1]bfd ab bind peer-ip 10.1.12.2

三、RIP

1、配置
	[Huawei]rip 1			//启动RIP进程
	[Huawei-rip-1]version 2		//选择版本(可选)
	[Huawei-rip-1]net 10.0.0.0(通告自然网段)			
3、使能自动汇总[V2默认开启,但不生效]
	[Huawei-rip-1]summary always
    或关闭接口水平分割
	[接口]undo rip split-horizon
4、手动汇总
	[Huawei-GigabitEthernet0/0/0]rip summary-address 聚合后网络 子网掩码
5、接口附加度量值
	[接口]rip metricin x	cost=原来的值+x
	[接口]rip metricout x	cost=0+x
6、认证
     明文:
	[R2-Serial1/0/0]rip authentication-mode simple huawei
     MD5:
	[R2-Serial2/0/0]rip authentication-mode md5 usual huawei
7、开启RIP调试
	debug rip 1
	terminal debugging
	Info: Current terminal debugging is on.
	terminal monitor
8、引入路由
	[R2-rip-1]import-route static		//静态
	[R2-rip-1]import-route ospf cost x	//引入OSPF(cost=原来的值+x)
9、抑制接口(只收不发)
	[R1-GigabitEthernet0/0/0]undo rip output	//不能使用单播通信
      或[R2-rip-1]silent-interface E0/0/0		//优先级高于前者
	单播通信:
		[R2-rip-1]peer IP地址
10、修改优先级(只在本地有效)
	[R2-rip-1]preference x
11、修改定时器
	[R2-rip-1]timers rip 20 120 60
12、发布默认路由
	[R3]ip route-static 0.0.0.0 0 LoopBack 2
	[R3-rip-1]default-route originate[不需创建默认路由,也能发布]		
13、刷新RIP统计信息
	reset rip 1 statistics 
     清除RIP学到的路由信息
	reset ip routing-table statistics protocol rip
     删除RIP
	[R2]undo rip 1
14、[R1]rip version2 multicase	//配置版本1的也能发送RIPv2报文

四、OSPF

1、配置OSPF
	配置环回口IP地址
	[R1]ospf Router-id ?(为环回口IP地址)
	[R1-ospf-1]area 0(所在区域)
	[R1-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255(反子网掩码)
2、查看邻居
	[R1]dis ospf peer brief(可选)
3、查看OSPF学到的路由
	[R1]dis ip routing-table protocol ospf
4、显示链路状态数据库的外接路由信息
	[R1]display ospf lsdb ase 172.16.0.0
5、重置OSPF进程
	reset ospf process
6、引入路由
	直连路由:
		 [R3-ospf-1]import-route direct
	RIP路由:[R1-ospf-1]import-route rip 1 cost 100
7、发布默认路由
	[R3]ip route-static 0.0.0.0 0 LoopBack 2
	[R3]ospf 100
	[R3-ospf-100]default-route-advertise
   自动发布默认路由
	[R3-ospf-100]default-route-advertise always
8、修改Hello和Dead时间
	[R1-GigabitEthernet0/0/0]ospf timer hello 15
	[R1-GigabitEthernet0/0/0]ospf timer dead 60
9、修改DR优先级
	[R1-GigabitEthernet0/0/0]ospf dr-priority 200(越大优先级越高)
	注:由于DR/BDR选举默认为不抢占模式,因此在修改了路由器优先级后不会自
	    动重新选举DR,需要重置OSPF进程。
10、OSPF验证:
	接口认证明文:[R1-Serial1/0/0]ospf authentication-mode simple plain huawei
	区域认证密文:
		      [R1-ospf-1]area 1
		     [R1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher huawei
11、修改网络类型为广播
	[R2-Serial2/0/0]ospf network-type broadcast
12、查看接口的OSPF信息
	[R1]dis ospf interface GigabitEthernet 0/0/0
13、修改开销值、带宽参考值
	[接口]ospf cost x
	[R3-ospf-1]bandwidth-reference x
16、抑制接口(不收不发)
	[R2-ospf-1]silent-interface E0/0/0
	单播通信:
		[R2-ospf-1]peer IP地址

五、VLNA

1、创建Eth-trunk 1,并将接口加入Eth-trunk 1
	[S1]interface Eth-Trunk 1
	[S1]int g0/0/9
	[S1-GigabitEthernet0/0/9]eth-trunk 1
	或
	[S1]interface Eth-Trunk 1
	[S1-Eth-Trunk1]trunkport g0/0/9
2、配置Eth-trunk 1链路配置为access
	[S1]interface Eth-Trunk 1
	[S1-Eth-Trunk1]port link-type access
	[S1-Eth-Trunk1]port default vlan 5
3、配置端口的Trunk类型
	[SW1]interface g0/0/24
	[SW1-GigabitEthernet0/0/24]port link-type trunk(接交换机)
	[SW1-GigabitEthernet0/0/24]port trunk allow-pass vlan all		//允许所有VLAN通过	
4、创建VLAN,配置端口为access,属于vlan 10	
	[Huawei]vlan 10							//创建VLAN	
	[Huawei]interface GigabitEthernet 0/0/2				//进入相应端口
	[Huawei-GigabitEthernet0/0/2]port link-type access(接用户)	//选择端口类型
	[Huawei-GigabitEthernet0/0/2]port default vlan 10		//加入相应VLAN
	技巧:[S2]vlan batch 3 to 5		//配置VLAN3、4、5
6、配置端口的Hybrid类型
	[SW1]vlan 10
	[SW1-GigabitEthernet0/0/1]port hybrid pvid vlan 10
	[SW1-GigabitEthernet0/0/1]port hybrid untagged vlan 10 30		//对VLAN10和30去标签
7、更改Trunk端口的PVID
	[SW1-GigabitEthernet0/0/24]port trunk pvid vlan 10
8、删除端口VLAN
	[SW1]interface g0/0/1
	[SW1-GigabitEthernet0/0/1]undo port default vlan
	[SW1-GigabitEthernet0/0/1]undo port link-type
9、将Trunk改为Access
	[Huawei]interface Ethernet 0/0/1
	[Huawei-Ethernet0/0/1]undo port trunk allow-pass vlan all
	[Huawei-Ethernet0/0/1]port trunk allow-pass vlan 1
	[Huawei-Ethernet0/0/1]port link-type access
	[Huawei-Ethernet0/0/1]port default vlan 10	
10、单臂路由子接口
	[R1]interface g0/0/0.10
	[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10		//对VLAN10的帧去标签
	[R1-GigabitEthernet0/0/0.10]arp broadcast enable		//使能子接口主动发送ARP广播去获得PC2的MAC地址
11、三层交换机配置[每个端口直接接主机]
	创建VLAN,端口设为Access,加入VLAN
	[SWA]interface vlanif 100
	[SWA-Vlanif1]ip add 192.168.10.1 255.255.255.0
	[SWA]interface vlanif 200
	[SWA-Vlanif200]ip add 192.168.20.1 255.255.255.0

六、帧中继

1、DCE配置
	[R1]interface s1/0/0
	[R1-Serial1/0/0]link-protocol fr
	[R1-Serial1/0/0]fr interface-type dce			//接口类型
	[R1-Serial1/0/0]fr dlci 100
	[R1-Serial1/0/0]ip add 192.168.1.1 24
2、DTE配置
	[R2]interface s1/0/0
	[R2-Serial1/0/0]link-protocol fr
	[R2-Serial1/0/0]fr interface-type dte		
3、查看PVC
	[R1]dis fr pvc-info
4、查看映射
	[R1]dis fr map-info
5、静态映射
	[R2-Serial1/0/0]undo fr inarp
	[R1-Serial1/0/0]fr map ip 192.168.1.2 100 broadcast	//OSPF中使用组播的网络类型时,应在映射后面加Broadcast

七、VRRP

1、基本配置
	[SW1]interface vlan 10
	[SW1-Vlanif10]vrrp vrid 1 virtual-ip 10.1.1.254(虚拟网关)
2、更改优先级
	[SW1-Vlanif10]vrrp vrid 1 priority 150
3、关闭抢占模式
	[SW1-Vlanif10]vrrp vrid 1 preempt-mode disable
4、跟踪上层端口
	[SW1]interface vlan 10
	[SW1-Vlanif10]vrrp vrid 1 track interface g0/0/24 reduced 60
5、配置接口的网络类型为Point-to-multipoint
	[R1]interface Serial 2/0/0
	[R1-Serial2/0/0]ospf network-type p2mp
6、查看VRRP信息
	[S1] display vrrp

八、HDLC

1、IP地址借用
	[R1-Serial1/0/0]ip address unnumbered interface LoopBack0
	[R1]ip route-static 10.1.1.0 24 Serial1/0/0
2、将接口改为HDLC类型
	[R1-Serial1/0/0]link-protocol hdlc

九、PPP

1、PAP/CHAP认证
	认证方:	[R1]aaa
	        [R1-aaa]local-user huawei password cipher 123456
	        [R1-aaa]local-user huawei service-type ppp
            [R1-Serial0]ppp authentication-mode pap(CHAP)
	被认证方:
		PAP:
	             [R2-Serial0]ppp pap local-user huawei password cipher 123456 
		CHAP:
	             [R2-Serial0]ppp chap user huawei
                         [R2-Serial0]ppp chap password cipher 123456
2、使用 CHAP 建立 PPP连接的协商过程
	debugging ppp chap all
	terminal debugging

十、以太网接口

1、将接口设置为100M速率和全双工模式
	[S1]int g0/0/9
	[S1-GigabitEthernet0/0/9]undo negotiation auto	//更改接口的速率和双工模式前应先关闭接口的自动协商功能
	[S1-GigabitEthernet0/0/9]speed 100
	[S1-GigabitEthernet0/0/9]duplex full	
2、查看Eth-trunk 1配置结果
	[S1]dis eth-trunk 1

十一、STP

1、修改桥优先级
	[S1]stp priority 4096		//数值越小优先级越高
2、修改端口优先级
	[S1-GigabitEthernet0/0/9]stp port priority 32	//默认为128,数值越小优先级越高
3、配置边缘端口(使端口快速进入转发状态)
	[S3]interface Ethernet0/0/3
	[S3-Ethernet0/0/3]stp edged-port enable
4、查看
	各接口简要STP状态
	[S1]dis stp brief
	具体接口详细STP信息
	[S1]dis stp interface g0/0/10
	查看当前根桥信息
	[S1]dis stp
	查看实例1的信息
	[SW1]dis stp instance 1 brief
5、设置路径开销值
	[S3-Ethernet0/0/3]stp cost
6、设置延迟时间
	[根交换机]stp timer forward-delay
7、设置网络直径
	[根交换机]stp edged-port enable
8、配置MSTP
	[SW1]stp region-configuration		//进入MST域
	[SW1-mst-region]region-name huawei	//配置域名
	[SW1-mst-region]revision-level 1	//配置修订级别为1
	[SW1-mst-region]instance 1 vlan 10	//制定MSTI 1与VLAN10的映射

十二、防火墙

1、登录不需要用户名和密码
	[FW]user-interface console 0
	[FW-ui-console0]authentication-mode none
2、定义时区:
	clock timezone 1 add 08:00:00

十三、自动保存配置

1、自动保存
	autosave interval on
	autosave interval 120	//每隔120分钟自动保存
2、定点保存
	autosave time on
	autosave time 23:00:00	//到23点自动保存
PS:两种方式不能共存

十四、端口镜像

1、设置观察端口
	[R1]observe-port 1 interface Ethernet4/0/1
2、将镜像端口映射到观察端口
	[接口] mirror to observe-port 1 both

十五、端口绑定

1.绑定MAC地址(可以绑定多个MAC地址)
[Huawei]user-bind static mac-address 5489-988B-5157 interface e0/0/1 
2.绑定IP地址
[Huawei]user-bind static ip-address 192.168.1.3

十六、端口安全

[接口]port-security enable			//启用端口安全
[接口]port-security max-mac-num 2	//自动学习MAC地址的最大数量
[接口]port-security protect-action shutdown	//保护行为为关闭端口

十七、配置前缀列表(在RIP里面过滤掉11.1.1.0/25)

[R1]ip ip-prefix 1 deny 11.1.1.0 25 greater-equal 25 less-equal 25
[R1]ip ip-prefix 1 permit 0.0.0.0 0 less-equal 32
[R1-rip-1]filter-policy ip-prefix 1 import

十八、DHCP

1、基于接口配置DHCP功能
	[R1]dhcp enable 	//开启DHCP功能
	[R1-GigabitEthernet0/0/0]dhcp select interface		//开启接口DHCP功能
	[R1-GigabitEthernet0/0/0]dhcp server lease day 2【可选】	//设置租用有效期限为2天
	[R1-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8	//为PC自动分配DNS服务器地址
	[R1-GigabitEthernet0/0/1]dhcp server excluded-ip-address 192.168.2.250 192.168.2.253	//配置不参与自动分配的IP地址范围
2、基于全局配置DHCP
	[R1]dhcp enable 	//开启DHCP功能
	[R1]ip pool huawei1	//配置全局地址池
	[R1-ip-pool-huawei1]network 192.168.1.0		//指定地址池范围
	[R1-ip-pool-huawei1]lease day 2【可选】		//租期为2天,默认1天
	[R1-ip-pool-huawei1]gateway-list 192.168.1.254	//出口网关地址
	[R1-ip-pool-huawei1]excluded-ip-address 192.168.1.250 192.168.1.253//不参与自动分配
	[R1-ip-pool-huawei1]dns-list 8.8.8.8		//配置DNS服务器地址
	[R1-GigabitEthernet0/0/0]dhcp select global 	//开启接口的DHCP功能
3、配置DHCP中继
	[R1]dhcp enable
	面向PC的接口:
		[R1-Ethernet0/0/0]dhcp select relay
		[R1-Ethernet0/0/0]dhcp relay server-ip 100.1.1.1  //指定DHCP服务器IP地址
	面向PC的接口下调用全局定义的DHCP服务器组:
		[R1]dhcp server group dhcp-group
		[R1-dhcp-server-group-dhcp-group]dhcp-server 100.1.1.1
		[R1-Ethernet0/0/0]dhcp select relay 
		[R1-Ethernet0/0/0]dhcp relay server-select dhcp-group
2、查看
	dis ip pool 	//查看地址池地址分配情况

十九、IPv6

1、基础配置
	[R1]ipv6	//开启全局IPv6功能
	[R1-Ethernet0/0/0]ipv6 enable 	//在接口(连接PC)下开启IPv6功能
	[R1-Ethernet0/0/0]ipv6 address auto link-local 		//自动生成链路本地地址
	[R1-GigabitEthernet0/0/0]ipv6 enable		//在接口(连接路由器)下开启IPv6功能
	[R1-GigabitEthernet0/0/0]ipv6 address 2031:0:130F::1 64		//配置全球单播地址
2、用EUI-64配置地址
	[R1-Ethernet0/0/0]ipv6 address 2001:3:FD:: 64 eui-64

二十、链路技术

1、链路聚合
	[S1]interface Eth-Trunk 1	//聚合交换机之间的Eth-Trunk端口编号相等
	[S1-Eth-Trunk1]mode manual load-balance 	//默认开启
	[S1-Eth-Trunk1]trunkport g0/0/1		//将成员端口加入到聚合端口中
	[S1-Eth-Trunk1]port link-type trunk 
	[S1-Eth-Trunk1]port trunk allow-pass vlan 1000
	[S1-Eth-Trunk1]dis eth-trunk 1 verbose	//查看聚合端口的信息
2、Smart Link
	[S1-GigabitEthernet0/0/1]stp disable	//关掉相关接口的STP
	[S1]smart-link group 1
	[S1-smlk-group1]port GigabitEthernet 0/0/1 master 	//设置主端口
	[S1-smlk-group1]port g0/0/2 slave	//设置从端口
	[S1-smlk-group1]flush send control-vlan 10 password simple 123
	[S1-smlk-group1]restore enable		//开启回切功能
	[S1-smlk-group1]timer wtr 30		//回切时间为30秒
	[S1-smlk-group1]smart-link enable	//使能Smart Link组1的功能
	[S1-smlk-group1]dis smart-link group 1	//查看Smart Link组1的信息
	[S2-GigabitEthernet0/0/1]smart-link flush receive control-vlan 10 password simple 123	//设置其他交换机可以接收和处理携带控制VLAN编号是10的Flush帧

你可能感兴趣的:(网络)