huawei命令

vlan
动态vlan (GVRP)
gvrp inter g 0/0/1 gvrp
静态路由
ip route-static 0.0.0.0 0.0.0.0 192.168.1.2
ip route-static 目的地址 反掩码 下一跳
端口
设置双工属性
inter gig 0/0/1 duplex full //全双工 duplex half //半双工
流量控制功能
inter gig 0/0/1 flow-control 开启流量控制功能后,如果本端交换机发生拥塞,它将向对端交换机发送消息,通知对端交换机暂时停止发送报文
速率
inter gig 0/0/1 auto speed 10/100/1000
端口环回口监测功能
loopback-detect enable //开启环回口监测 inter gig 0/0/1 loopback-detect enable //端口里开启环回口检测
发送环回数据包的时间间隔
loopback-detect packet-interval 5 //发送环回数据包时间间隔为5秒
链路聚合
inter eth-trunk1 trunkport GigabitEthernet 0/0/1 to 0/0/3 将接口加入
eth-trunk mode lacp-static //为静态模式
inter gig 0/0/1 lacp priority 100 //优先级 优先级越小为主动端 也可以
inter g0/0/1 eth-trunk 1
配置链路聚合组活动接口数目的上限阈值。
max active-linknumber
开启链路抢占模式
要在链路聚合组放到直连端口里之前配置 mode lacp-static
链路聚合最大运行两条链路
max active-linknumber 2
端口安全
端口隔离
实现l2隔离
interface GigabitEthernet0/0/1
port-isolate enable group 1
interface GigabitEthernet0/0/2
port-isolate enable group 1
更改三层隔离
port-isolate mode L3
单向端口隔离配置(仅支持L2层隔离,L3层隔离是双向隔离)
port-isolate mode L2
interface GigabitEthernet0/0/1
am isolate g0/0/2 阻止g0/0/1向g0/0/2发送数据,但允许g0/0/2发来的报文,只收不发。
限制最大mac地址
要在开启端口安全之前打
interface GigabitEthernet 0/0/1
mac-limit maximum 5 //限制最大学习5个mac地址 如果是0 的话表示没有限制
超过最大mac地址限制报警
mac-limit maximum 5 alarm enable
打开端口安全
port-security enable
限制安全mac最大数
port-security max-mac-num 9
mac地址老化时间
port-security aging-time 300
生成树
stp enable
MSTP
stp mode mstp //配置成mstpmos
stp region-configuration //进入mstp配置模式
region-name huawei //配置域名huawei
revision-level 1 //修订等级
instance 1 vlan 10 //将vlan10加入实例1
instance 2 vlan 20 //将vlan20 加入实例2
active region-configuration //激活配置
stp instance 1 root primary //将此交换机实例1设置为主根
stp instance 2 root secondary //将此交换机实例2设置为备根
stp instance 1 priority 0-61440
将端口设置为边缘端口
sw1 inter g0/0/4 stp edged-port enable
最大条数
stp max-hops 7
rstp
stp mode rstp
配置根桥
stp root primary
配置备份根桥
stp root secondary
端口路径开销为华为计算方法
stp pathcost-standard legacy
开启bpdu保护
stp bpdu-protection
设置边缘端口
interface ethernet 0/0/2 stp edged-port enable
VRRP
sw1 inter vlanif 10 ip add 10.1.1.210 24
vrrp vrid 1 virtual-ip 10.1.1.254 //备份组号1 虚拟ip地址
vrrp vrid 1 priority 120 //配置备份组的优先级 优先级越高,越会成为master设备。默认优先级是100 inter vlan 20
ip add 10.1.2.220 24
vrrp vrid 2 virtual-ip 10.1.2.254
sw2
inter vlanif 20
ip add 10.1.2.120 24
vrrp vrid 2 vir 10.1.2.254
vrrp vrid 2 pri 120
inter vlan 10
ip add 10.1.2.110 24
vrrp vrid 1 vir 10.1.1.254
上行链路检测
vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 21 //检测上行链路出现故障,将本机的优先级减少21
堆叠
stack port interface g0/0/28 enable //开启指定端口的堆叠端口功能
stack port interface g0/0/27 enable //开启指定端口的堆叠端口功能
interface stack-port0/1 //创建堆叠端口1
port member-group interface g0/0/28 //将端口g0、0/28加入到堆叠端口1
quit
interface stack-port0/2 //创建堆叠端口2
port member-group interface g0/0/27 //将端口g0/0/27加入到堆叠端口2
quit 配置堆叠优先级
stack slot 0 priority 200 //堆叠id为0的优先级为200 ,默认优先级是100 优先级越大越优先
stack slot 0 reunmber 0 //修改swa堆叠ID为0 ,默认为0 堆叠配置完成后保存配置,并重启交换机 save reboot
DHCP
dhcp enable //打开dhcp动能 ip pool vlan10 //新增地址池名称 gateway-list 192.168.1.254 //设置网关 network 192.168.1.0 mask 255.255.255.0 //设置地址段 excluded-ip-address 192.168.1.200 192.168.1.253 //可以设置排除ip范围 lease day 5 //设置获取ip地址的有效期为5天 dns-list 114.114.114.114 //设置客户机DNS
DHCP中继
R1
dhcp enable
ip pool vlan10
network 192.168.10.0 mask
255.255.255.0
gateway-list 192.168.10.254
dns-list 1.1.1.1
lesae day 3
inter g0/0/0 //进入于下行交换机互联接口
dhcp select global //本地设备设置为dhcp服务器
ip route-static 0.0.0.0 0.0.0.0 192.168.88.66 //下一跳为交换机的直连地址
sw-1 inter vlan 10 dhcp select relay //开启中继服务
dhcp relay server-ip 192.168.88.88 //dhcp服务器地址
ssh
rsa local-key-pair create //生成密钥
aaa local-user huawei password cipher admin //创建用户和密码,并且密码是密文
local-user huawei privilege level 3 //用户等级为3
local-user huawei service-type ssh //服务类型为
ssh stelnet server enable //使能(开启)SSH服务
ssh user huawei authentication-type password //用户的验证类型为密码验证
ssh user huawei service-type stelnet //服务类型为
ssh user-interface vty 0 4 //进入0到4线路
authentication-mode aaa //验证模式为
aaa protocol inbound ssh //允许使用ssh协议 可选: ssh server port 1025 //修改ssh的端口为1025,默认为22
display rsa local-key-pair public

