网络工程师 华为配置命令复习
华为设备基础配置
点击查看代码
system-view # 系统模式
telnet server enable # 开启telnet功能
user-interface vty 0 4 # 允许0~4个p用户登入设备
// user-interface console 0 # 配置console用户登入
authentication-mode aaa # 认证模式为aaa , authentication-mode [aaa | password | none]
aaa #开启aaa
local-user user1 password cipher 123 #设置账号和密码
local-user user1 privilege level 3 # 用户等级
local-user usre1 server-type telnet #用户登入类型 telnet
quit
protocol inbound [all|telnent]# 配置vty支持telnet功能
return
save #保存配置
undo info-center enable #关闭提示中心
dis port vlan active #查看接口上的vlan
dis ip interface brief #查看接口上的ip
GVRP(Generic Vlan Registration Protocol) 通用vlan注册协议
点击查看代码
//GARP(Generic Attribute Registration Protocol)
syname R1
vlan batch 2 3
gvrp # 全局使用gvrp
interface g0/0/1
port link-type trunk # gvrp必须使用trunk口
port trunk allow-pass vlan all
gvrp # 接口使用gvrp
gvrp registration normal #gbrp注册模式为normal, 还有fixed、forbidden
STP(spanning tree protocol) 生成树协议
点击查看代码
sysname R1
stp mode stp
stp root primary # 设置R1为根交换机
sysname R2
stp root secondary #设置R2为根备用交换机
sysname R3
interface g0/0/1
stp cost 20000 #设置接口路径开销
stp edged-port enable # 配置接口为边缘接口
stp bpdu-filter enable #启用接口BPDU报文过滤
链路聚合
点击查看代码
sysname R1
interface eth-trunk 1 #创建eth-trunk1接口
trunkport g 0/0/1 to 0/0/2 #加入接口成员
port link-type trunk #配置eth-trunk1接口类型
port trunk allow-pass vlan all
quit
端口配置-端口隔离,速率设置
点击查看代码
// 端口隔离
port-isolate model [L2 | all] # 默认隔离2层,三层互通。
interface g0/0/1
port-isolate enable [group 1] # 接口隔离选择默认组1,相同组则隔离
interface g0/0/2
port-isolate enable [group 1]
// 速率设置
intface g0/0/1
negotiation auto
auto speed 100
VLAN配置
点击查看代码
vlan batch 10 20 30 # vlan 40
interface g0/0/0
port link-type access # trunk , hybrid
port default vlan 10 # port trunk allow-pass vlan all [10], port hybrid untagged vlan 10 [20] [30]
quit
vlan 10
mac-vlan mac-address 0000-1111-2222 # mac 和 vlan 关联
mac-vlan enable # mac-vlan开启
quit
interface vlanif 10 # vlanif 接口
ip address 192.168.1.1 24 # 配置vlan网关
quit
ACL
点击查看代码
time-range time1 9:00 2022/9/29 to 23:00 2023/9/30 #
time-range time2 9:00 to 23:00 working-day # daily、off-day
acl 2000 # 2000~2999 基本acl
rule perimit source 1.1.1.1 0.0.0.255 [timerange time1]#
acl 3000
rule permit [tcp|ip|udp] soruce 1.1.1.1 [0|0.0.0.255] destination 2.2.2.2 [0|0.0.0.255] eq [80|www|21|ftp] [timerange time2]
quit
interface g0/0/0
traffic-filter [inbound | outbound] acl 3000
掩码:IP地址、DHCP地址
反掩码:ACL、OSPF宣告
NAT
点击查看代码
// 静态NAT
sys
interface g0/0/0
ip address 1.1.1.1 24
nat static global 10.1.1.1 inside 1.1.1.2
// NAPT
nat address-group nat_group 1.1.1.10 1.1.1.20 #公网地址池
acl 2000
rule permit source 192.168.1 0.0.0.255 # 访问外网的内网主机网段
quit
interface g0/0/0
nat outbound 2000 address-group nat_group # address-group可以省略,则使用端口IP+端口号。no-pat:不使用端口
# nat outbound # 使用 接口的Ip+端口进行转换
// NAT Server,外网访问内网时,进行ip地址转换
nat server protocol tcp global 12.1.1.6 www inside 10.1.0.101 www # 端口号可以是:对应的协议,或者协议端口号
ipv6 over ipv4
点击查看代码
sys
ipv6 #全局开启ipv6
interface g0/0/0
ip addrss 1.1.1.1 24
quit
interface tunnel 0/0/0 # 进入隧道
tunnel-protocol ipv6-ipv4 auto-tunnel # 配置 ipv6 voer ipv4 隧道协议
ipv6 enable # 隧道启用ipv6
ipv6 address 1::1 64 # 隧道 ipv6地址
source g0/0/0 # 隧道接口绑定网卡口
quit
ip route-static 0.0.0.0 0 12.1.1.2
ipv6 route-static 2::1 64 tunnel 0/0/0
BFD
点击查看代码
// 配置vrrp 和 bfd
bfd bind 1 peer-ip 10.1.1.1 interface [g0/0/0 | vlanif10] [auto] source-ip 10.1.1.2// 对端ip,本地接口,auto: 自动配置标识符
discriminator local 10 # 本地标识符
discriminator remote 20 # 对端标识符
min-rx-interval 100 #最小接受时间间隔
min-tx-interval 100 #最小发送时间间隔
vrrp vrid 1 track bfd-session session-name 1 increased 40 //
// 静态路由和bfd
ip route-static 10.1.2.2 24 10.1.1.2 preference 50 track bfd-session 1 # 链路up时,静态路由生效,down时静态路由删去
//配置 rip 上所有接口
bfd #开启bfd
quit
rip 1 # 进入rip视图
bfd all-interfaces enable # 所有接口启动bfd
bfd all-interfaces min-rx-interval 100 min-tx-interval 100 detect-multiplier 10 # 设置最小接受、发送、检测时间等参数
QoS(Quality of Service,服务质量)
点击查看代码
// 创建一个流分类并进入流分类视图
traffic classifier classifier-name
if-match vlan-id 10
if-match acl 2000
// 创建一个流行为并进入流行为视图
traffic behavior
permit | deny
redirect ip-nexthop 10.1.1.1
car cir 2048 pir 4096 green pass yellow discard red discard #只承诺 2M 的带宽,可以突发到 4M,超过 4M 的全部丢弃, 单位kb
statistic enable #开启流量统计
//在流策略中为指定的流分类配置所需流行为,即绑定流分类和流行为;
traffic policy policy-name
[classifier classifier-name behavior behavior-name]*
//在接口、VLAN 或者系统视图下应用流策略;
traffic-policy policy-name [inbound | outbound]
//配置接口限速, CIR:承诺平均速率(单位:Kbps) CBS:承诺突发尺寸(单位:byte)BS:最大突发尺寸(单位:byte)
interface gigabitethernet 0/0/1
qos lr inbound cir 8192 # 在接口 GE0/0/1 的入方向上配置接口限速,保证带宽为 8192kbit/s。
//配置CAR模板car1设置其带宽限制为8Mbit/s,最高不超过10Mbit/s
qos car car1 cir 8192 pir 10240
interface gigabitethernet 1/0/1
qos car inbound car1 #在Switch的接口GE1/0/1、上行方向分别应用car1进行限速。
策略路由配置(PBR)
点击查看代码
sys
acl 3000
rele permit tcp
quit
policy-based-route pbr permit node 10
if-match acl 3000
apply ip-address next-hop 1.1.1.2
quit
ip local policy-based-route pbr
VRRP (Virtual Route Redundancy Protocol)
点击查看代码
sysname R1
interface g0/0/1
int address 192.168.1.1 255.255.255.0
vrrp vrid 10 virtual-ip 192.168.1.254 # VRRP组号为10,虚拟网关为192.168.1.254
vrrp vrid priority 200 # 优先级为200,默认为100,越大优先级越高
vrip vrid 10 preempt-mode timer delay 10 # 延迟抢占方式,延迟时间为10s
vrip vrid 10 preempt-mode disable # 采用非抢占方式
vrrp vrid 10 track interface g0/0/2 reduced 60 # 接口g0/0/2出现故障后,R1优先级减少60
DHCP配置
点击查看代码
sys
dhcp enable
ip pool ip_pool # dhcp地址池命名
network 192.168.1.0 mask 255.255.255 0 # dhcp地址池范围
gateway-list 192.168.1.1 # dhcp 网关地址
dns-list 192.168.1.1 # dhcp dns地址
excluded-ip-address 192.168.1.2 # dhcp 不分配地址
# excluded-ip-address 192.168.1.2 192.168.1.100 #排除192.168.1.2 到 192.168.1.100之内的地址
lease day 1 hour 1 min 30 # dhcp 租约时间
quit
interface g0/0/0
ip address 192.168.1.1 24
dhcp select global # 接口开启全局dhcp
//dhcp 中继
interface g0/0/1
dhcp select relay # 接口开启中继
dhcp relay server-ip 192.168.1.1 # dhcp 服务器地址
//dhcp 中继2
dhcp server group dhcpgroup1
dhcp-server 10.10.10.1
interface g0/0/0
dhcp select relay
dhcp relay server-select dhcpgroup1
// 配置dncp不过期
lease unlimited
// 配置dhcp的ip与mac地址绑定
static-bind ip-address 10.1.1.4 mac-address dcd2-fc96-e4c0
// 客户端配置dhcp
ip address dhcp-alloc
// 配置合法 DHCP 服务器的接口为信任接口
dhcp snooping enable
dhcp snooping trusted
静态路由
点击查看代码
ip route-static 192.168.5.0 255.255.255.0 192.168.4.0
ip route-static 192.168.5.1 24 192.168.4.0 # 主机路由
ip route-static 0.0.0.0 0 192.168.4.0 # 默认路由
ip route-static 0.0.0.0 0 192.168.4.0 preference 100 # 路由优先级为100,默认60,越高优先级越低
RIP, OSPF
点击查看代码
rip
version 2
undo summary
network 192.168.1.0
network 192.168.2.0
router id 1.1.1.1
ospf
area 0 # 区域0,表示骨干区域
network 192.168.1.0 0.0.0.255
quit
area 1
network 192.1682.20 0.0.0.255
quit
display ospf peer # 查看ospf 邻居
display ospf routing # 查看ospf 路由
IPSEC
点击查看代码
// 定义需要保护的数据流
acl number 3000
rule permit ip source 192.168.1.0 0.0.0.255 destination 192.168.2.0 0.0.0.255
// 配置IPSEC安全协议(封装模式、安全模式、加密、验证算法)
ipsec proposal tran1 # 创建安全提议tran1
encapsulation-mode tunnel [transport] #封装模式为隧道
transform esp [ah | ah-esp] #采用esp协议
esp encryption-algorithm aes 128 #采用AES加密算法
esp authentication-algorithm sha1 #采用sha1验证算法, ah authentication-algorithm [md5|sha2-256|sm3|..]
// 配置IKE对等实体
ike peer peer1
pre-shared-key 123456 # 配置预共享密钥为123456
remote-addrsss 3.3.3.3 # 配置对端实体
// 配置IPSEC安全策略
ipsec policy map1 10 isakmp #策略取名为map1
security acl 3000
proposal tran1
ike-peer peer1
// 接口上应用IPSEC策略
interface g0/0/1
ipsec policy map1
isis
点击查看代码
isis
network-entity 10.0000.0000.0001.00 # 宣告本路由网络实体
quit
interface g0/0/0
isis enable
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix