华为交换路由命令合集

举报
柳ioi 发表于 2022/07/10 23:27:34 2022/07/10
【摘要】 u t mundo info-center enable #关闭消息中心undo ter mo #关闭日志打印<R1>di ip rou p ospf #查看ospf[R1]di ospf interface #接口通告[R1]di ospf peer #邻居状态<R1> di c int #查看端口 VLAN部署 1,创建vlan<Huawei>...
u t m
undo info-center enable 	#关闭消息中心
undo ter mo					#关闭日志打印
<R1>di ip rou p ospf 	#查看ospf
[R1]di ospf interface 				   #接口通告
[R1]di ospf peer					  #邻居状态

<R1>   di c int		#查看端口

VLAN部署

1,创建vlan

<Huawei>system-view
[Huawei]sysname SW1
[SW1]vlan batch 10 20 30#创建多个vlan

2,端口

[SW1]int eth0/0/01
[SW1-Ethernet0/0/1]port link-type access	#类型
[SW1-Ethernet0/0/1]port default vlan 10		#加入到vlan10中

3,查看vlan信息

[SW1]dis vlan

STP

image-20210606162302836

1,进入多个端口

[SW1]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/3
[SW1-port-group]port link-type trunk

[SW1-port-group]port trunk allow-pass vlan 10

[SW1-port-group]quit

2,开启STP

[SW1]stp enable
[SW1]stp mode stp

3,配置STP优先级

将SW1配置为主根交换机,SW2为备份根交换机。

第一种方法:
SW1的优先级改为0,SW2的优先级改为4096
①SW1的配置:
[SW1]stp priority 0
②SW2的配置:
[SW2]stp priority 4096

第二种方法:
首先删除在SW1上所配置的优先级,使用stp root primary 命令配置主根交换机。
SW1的配置:
[SW1]undo stp priority
[SW1]stp root primary 
删除在SW2上所配置的优先级,使用stp root secondary命令配置备份根交换机
SW2的配置:
[SW2]undo stp priority
[SW2]stp root secondary
forwarding:转发状态。
learning:学习状态,能收到流量(用户流量和mac地址),不能转发
listening:侦听状态,可以转发报文,不能转发用户流量
blocking:处理,不能转发,可以理解预备端口
disabled:堵塞状态
15秒变化时间

RSTP

image-20210606162242335

image-20211104095103031

rstp 边缘端口不加入计算

1,开启rstp

[SW1]stp mode rstp 

2,配置RSTP优先级

SW1配置化为主根交换机,SW2为备份根交换机。
方法 1
SW1的优先级改为0SW2的优先级改为4096
SW1的配置
[SW1]stp priority 0
SW2的配置
[SW2]stp priority 4096

方法 2
首先删除在SW1上所配置的优先级,使用stp root primary命令配置主根交换机。
SW1的配置
[SW1]undo stp priority
[SW1]stp root primary 
删除在SW2上所配置的优先级,使用stp root secondary命令配置备份根交换机
[SW2]undo stp priority
[SW2]stp root secondary

3,配置边缘端口

[SW3]interface Ethernet0/0/10
[SW3-Etherneto/0/10]stp edged-port enable

[SW4]interface Ethernet0/0/10
[SW4-Etherneto/0/10]stp edged-port enable

MSTP

1,

image-20211021153554956

[sw1]stp enable 	#打开stp
[sw1]stp mode  mstp 	#stp模式为mstp
[sw1]stp region-configuration #配置MSTP
[sw1-mst-region]region-name RG1	#设置域名
[sw1-mst-region]instance 1 vlan 1 to 10	#创建实例1映射为vlan1-10
[sw1-mst-region]instance 2 vlan 2 to 20	#创建实例2映射为vlan11-20
[sw1-mst-region]active region-configuration 	#激活配置
Info: This operation may take a few seconds. Please wait for a moment...done.

image-20211021153622739

[sw1]stp instance 1 root primary 
[sw1]stp instance 2 root secondary 

image-20211021153649855

https://blog.csdn.net/qq_45631844/article/details/109893396

OSPF

1,单区域配置

