dispaly version 显示系统软件版本及硬件信息 system-view 切换到系统视图 quit 返回 interface +接口 进入接口视图 ip address +IP +mask 配置IP和子网掩码 return 返回用户视图 <Ctrl+Z> 返回用户视图 sysname R1 修改路由器名称为R1 clock timezone BJ add 08:00:00 设置所在的时区为北京 clock datetime 11:23:24 2019-4-9 修改系统日期和时间为2019年4月9日11点23分24秒 header login information “hello” 设置登录时的标题文本为hello header shell information “Welcom” 设置设备登陆成功后的标题文本信息为“Welcome” display current-configuration 查看路由器当前配置 dispaly interface +接口 查看路由器接口的状态信息 save 保存当前配置 display ip interface brief 查看接口与IP相关摘要信息 display ip routing-table 查看路由表
获取该命令视图下所有的命令及其简单描述 interface ? 列出interface全部关键字或参数及其简单描述 rou? 列出以“rou”字符串开头的所有命令及其简单描述
user-interface vty 0 4 进入0~4前五个的VTY用户界面进行整体配置
authentication-mode password 设置验证方式为密码 user privilege level 3 设置用户登陆级别 aaa 进入aaa视图 local-user admin password cipher hello privilege level 3 在aaa视图下设置账号密码 和用户级别 local-user admin service-type telnet 配置该用户接入类型为aaa q 退回到用户视图 user-interface vty 0 4 进入到VTY用户视图 authentication-mode aaa 设置验证方式aaa
配置SSH server:rsa local-key-pair create 生成本地RSA主机密钥对
display rsa local-key-pair public 查看本地密钥对中的公钥信息 user-interface vty 0 4 进入VTY用户视图 authentication-mode aaa 设置用户验证方式为aaa授权验证方式 protocol inbound ssh 指定VTY用户只支持ssh q 返回到系统视图 aaa 进入aaa视图 local-user huawei1 password cipher huawei1 创建用户和设置用户密码 local-user huawei1 service-type ssh 配置本地用户接入类型为ssh q 退回到用户视图 ssh user huawei1 authentication-type password 新建ssh用户指定ssh用户认证方式为password aaa 进入aaa视图 local-user huawei1 privilege level 3 设置huawei1用户级别为3 级别范围0~15 stelnet server enable 开启ssh功能 display ssh user-information huawei1 查看ssh用户配置信息不指定用户默认查看所有用户 display ssh server status 查看ssh服务器全局配置信息
ssh client first-time enable 开启首次认证功能不对ssh服务器的RSA公钥进行有效性验证
stelnet 10.1.1.2 登陆R2 sys 进入到R2的系统视图 display ssh server session 查看ssh服务器端的当前会话连接信息
server:aaa 进入aaa视图 local-user huawei2 password cipher huawei2 设置用户名和密码 local-user huawei2 service-type ssh 配置本地用户的接入类型为ssh local-user huawei2 privilege level 3 设置用户级别为3 local-user huawei2 ftp-directory flash: 指定FTP用户的可访问目录,如果不配置用户将无法登陆 ssh user huawei2 authentication-type password 新建ssh用户指定用户认证方式为密码 sftp server enable 开启sftp服务器功能 display ssh server status 查看ssh服务器配置信息 display ssh server session 查看ssh服务器端的当前会话连接信息 client:sftp 10.1.1.2 登陆S2
ftp 10.0.2.1 连接远程ftp服务器 ls 查看FTP服务器文件夹状态 cd +文件夹名 进入文件夹 dir 查看详细的文件属性 get +文件名 下载文件到本地 put +旧文件名 +新文件名 上传文件到FTP服务器 配置路由器为ftp Server sys 进入系统视图 aaa 进入aaa视图 local-user ftp password cipher huawei 设置用户名ftp和密码huawei local-user ftp ftp-directory flash: 指定FTP用户的可访问目录,如果不配置用户将无法登陆 local-user ftp service-type ftp 设置服务类型为ftp local-user ftp privilege level 15 设置用户优先级为15
interface +接口 进入到某一接口 undo negotiation auto 命令关掉自协商功能 duplex full 指定双工模式为全双工 speed 10 配置接口速率为10Mbit/s
arp static 10.1.2.3 5489-9827-0ECD 配置静态arp表 arp-proxy enable 开启arp代理功能具体到接口
vlan 10 划分Vlan10 vlan batch 30 40 同时创建vlan30和40 dispaly vlan 查看vlan信息
int e0/0/1 进入某一个接口 port link-type access 配置接口类型为access port default vlan 10 配置接口加入相应的vlan
int e0/0/1 进入某一个接口 port link-type trunk 配置接口类型为trunk port trunk allow-pass vlan 10 20 允许vlan 10 20 的数据通过 port trunk allow-pass vlan all 允许所有vlan通过
int e0/0/1 undo port default vlan 恢复接口默认vlan port link-type hybrid 修改接口类型为hybrid port hybrid untagged vlan 20 命令交换机在该接口转发VLAN 20的帧时,剥离掉相应的VLAN Tag 20,以Untagged的方式发送给PC port hybrid pvid vlan 20 设置hybrid接口的默认VLAN ID port hybrid tagged vlan 10 20 设置该链路仅接收带有VLAN Tag 10 和 20 的帧
interface GigabitEthernet 0/0/1.1 路由器上创建子接口 dot1q termination vid 10 配置子接口对一层tag报文的终结功能 arp broadcast enable 开启子接口的arp广播功能
vlan batch 10 20 创建VLAN 10 20
int g0/0/1 port link-type access 设置接口类型 port default vlan 10 划分接口g0/0/1到vlan 10 interface Vlanif 10 创建Vlanif接口设置其对应接口ID为10 ip address 192.168.1.254 24 设置其Vlanif 接口ip地址
stp enable 在交换机上启用STP stp mode stp dis stp 查看stp配置 dis stp brief 查看接口摘要信息 stp priority 4096 修改交换机优先级为4096 stp root primary 设置交换机为主根交换机 stp root secondary 命令配置备份交换机 display stp interface Ethernet 0/0/2 查看e0/0/2接口的开销值 int e0/0/2 stp cost 2000 配置接口e0/0/2的带价值为2000 stp timer forward-delay 3000 修改STP的Forward Delay时间为3000cs也就是30s stp bridge-diameter 3 命令设置网络的直径为3
stp mode rstp 启用RSTP使用RSTP可以缩短收敛时间
int e0/0/1 stp edged-port enable 配置接口e0/0/1为边缘端口不参与生成树的计算
stp region-configuration 进入MST域视图 region-name huawei 配置MST域名为huawei revision-level 1 配置MSTP的修订级别为1 instance 1 vlan 10 指定VLAN 10映射到MSTI 1 active region-configuration 激活MST域配置 display stp region-configuration 查看交换机上当前生效的MST域配置信息
dis stp instance 0 brief 查看实例0中的生成树状态和统计的摘要信息 stp instance 2 priority 0 配置交换机成位实例2中的根交换机
int G0/0/1 port link-type trunk 配置接口类型为trunk port trunk allow-pass vlan all 允许所有VLAN通过
int e0/0/1 port link-type access 配置接口类型为access port default vlan 10 将接口e0/0/1划入VLAN 10
grvp 交换机上开启GVRP功能
int g0/0/1 gvrp 在接口g0/0/1开启gGVRP功能
还需在某个交换机的右侧接口手动配置VLAN实现双向注册GVRP
interface Eth-Trunk 1 创建Eth-Trunk 1 接口 mode manual load-balance 指定为手工负载分担模式
int g0/0/1 进入接口 eth-trunk 1 将接口g0/0/1加入到Eth-Trunk 1接口 display eth-trunk 1 查看Eth-Trunk 1接口状态
int g0/0/1 进入接口 undo eth-trunk 删除聚合链路接口下的g0/0/1 mode lacp-static 将工作模式改为静态LACP 然后将所有接口加入到聚合链路Eth-trunk 1 lacp priority 100 修改交换机优先级为一百 (值越低优先级越高) interface Eth-Trunk 1 max active-linknumber 2 设置活动接口的上限阈值 接下来修改聚合链路中接口g0/0/1和g0/0/2的优先级
ip route-static 192.168.20.0 24 10.0.12.2 preference 100 设置备份路由并将优先级设置为100 display ip routing-table protocol static 查看静态路由的路由信息
rip 创建开启协议进程 network + ip 对指定网段接口使能RIP功能IP地址是与路由器直连的网段 debugging rip 1 查看RIP定期更新情况 terminal debugging terminal monitor 在屏幕上显示debug信息 undo debugging rip 1undo debug all 命令关闭debug调试功能 在上面的配置基础上配置RIP2 rip 进入子视图模式 version 2 配置版本 或者直接配置 rip 1 version 2 network + ip
rip简单认证 rip authentication-mode simple huawei 在需要的路由器上配置密码要相同
rip authentication-mode md5 usual huawei 方式使用MD5密文验证,使用通用报文格式,两端报文格式必须一致 dis default-parameter rip 查看RIP配置信息
方法1: rip 1 version 2 summary always 方法2: int + 接口 undo rip split-horizon 关闭水平分割功能
int +接口 rip summary-address 3.3.0.0 255.255.252.0 手动汇总ip+掩码
配置RIP版本兼容 rip version 2 broadcast 命令路由器以广播的形式发送RIPv2报文 rip version 2 multicast 命令路由器以组播的形式发送RIPv2报文
int + 接口 undo rip output 让路由器停止发送RIP路由更新 display rip 1 database 检查RIP发布数据库中的所有路由激活 rip timers rip 20 120 60 设置更新报文时间为20s,超时计时器为120s,垃圾收集计时器为60s preference 90 修改RIP协议优先级为90
(只接受RIP更新报文,不发送更新报文) rip 1 silent-interface GigabitEthernet 0/0/0 设置要抑制的接口 配置RIP单播更新(由于配置了抑制接口,接口无法以广播或者组播的方式发送RIP更新报文) rip 1 peer 172.16.1.100 IP地址为邻居路由器的IP地址 另一种方法(删除上面的配置) undo rip output 禁止这个接口发送RIP报文 undo rip input 禁止这个接口接收RIP报文
方法1给接口配置第二个IP地址,应该取配置网段的子网,适合小型网络 ip address 10.0.23.2 sub 方法2使用RIPv2,关闭自动汇总 rip version 2 undo summary
undo rip split-horizon 关闭水平分割功能(进入接口) rip split-horizon 开启水平分割功能 rip poison-reverse 开启毒性逆转功能
增加度量值(进入接口) rip metricin 2 增加度量值2端口出去的跳数 rip metricout 2 增加度量值2端口进来的跳数
Rip路由引入(需保证被引入的路由条目已经存在于当前设备中) rip import-route direct 直连路由,一般是本地接口的地址 rip import-route static 静态路由,是引入的你在设备上配置的静态路由。
ospf 1 进入ospf视图1代表进程号 area 0 创建区域并进入OSPF区域视图,输入要创建的区域ID,骨干区域即区域0 network +IP +匹配码 display ospf interface 命令查看OSPF接口通告是否正确、 display ospf peer 查看OSPF邻居状态 display ip routing-table protocol ospf 查看OSPF路由表
o spf 1 area 1 authentication-mode simple plain huawei plain是口令以明文方式显示 authentication-mode md5 1 huawei 配置区域密文认证
int g0/0/1 ospf authentication-mode md5 1 huawei 在一条链路中的两个接口配置要相同
ospf 1 silent-interface GigabitEthernet 0/0/1 禁止接口g0/0/1接收和发送ospf报文 技巧对多个接口配置接口抑制 ospf 1 silent-interface all 抑制所有接口 un display ip routing-table 10.0.1.1 查看10.0.1.1所在网段的路由条目
基于接口修改 int g0/0/0 ospf network-type p2mp 修改ospf的网络类型为多到多点 ospf network-type broadcast 修改ospf的网络类型为广播 ospf dr-priority 100 修改g0/0/0接口的DR优先级为100 reset ospf process 重启ospf进程 ospf cost 1000 修改ospf的开销值为1000 ospf timer hello 20 修改HELLO计时器为20s ospf timer dead 80 修改dead计时器为80s
ospf 1 preference 110 修改ospf优先级为110 值越大优先级越低
ospf 1 import-route rip 1 在ospf进程中引入rip default-route-advertise always 在ospf进程中引入默认路由
rip import-route ospf 1 在rip进程中引入ospf import-route ospf cost 3 ospf 引入rip时配置开销值 default-route originate 在RIP进程中发布默认路由
int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 创建VRRP备份组,备份组号为1,配置虚拟IP为172.16.1.254 vrrp vrid 1 priority 120 修改优先级为120 display vrrp 查看vrrp信息 display vrrp brief display vrrp interface g0/0/0 查看VRRP的工作状态
int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 创建VRRP备份组,备份组号为1,配置虚拟IP为172.16.1.254 vrrp vrid 1 priority 120 修改优先级为120 vrrp vrid 2 virtual-ip 172.16.1.253 创建VRRP备份组,备份组号为2,配置虚拟IP为172.16.1.253
int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 创建VRRP备份组,备份组号为1,配置虚拟IP为172.16.1.254 vrrp vrid 2 virtual-ip 172.16.1.253 创建VRRP备份组,备份组号为2,配置虚拟IP为172.16.1.253 vrrp vrid 2 priority 120 修改优先级为120
vrrp vrid 2 preempt-mode disable 开启非抢占方式
in t g0/0/1 vrrp vrid 1 track interface GigabitEthernet 0/0/0 reduced 50 监视上行接口G0/0/0,当此接口断掉时,裁减优先级50,使优先级为70 vrrp vrid 1 authentication-mode md5 huawei 认证配置
acl 2000 创建一个编号型ACL,基本ACL的范围是2000~29999 rule 5 permit source 1.1.1.1 0 指定规则ID为5,允许数据源地址为1.1.1.1的报文通过,反掩码全为0,即精确匹配 rule 10 deny source any 指定ID为10,拒绝任意源地址的数据包通过
display acl all 查看设备上所有的访问控制列表
ip ip-prefix 1 index 10 deny 11.1.1.0 25 greater-equal 25 less-equal 25 ip-prefix-name:指定地址前缀列表名称,唯一标识一个IPv4地址前缀列表。deny:拒绝。greater-equal:指定掩码长度可以匹配范围的下限(也即最小长度)。less-equal:指定掩码长度匹配范围的上限 ip ip-prefix 1 index 20 permit 0.0.0.0 0 less-equal 32 rip filter-policy ip-prefix 1 import 将前缀列表配置在过滤策略下
修改链路类型 link-protocol hdlc 修改链路类型为高级数据链路控制
ppp的pap认证 int Serial 4/0/0 ppp authentication-mode pap domain huawei 采用pap方式认证,认证采用域名为huawei aaa 进入aaa视图 authentication-scheme huawei_1 创建认证方案为huawei_1 authentication-mode local 配置认证模式为本地认证 domain huaweiyu 创建域huaweiyu并进入视图 authentication-scheme huawei_1 配置域的认证方案为huawei_1 q 退回到aaa视图 local-user R1@huaweiyu password cipher Huawei 配置存储在本地,为对端认证方所使用的用户名为R1@huaweiyu,密码为Huawei local-user R1@huaweiyu service-type ppp
int Serial 4/0/0 undo ppp authentication-mode 删除以前的pap配置 去到另一端 undo ppp pap local-user 删除ppp本地用户 回到配置路由器 int Serial 4/0/0 authentication-mode CHAP 配置ppp认证模式为CHAP aaa 进入aaa视图 loacal-user R1 password cipher huawei 用户设置为R1,密码设置为huawei loacal-user R1 service-type ppp 设置服务类型为ppp 去到另外一端配置用户名和密码 int Serial 4/0/0 ppp chap user R1 ppp chap password cipher huawei
int Serial 1/0/0 link-protocol fr 修改链路协议 fr inarp 开启逆向地址解析功能 fr map 10.1.1.1 201 配置一条静态地址映射 dis fr pvc-info 查看PVC的建立情况
(动态主机配置协议) [R1]dhcp enable 路由器上开启DHCP [R1]int g0/0/0 [R1-GigabitEthernet0/0/0]dhcp select interface 开启接口DHCP功能 [R1-GigabitEthernet0/0/0]int g0/0/1 [R1-GigabitEthernet0/0/1]dhcp select interface [R1-GigabitEthernet0/0/0]dhcp server lease day 2 配置DHCP服务器接口地址池中IP地址的租用有效期限为两天 [R1-GigabitEthernet0/0/0]dhcp server excluded-ip-address 192.168.1.1 192.168.1.10 设置不参与分配自动分配的IP地址范围 [R1-GigabitEthernet0/0/1]dhcp server dns-list 8.8.8.8 配置该接口地址池下的DNS服务器为PC分配DNS服务器地址 [R1]display ip pool 查看DHCP地址池中的地址分配情况
[R1]dhcp enable [R1]ip pool huawei1 创建一个全局地址池 [R1-ip-pool-huawei1]network 192.168.1.0 命令配置全局地址池huawei1可动态分配的网段范围为192.168.1.0,默认使用24为掩码。 [R1-ip-pool-huawei1]lease day 2 配置DHCP全局地址池下的地址租期为2天 [R1-ip-pool-huawei1]gateway-list 192.168.1.254 配置dhcp客户端的出口网关地址 [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]int g0/0/0 [R1-GigabitEthernet0/0/0]dhcp select global 开启DHCP功能采用全局地址池为客户端分配地址
方法一直接指定DHCP服务器 [R1]dhcp enable 路由器开启DHCP功能 [R1]interface g0/0/1 [R1-GigabitEthernet0/0/1]dhcp select relay 开启DHCP中继功能 [R1-GigabitEthernet0/0/1]dhcp relay server-ip 100.1.1.1 指定DHCP服务器 方法二全局配置DHCP中继: [R1]dhcp server group dhcp-group 创建DHCP服务器组dhcp-group [R1-dhcp-server-group-dhcp-group]dhcp-server 100.1.1.1 配置DHCP服务器
[R1-dhcp-server-group-dhcp-group]int g0/0/1 [R1-GigabitEthernet0/0/1]dhcp select relay 开启DHCP中继功能 [R1-GigabitEthernet0/0/1]dhcp relay server-select dhcp-group 将接口加入到DHCP服务器组dhcp-group
[R1]ipv6 全局开启开启IPv6 [R1]interface g0/0/0 [R1-GigabitEthernet0/0/0]ipv6 enable 在接口下开启IPv6功能 [R1-GigabitEthernet0/0/0]ipv6 address auto link-local 接口上配置自动生成的链路本地地址 用EUI-64方式配置IPv6地址 [R1]int g 0/0/0 [R1]ipv6 address 2001:3:FD:: 64 eui-64
静态 [R1]int g0/0/0 [R1-GigabitEthernet0/0/0]nat static global 202.169.10.5 inside 172.16.1.1 静态地址转换 [R1]display nat static 查看Nat静态配置信息
NAT Outbound [R1]nat address-group 1 202.169.10.50 202.169.10.60 配置NAT地址池 [R1]ACL 2001 创建ACL 2001 [R1-acl-basic-2001]rule 5 permit source 172.17.1.0 0.0.0.255 设置规则 [R1]int g0/0/0 [R1-GigabitEthernet0/0/0]nat outbound 2001 address-group 1 no-pat 将ACL 2001 与地址池结合只允许ACL中规定地址段的IP可以进行地址转换 [R1]dis nat outbound 查看nat outbound 信息
[R1]interface g0/0/0 [R1-GigabitEthernet0/0/0]undo nat outbound 2001 address-group 1 no-pat 删除之前的配置 [R1-GigabitEthernet0/0/0]nat outbound 2001 配置Easy-IP特性,直接使用接口IP地址作为NAT转换后的地址
[R1-GigabitEthernet0/0/0]interface g0/0/0 [R1-GigabitEthernet0/0/0]nat server protocol tcp global 202.169.10.6 ftp inside 172.16.1.3 ftp 定义内部服务器的映射表,指定服务器通信类型为tcp,配置服务器使用公网IP地址为202.169.10.6,服务器内网地址为172.16.1.3,指定端口号为21用关键字ftp代替 [R1]nat alg ftp enable 开启ftp功能
--- EOF ---