Smart link & monitor link
smart-link group 1 创建Smart Link 组1
smart-link enable 开启Smart Link组功能 配置Smart Link时,需要在相关运行Smart Link的接口下关闭生成树协议。
inter g0/0/3 stp disable smart-link group 1 port g0/0/3 mastter //配置e0/0/3为主接口
port e0/0/4 slave e0/0/4//为备份接口
display smart-link group 1 //查看Smart Link 组1的主备状态
monitor-link group 1 //启用monitor link组1
port e0/0/1 uplink //设置e0/0/1为上行接口
port e0/0/3 downlink //设置e0/0/3为下行接口
smart link 回切功能
smart-link group 1 restore enable 开启回切功能
timer wtr 30 设置定时器为30S
端口镜像
observe-port 1 interface
gigabitethernet 1/0/1
interface gigabitethernet 2/0/1
port-mirroring to observe-port 1
inbound/outbound //将2/0/1入方向的报文即接收到的报文复制到g0/0/1上
vrf
ip vpn-instance internet
route-distinguisher 1:1
vlan10
inter vlan 10
ip binding vpn-instance internet
lldp
全局
lldp enable
inter g0/0/3
lldp enable
lldp tlv-enable basic-tlv all
路由
管理
telnet
telnet的两台机器能互相ping通 r1 system-view sysname ar1ar1 super password cipher 123456 //设置密码 user-interface vty 0 4 //进入配置用户终端 authentication-mode password //回车后输入密码123456。 protocol inbound telnet //传入协议telnet user privilege level 10 //设置优先级 quit R2 telnet 192.168.1.1 用户和密码 user-inter vty 0 4 authe-mode aaa aaa local-user huawei password ci huawei2021 local-user huawei server telnet user - -
ssh
rsa local-key-pair create aaa local-user admin password cipher 123456 local-user admin service-type ssh stelnet server enable user-interface vty 0 4 authentication-mode aaa user privilege level 15 protocol inbound ssh ssh user admin ssh client first-time enable
SNMP
snmp-agent \开启SNMP Agent服务 snmp-agent sys-info version v3 snmp-agent mib-view View_ALL include iso \设置MIB视图参数View_ALL snmp-agent group v3 SNMPv3group privacy read-view View_ALL write-view View_ALL notify-view View_ALL \设置用户组 snmp-agent usm-user v3 SNMPv3user SNMPv3group authentication-mode sha Changeme_123 privacy-mode aes128 Changeme@123 \设置用户 snmp-agent target-host trap-paramsname SNMPv3ser v3 securityname SNMPv3user privacy \设置告警参数 snmp-agent target-host trap-hostname eSightServer address 192.168.3.100 trap-paramsname SNMPv3user \设置告警主机 snmp-agent trap enable \开启trap告警
查看路由表
display ip routing-table
VPN
GRE
R2: ip route-static 0.0.0.0 0 10.10.10.2 //加一条路由,使得两个公网IP互通 interface Tunnel0/0/0 //新建隧道 tunnel-protocol gre //隧道协议 source 10.10.10.1 //源地址 destination 10.10.20.1 //目标地址 ip add 192.168.254.1 24 //给隧道配置地址 quit ip route-static 192.168.12.0 255.255.255.0 192.168.254.2 //给隧道配置静态路由 需要注意的是:description(描述)和destination(目标地 址),很容易敲错。 R1 inter g0/0/1 ip add 10.10.10.2 24 inter g0/0/0 ip add 10.10.20.2 24 R3 ip route-static 0.0.0.0 0 10.10.20.2 interface Tunnel0/0/0 tunnel-protocol gre source 10.10.20.1 destination 10.10.10.1 ip add 192.168.254.2 24 quit ip route-static 192.168.11.0 255.255.255.0 192.168.254.1
ipsec
R1 ike proposal 1 encryption-algorithm 3des-cbc //指定加密算法 authentication-algorithm md5 //散列函数 authentication-method pre-share //认证方式为预共享密钥 dh group2 //DH组的长度为2 ike peer 200.0.0.1 v1 pre-shared-key simple hahui //带有文本的预共享密钥 ike-proposal 1 remote-address 200.0.0.1 //指定远程对等方的ip地址 quit acl number 3000 //创建acl编号 rule permit ip source 192.168.1.0 0.0.0.255 destination 10.0.0.0 0.0.0.255 //匹配感兴趣流 quit ipsec proposal 1 //配置ipsec安全协议 transform ah-esp //封装算法 quit ipsec policy hh 1 isakmp // 配置ipsec安全策略 security acl 3000 //匹配的感兴趣流 ike-peer 200.0.0.1 //对等体 proposal 1 //封装算法 q inter g0/0/0 ipsec policy hh //把ipsec调用到接口上 R3 ip route-static 0.0.0.0 0.0.0.0 200.0.0.2 ike proposal 1 encryption-algorithm 3des-cbc authentication-algorithm md5 authentication-method pre-share dh group2 q ike peer 100.0.0.1 v1 pre-shared-key simple hahui ike-proposal 1 remote-address 100.0.0.1 q acl number 3000 rule permit ip source 10.0.0.0 0.0.0.255 destination 192.168.1.0 0.0.0.255 q ipsec proposal 1 transform ah-esp q ipsec policy hh 1 isakmp security acl 3000 ike-peer 100.0.0.1 proposal 1 q inter g0/0/1 ipsec policy hh
路由
路由重发布
rip import-route ospf 1 //进入rip重发布ospf 1
RIP
rip version 2 //版本号rip2 (支持无类网络) undo summary //关闭自动汇总 network 1.0.0.0
OSPF
也可以直接ospf 1 不用跟router-id ospf 1 router-id 1.1.1.1 //进程号 router id area 12 //进入area区域 network 192.168.1.0 0.0.0.255 network 192.168.12.0 0.0.0.255 display ospf peer brief //查看ospf邻居
区域认证
只有一方配置了认证会导致邻居终端,要两边验证模式和一致 ospf 1 area 1 authentication-mode authentication-mode simple plain huawei1 //区域认证为简单模式 并配置plain参数。配置plain参数后,可以使得在查看配置文件时,口令均以明文方式显示。 dis this //查看ospf下配置 authentication-mode simple plain huawei1 //明文方式显示口令 authentication-mode simple huawei1 //没有plain authentication-mode simple cipher %%/F~SKKaTeX parse error: Expected ‘EOF’, got ‘#’ at position 1: #̲~h"😡!s<^Dpw1)8…%$ //口令密文形式显示
链路认证
int g 0/0/1 ospf authentication-mode md5 1 huawei5 //配置链路认证,MD5验证模式,标识符1,口令huawei5 一边配置会导致识别失败,要两边验证模式,标识符,口令保持一致)都配置后邻居又重新起来 同时配置接口认证和区域认证,会优先使用接口验证建立OSPF邻居
nssa
ospf 100 area 1 nssa nssa no-summary
totally stub
ospf 1 area 0 stub no-summary
BGP
ibgp
ibgp用lookback 地址建立邻居 bgp 100 router-id 7.7.7.7 peer 8.8.8.8 as-number 100 peer 8.8.8.8 connect-interface LoopBack0 //更新发送bgp报文的接口为lookback接口 network 1.1.1.1 32 用直连接口建 bgp 100 router-id 1.1.1.1 peer 10.0.12.2 as-number 200 //和邻居网络建立邻接关系 network 1.1.1.1 32 //宣告虚拟接口网络
EBGP
bgp 100 router-id 1.1.1.1 peer 192.168.1.2 as-number 200 network 1.1.1.1 32 bgp 200 router-id 2.2.2.2 peer 192.168.1.1 as-number 100 network 2.2.2.2 32 ebgp用lookback 地址建邻居 bgp 13 router-id 1.1.1.1 peer 2.2.2.2 as-number 24 与AR2建立ebgp邻居 peer 2.2.2.2 ebgp-max-hop 2 ebgp邻居允许的最大跳数修改为2(因为不是直连而是用loopback0接口) peer 2.2.2.2 connect-interface LoopBack0 更新发送bgp报文的接口为loopback0接口
选路
本地优先级
从R4去往R1的路由从R2改走R3 route-policy lop permit node 10 //创建名为lop的路由策略 Info: New Sequence of this List. apply local-preference 222 //设置本地优先级为222 quit //保存退出 bgp 200 //进入bgp 200 peer 10.0.34.1 route-policy lop export //应用策略 quit //保存退出 quit //退出到用户视图 reset bgp all //刷新路由属性 本地优先级越大越优先
MED
如果希望R1去往R4的路由改走R3,可以使用MED属性控制R1的路由选路,使R1去往R4从R2改走R3。默认情况下R1去R4的4.4.4.4走R2。通过在R2上修改MED属性并传出给R1,可以使R1去往R4的路由改走R3。 route-policy med permit node 10 //创建名为med的路由策略 Info: New Sequence of this List. apply cost + 500 //设置路由开销为500 quit //保存退出 bgp 200 //进入bgp200 peer 10.0.12.1 route-policy med export //应用策略 quit //保存退出
RR(路由反射器)
bgp 200 peer 193.1.1.2 reflect-client peer 194.1.1.2 reflect-client quit
bgp邻居认证
bgp 65000 peer 10.10.10.1 password cip/sim 123456
as-path-acl
ip as-path 1deny _200 创建一个AS路径列表1,且设置规则拒绝所有200AS始发的路由 ip as-path 1permit * 不要忘记,写这条放行其它所有路由 route-policy 1 deny node 0 //创建route-policy if-match as-path 1 bgp 300 peer 34.34.34.2 route-policy 1 import
is-is
isis network-entity 49.0000.0030.0300.3003.00 is-level level-2 ###骨干区域设为L2路由 int g0/0/0 ####进接口启动协议 is en int g0/0/1 is en
静态路由
ip route-static 192.168.1.0 255.255.255.0 192.168.20.1
ACL
acl number 2000 //创建acl 2000 rule deny source 192.168.10.1 0 //拒绝源地址为192.168.10.1 的流量 int gi 0/0/1 traffic-filter outbound acl 2000 //接口下出方向调用acl 2000 拒绝所有的报文 acl number 3006 rule 5 deny ip 在ospf里调用acl ospf 1 filter-policy 2000 import //把acl调用到收方向
路由策略(route-policy)
route-policy StoO permit node 10 // StoO为命名;node 10 为节点 if-match interface GigabitEthernet0/0/0 apply cost 15 // 修改cost值 apply cost-type type-1 // 类型为1型 在ospf中引入路由策略: [R2-ospf-1]import-route direct route-policy StoO //direct为直连
策略路由(traffic-policy)
acl 3000 rule 5 permit source 10.1.1.0 0.0.0.255 dest 10.1.3.0 0.0.0.255 traffic classifie huawei-control1 //创建流分类 命名huawei-control1 if-match acl 3000 quit traffic behavior huawei-control1 //创建流动作 命名huawei-control1 rdirect ip-nexthop 12.1.1.2 //定义下一跳 traffic policy huawei-control1 //创建策略路由 classifier huawei-control behavior huawei-control1 //关联流分类和流动作 inter g0/0/2 traffic-policy huawei-control1 inbound //
policy-based-route
policy-based-route pbr perm node 5 if-match acl 2001 apply ip-add next-hop policy-based=route pbr per node 10 ip local policy-based-route pbr
ip-prefix list
ip ip-prefix test index 10 permit 10.0.0.0 16 greater-equal 24 less-equal 28 //ip前缀列表为test 最短24掩码 范围 和最长的掩码范围 24<=掩码长度<=28
串口
PPP
ppp认证
PAP
R1 为PAP认证方 AAA LOCAL-USER hst password cipher 123 //配置一个本地用户hst LOCAL-USER HST service-type PPP //这个用户的服务类型为ppp INT S 2/0/0 link-protocol PPP //在华为S接口默认二层协议是PPP IP address 10.0.0.1 30 PPP authentication-mode PAP // 端口验证模式为PAP认证 R2 为PAP被认证方 INT S2/0/0 IP ADDRESS 10.0.0.2 30 ppp pap local-user hst password cipher 123 //在接口上配置一个本地认证用户hst
chap
R1为CHAP主认证方 int s 2/0/0 ppp chap user sss ppp chap password cipher 123 ppp authentication chap R3 为chap被验证方 aaa local-user sss password cipher 123 local-user sss service-type ppp INT S 2/0/0 PPP authentication-mode CHAP
mp-group
interface mp-group0/0/0 ip add 10.18.1.190 30 interface serial 0/0/1 link-protocol ppp ppp mp mp-group 0/0/0
ACl
acl 2000 #定义基本策略 rule 0 deny source 172.30.1.1 0.0.0.0 #写一条拒绝的规则 quit traffic classifier deny_icmp #创建策略 if-match acl 2000 #和条件绑定 quit traffic behavior deny #创建一个策略的动作, quit traffic policy xianzhi #创建一个策略组 classifier deny_icmp behavior deny #关联策略和动作 quit interface Ethernet 0/0/1 traffic-policy xianzhi inbound #在相应的如接口调用策略组
NAt
######静态NAT:一个私网IP地址对应一个公网IP地址 [R1]nat static global 8.8.8.8 inside 192.168.10.10 //全局模式下 [R1]int g0/0/1 [R1-GigabitEthernet0/0/1]nat static enable //在外网接口上启动nat static功能 ######配置默认路由出去 [R1]ip route-static 0.0.0.0 0.0.0.0 12.0.0.2 ######配置回环接口的静态路由 ip route-static 114.114.114.114 255.255.255.255 12.0.0.2 #######动态NAT:多个私网IP地址对应多个公网IP地址 [R1]nat address-group 1 212.0.0.100 212.0.0.200 //新建为1的nat地址池 [R1]acl 2000 // ac1编号 [R1-acl-basic-2000]rule permit source 192.168.20.0 0.0.0.255 //抓取要转换的网段 [R1-acl-basic-2000]int g0/0/1 //进入外网接口 [R1-GigabitEthernet0/0/1]nat outbound 2000 address-group 1 no-pat //使用outbound命令将acl 2000与地址池关联,使得acl中固定的地址,可以使用地址 ######EasyIp:多个私网IP地址对应外网口公网IP地址(12.0.0.1) [R1]acl 3000 [R1-acl-adv-3000]rule permit ip source 192.168.30.0 0.0.0.255 [R1-acl-basic-2000]int g0/0/1 //进入外网接口 [R1-GigabitEthernet0/0/1]nat outbound 3000
ppp
chap
aaa 进入认证端的AAA配置 local-user guest password cipher 123456 增加被认证端的用户名及密码 local-user guest service-type ppp 配置此用户的服务类型为PPP interface Serial 1/0/0 进入认证端的串口 link-protocol ppp ppp authentication-mode chap 配置认证端的接口认证模式为chap ppp chap user guest 配置被认证端接口chap认证方式的用户名 ppp chap password cipher 123456 配置被认证端接口chap认证方式的密码
单臂路由
Router B interface GigabitEthernet0/0/0.200 dot1Qtermination vid 200 ip address 10.0.12.2 255.255.255.0 arp broadcast enable
防火墙
pc机tracert过去到防火墙没有回应成星号,使防火墙做出回应
icmp ttl-exceeded send

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值