[R1]ospf 1 
[R1-ospf-1]area 0 
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 
[R1-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255 
[R1-ospf-1-area-0.0.0.0]network 30.30.30.0 0.0.0.255 

2,查看

[R1]display ospf interface 				   #接口通告
[R1]display ospf peer					  #邻居状态
[R1]display ip routing-table protocol ospf 	#路由表

静态路由

1,

[R1]ip route-static 10.10.10.0 24 30.30.30.10 #静态路由

默认路由与浮动路由

1,

[R1]ip route-static 0.0.0.0 0.0.0.0 30.30.30.10 	#添加默认路由
[R1]ip route-static 10.10.10.0 24 30.30.30.10 p 100 #浮动路由(用于备份)

VLANNIF

1,

配置 vlanif 接口
[SW1]interface Vlanif 10 
[SW1-Vlanif10]ip add 192.168.1.1 24 

[SW1]interface Vlanif 20 
[SW1-Vlanif20]ip add 192.168.2.1 24 

VRRP的ISP双出口备份链路

1,配置VRRP协议

[R1]interface G0/0/0 
[R1-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254 
#创建一个VRRP备份组,组号1,虚拟ip192.168.1.254
[R1-GigabitEthernet0/0/0]vrrp vrid 1 priority 110	
#R1优先级为110,R2优先级默认(100)这样R1成为master,R2为backup
[R1-GigabitEthernet0/0/0]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 60
#配置上行接口监视,监视g0/1,当此接口断掉时,裁剪优先级60,使得优先级为50,小于R2的优先级100

[R2]interface GigabitEthernet 0/0/0 
[R2-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254

2,查看

[R1]display vrrp		#查看vrrp信息
PC>tracert 100.200.30.1	#跟踪数据包走向
https://blog.csdn.net/quexiyi8051/article/details/89073012?spm=1001.2014.3001.5501

VRRP的负载均衡出口链路

1,VRRP协议

#(网关指向vrrp虚拟ip,)
[R1]interface G0/0/0 
[R1-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.253#vrrp1虚拟ip253,备用为R2的端口
[R1-GigabitEthernet0/0/0]vrrp vrid 1 priority 110#R1优先级调高,走R1,R1断了走R2
[R1-GigabitEthernet0/0/0] vrrp vrid 2 virtual-ip 192.168.1.254#vrrp2,R1备用
[R1-GigabitEthernet0/0/0]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 60#监视端口,裁剪60优先级

[R2]interface GigabitEthernet 0/0/0 
[R2-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.253#vrrp1,作为R1的备用端口
[R2-GigabitEthernet0/0/0]vrrp vrid 2 virtual-ip 192.168.1.254#vrrp2虚拟ip,备用端口为R1
[R2-GigabitEthernet0/0/0] vrrp vrid 2 priority 110 	#vrrp2,R2的优先级高,走R2R2断走R1
[R2-GigabitEthernet0/0/0] vrrp vrid 2 track interface GigabitEthernet0/0/1 reduced 60#监视端口,裁剪60优先级

链路聚合

(两种模式)

1,手动模式

[SW1]interface Eth-Trunk 1#创建trunk接口,组号为1
[SW1-Eth-Trunk1]mode manual load-balance#指定为手动负载分担模式
[SW1-Eth-Trunk1]port link-type trunk#设置trunk
[SW1-Eth-Trunk1]port trunk allow-pass vlan 10 20#华为默认拒绝所有vlan通过,需要放行vlan
[SW1-Eth-Trunk1]quit
[SW1]interface GigabitEthernet 0/0/1
[SW1-GigabitEthernet0/0/1] eth-trunk 1#将端口加入到接口
[SW1]interface GigabitEthernet 0/0/2
[SW1-GigabitEthernet0/0/2] eth-trunk 1
[SW1-GigabitEthernet0/0/2]quit

#对端也要设置
[SW2]interface Eth-Trunk 1
[SW2-Eth-Trunk1]mode manual load-balance
[SW2-Eth-Trunk1]port link-type trunk
[SW2-Eth-Trunk1]port trunk allow-pass vlan 10 20
[SW2-Eth-Trunk1]quit
[SW2]interface GigabitEthernet 0/0/1
[SW2-GigabitEthernet0/0/1] eth-trunk 1
[SW2]interface GigabitEthernet 0/0/2
[SW2-GigabitEthernet0/0/2] eth-trunk 1
[SW2-GigabitEthernet0/0/2]quit

#查看
[SW1]display eth-trunk 1

2,lacp

image-20211019144029911

SW1
[sw1]lacp priority 1	#LACP优先级设置为1,他将成为Eth-trunk链路协商时的主动端,sw2的设备LACP优先级保持缺省32768,该值越小越优先
[sw1]int e 1 	#创建链路聚合1
[sw1-Eth-Trunk1]mode lacp-static #设置工作在静态LACP,
[sw1-Eth-Trunk1]max active-linknumber 2	#最大活跃链路设置为2
[sw1-Eth-Trunk1]trunkport GigabitEthernet 0/0/3 to 0/0/4 0/0/5	#将3,4,5,加入链路组
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw1-Eth-Trunk1]po li t 	#设置trunk
[sw1-Eth-Trunk1]po t a v 10 20	#放行vlan10,20

SW2
[sw2]int e 1	
[sw2-Eth-Trunk1]mode lacp-static	#sw2的链路聚合接口工作方式需要与sw1相匹配
[sw2-Eth-Trunk1]trunkport GigabitEthernet 0/0/3 to 0/0/4 0/0/5	#加入端口
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2-Eth-Trunk1]po li t 
[sw2-Eth-Trunk1]po t a v 10 20

[sw1]display eth-trunk 1
查询可知,3 4 端口被选举(selected)为活跃端口,5为备份端口(Unselect)不转发数据。

PAP认证

1,ppp的pap认证

#R1作为认证端,需要配置本端的ppp协议的认证方式为pap
[R1]aaa #进入aaa视图
[R1-aaa]local-user Jan16 password cipher 123456 #设置一个账号密码
[R1-aaa]local-user Jan16 service-type ppp #它将作用于ppp协议
[R1-aaa]int s4/0/0
[R1-Serial4/0/0]link-protocol ppp #进入端口使用ppp协议
[R1-Serial4/0/0]ppp authentication-mode pap#ppp协议的认证方式为pap
#配置完成后,关闭R1与R2相连接口一段时间后再打开,使R1与R2间的链路重新协商,并检查链路状态和连通性。
[R1]interface Serial 4/0/0 
[R1-Serial4/0/0]shutdown #关闭
[R1-Serial4/0/0]undo shutdown #打开
[R1-Serial4/0/0]quit
[R1]display ip interface brief#查看端口的IP地址
[R1]ping 10.10.10.2#ping对端检查连通性

#对端配置 PAP 验证,R2作为被认证端,
[R2]int s4/0/0 
[R2-Serial4/0/0]link-protocol ppp 
[R2-Serial4/0/0]ppp pap local-user Jan16 password cipher 123456#在接口下配置以PAP方式验证时本地发送的PAP用户名和密码。

CHAP认证

1,ppp中的chap认证

#R1路由器作为认证端,需要配置本端PPP协议的认证方式为CHAP。
[R1]aaa #进入aaa视图
[R1-aaa]local-user Jan16 password cipher 123456 #创建账号密码
[R1-aaa]local-user Jan16 service-type ppp #作用于ppp认证
[R1]interface Serial 4/0/0 
[R1-Serial4/0/0]link-protocol ppp #使用ppp认证
[R1-Serial4/0/0]ppp authentication-mode chap#ppp协议认证方式为chap
#配置完成后,关闭R1与R2相连接口一段时间后再打开,使R1与R2间的链路重新协商,并检查链路状态和连通性。
[R1]interface Serial 4/0/0 
[R1-Serial4/0/0]shutdown #关闭
[R1-Serial4/0/0]undo shutdown#打开

#R2作为被认证端,在S4/0/0接口下配置以PAP方式验证时本地发送的CHAP用户名和密码。
[R2]int s4/0/0 
[R2-Serial4/0/0]link-protocol ppp#使用ppp认证 
[R2-Serial4/0/0]ppp chap user Jan16 #对端设置的账号
[R2-Serial4/0/0]ppp chap password cipher 123456#对端设置的密码

静态NAT

image-20210606162329662

1,静态NAT

在R1的G0/0/1接口下使用nat static命令配置内部地址到外部地址一对一转换。

[R1]interface GigabitEthernet 0/0/1 
[R1-GigabitEthernet0/0/1]nat static global 16.16.16.1 inside 192.168.1.1 

2,查看静态nat配置

<R1>display nat static

动态NAT

image-20210606162318481

1,配置NAT地址池,设置起始和结束地址分别为 16.16.16.1和16.16.16.5。

nat address-group 1 16.16.16.1 16.16.16.5

2,创建基本acl

acl 2000
rule permit source 192.168.10.0 0.0.0.255

3,关联地址池

在G0/0/1接口下使用nat outbound命令将ACL2000与地址池相关联,使得ACL中规定的地址可以使用地址池进行地址转换。

int G0/0/1
nat outbound 2000 address-group 1 no-pat

4,查看

nat outbound 信息

<R1>display nat outbound 

nat会话信息

<R1>display nat session all 

IPV6

1,端口设置ipv6

[R1]ipv6#全局下打开ipv6
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ipv6 enable#端口下打开ipv6
[R1-GigabitEthernet0/0/0]ipv6 address 2010::1/64#ipv6IP地址

2,ipv6静态路由

|[R1]ipv6 route-static 2020:: 64  2001::2

ACL

基本ACL

1,在交换机上配置 ACL 规则,允许数据包源网段为 192.168.30.0 的报文通过。将规则应用到 G0/0/2 的端口上。

[SW1]acl 2000
[SW1-acl-basic-2000]rule permit source 192.168.30.0 0.0.0.255
[SW1-acl-basic-2000]rule deny
[SW1]int G0/0/2
[SW1-GigabitEthernet0/0/2]traffic-filter outbound acl 2000

2,在交换机上配置 ACL 规则,拒绝数据包源网段为 192.168.40.0 的报文通过。将规则应用到 G0/0/1 的端口上。

[SW1]acl 2001
[SW1-acl-basic-2001]rule deny source 192.168.40.0 0.0.0.255
[SW1]int G0/0/1
[SW1-GigabitEthernet0/0/1]traffic-filter outbound acl 2001

高级ACL

1,在路由器上配置高级 ACL 规则,允许财务部 PC1 对服务器 80 端口的访问。将规则应用到 G0/0/1 的端口上。
[R1]acl 3000
[R1-acl-adv-3000]rule 5 permit tcp source 192.168.10.1 0 destination-port eq www#5为优先级,越小越先匹配
[R1-acl-adv-3000]rule 10 deny ip#10为优先级,越小越先匹配
[R1]int G0/0/1
[R1-GigabitEthernet0/0/1]traffic-filter outbound acl 3000

2,在路由器上配置高级 ACL 规则,拒绝财务系统服务器对外网的访问。将规则应用到G0/0/0 的端口上。
[R1]acl 3001
[R1-acl-adv-3001]rule 5 deny ip source 192.168.20.0 0.0.0.255
[R1-acl-adv-3001]rule 10 permit ip
[R1]int g0/0/0
[R1-GigabitEthernet0/0/1]traffic-filter outbound acl 3001

MPLS

简单配置:https://blog.csdn.net/qq_45089570/article/details/106104663
动态配置:https://blog.csdn.net/qq_48759664/article/details/109227581
VPN:https://blog.51cto.com/ccie23951/1673743
https://zhuanlan.zhihu.com/p/401031480
标签
#配置mpls
mpls
 lsp-trigger all  #将ldp lsp的触发策略修改为all
#只允许12.0网段路由通过
mpls ldp
inbound peer 3.3.3.3 fec ip-prefix prefix1
ip ip-prefix prefix1 index 10 permit 10.0.12.0 24 
#下发端口
interface Serial1/0/0
ip address 10.0.12.1 255.255.255.0 
mpls
mpls ldp

interface LoopBack0
ip address 2.2.2.2 255.255.255.0 
#
ospf 1 router-id 2.2.2.2 
area 0.0.0.0 
 network 10.0.1.0 0.0.0.255 
 network 10.0.12.0 0.0.0.255 
 network 2.2.2.0 0.0.0.255 

QOS

https://jingyan.baidu.com/article/9c69d48ff4fa3c13c8024e6e.html
https://blog.csdn.net/qq_45089570/article/details/106085981
限额

BFD

https://www.cnblogs.com/bjlssj/p/11757497.html
https://blog.csdn.net/weixin_45821358/article/details/104651334
备份静态路由

SDN

https://blog.csdn.net/muxia_jhy/article/details/109674829
(软件定义网络)

VXLAN

https://blog.csdn.net/meigeer2/article/details/106609616/

路由选路

https://jingyan.baidu.com/article/a3761b2b1169851576f9aac9.html

GER

隧道
https://blog.csdn.net/ZXW_NUDT/article/details/115480258

GRE voer IPSec

GRE隧道进行加密
https://blog.csdn.net/ZXW_NUDT/article/details/115481067
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

举报
请填写举报理由
0/200