1+X网络中级命令整理

Crq
Crq
Crq
218
文章
0
评论
2021年7月7日19:13:05
评论
1,4251 7464字阅读24分52秒

1.vlan

[SW1]vlan batch 10 20 30 //一次性划分多个VLAN
[SW1-Ethernet0/0/1]port link-type access //接口改成ACCESS模式
[SW1-Ethernet0/0/1]port default vlan 10 //接口划分进vlan10
[SW2-GigabitEthernet0/0/1]port link-type trunk //接口改成trunk模式
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 //trunk模式下放通vlan10和20

[SW2]vlan 10
[SW2-vlan10]description Technical //给vlan一个备注

[SW1]interface Vlanif 10

[SW1-Vlanif10]ip add 192.168.1.1 24 //进入vlan给它一个地址,可以用于与路由器通信,或者作为终端的网关,也可以在vlanif内配置DHCP

 

2.stp

[SW1]stp enable //开启生成树,(华为默认开启,多生成树)
[SW1]stp mode {stp | rstp | mstp} //切换生成树模式
[SW1]stp priority 0 //更改生成树优先级,默认32768
[SW1]undo stp priority //删除配置的优先级
[SW1]stp root primary //设置本交换机为根桥 交换机
[SW2]stp root secondary //设置本交换机为备份根桥 从交换机

2.ospf

(优先从Loopback地址中选择最大的IP地址作为Router-ID。如果没有配置Loopback接口,则在接口地址中选取最大的IP地址作为Router-ID。)

[R1]ospf 1 router-id 1.1.1.1 //创建一个OSPF进程,进程号为1,ospf的routerid为1.1.1.1
[R1-ospf-1]import-route {direct | static | ospf} //引入 {直连 | 静态 | OSPF外部} 路由 ,非中级内容不做介绍
[Huawei-ospf-1]default-route-advertise //引入默认路由,加上always 则下发一条默认路由
[R1-ospf-1]area 0 //进入区域0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 //宣告网段。IP地址段后面是反掩码
[R1-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher 123456 //设置区域认证为MD5 密码是12346
[R1-ospf-1-area-0.0.0.0]authentication-mode simple cipher 123456 //设置区域认证为简单模式 密码12346
//plain为明文认证
display ip routing-table protocol ospf //查看OSPF路由表
display ospf peer brief //查看OSPF邻居状态

3.静态路由

 

[R2]ip route-static 10.10.10.0 24 40.40.40.1 //去往10.10.10.0的网段 掩码为24 下一跳地址为40.40.40.1
[R2]ip route-static 10.10.10.0 24 serial1/0/1 //去往10.10.10.0的网段 掩码为24 下一跳地址为自己的出接口
[R1]ip route-static 0.0.0.0 0.0.0.0 10.10.10.10 //默认路由是特殊的静态路由,路由表没有记录的网段都可以去往10.10.10.10
[R1]ip route-static 0.0.0.0 0.0.0.0 20.20.20.10 preference 100 //配置本条静态路由优先级为100,一般用于配置浮动路由

 

4.单臂路由

 

[R1]interface GigabitEthernet 0/0/0.1 //进入子接口
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 10 //终结含多层VLAN的数据包的最外层标签
[R1-GigabitEthernet0/0/0.1]ip address 192.168.1.254 24 //配置地址
[R1-GigabitEthernet0/0/0.1]arp broadcast enable //开启ARP广播

缺省情况下,终结子接口没有使能ARP广播功能。
如果终结子接口上没有配置arp broadcast enable命令,那么系统会直接把该IP报文丢弃。此时该终结子接口的路由可以看作是黑洞路由。
如果终结子接口上配置了arp broadcast enable命令,那么系统会构造带Tag的ARP广播报文,然后再从该终结子接口发出。

5.VRRP

 

[R1-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254 //在接口模式下配置VRRP VRID为1 虚拟地址为192.168.1.254
[R1-GigabitEthernet0/0/0]vrrp vrid 1 priority 150 //设置VRID为1的VRRP组优先级为150,默认值为100,取值范围1-254
[R1-GigabitEthernet0/0/0]vrrp vrid 1 authentication-mode md5 123456 //设置VRRP的认证 仅支持MD5与simple

[R1-GigabitEthernet0/0/0]vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 20 //VRRP组1要监控GE0/0/1口,如果该接口的协议状态或者是物理状态变成DOWN,则将该VRRP组的优先级减去20

6.链路聚合

[SW1]int Eth-Trunk 1 //进入或创建聚合组
[SW1-Eth-Trunk1]trunkport GigabitEthernet 0/0/1 to 0/0/3 //添加g0/0/1到g0/0/3及之间的接口到聚合内,不加 to 就是间断添加接口
[SW1-Eth-Trunk1]port link-type trunk //改变聚合组链路类型为trunk,与在交换机接口内改链路类型类似,其他端口特性不列举
[SW1-Eth-Trunk1]mode lacp-static //更改聚合模式为静态LACP,缺省的工作模式为手工负载分担模式
[SW1-GigabitEthernet0/0/1]lacp priority 1000 //配置接口优先级,缺省值32768

 

7.pap认证

 

配置本端PPP协议的认证方式为PAP。需要先执行aaa命令

[R1]aaa //进入aaa视图
[R1-aaa]local-user huawei password cipher 123456 //创建用户名为huawei 加密类型为密文 密码为123456的账户
[R1-aaa]local-user huawei service-type ppp //设置huawei账户的用于ppp服务
[R1-aaa]int s4/0/0
[R1-Serial4/0/0]link-protocol ppp //设置接口在L2层封装PPP协议
[R1-Serial4/0/0]ppp authentication-mode pap //在主认证端上指明ppp的认证方式为pap
display ip interface brief //查看接口状态

对端配置(被认证端)

[R2]int s4/0/0
[R2-Serial4/0/0]link-protocol ppp //设置接口在L2层封装PPP协议
[R2-Serial4/0/0]ppp pap local-user huawei password cipher 123456 //设置用于认证的账户与密码

 

8.chap认证

配置本端PPP协议的认证方式为chap。需要先执行aaa命令

[R1]aaa //进入aaa视图
[R1-aaa]local-user huawei password cipher 123456 //创建用户名为huawei 加密类型为密文 密码为123456的账户
[R1-aaa]local-user huawei service-type ppp //设置huawei账户的用于ppp服务
[R1]interface Serial 4/0/0
[R1-Serial4/0/0]link-protocol ppp //设置接口在L2层封装PPP协议
[R1-Serial4/0/0]ppp authentication-mode chap //在主认证端上指明ppp的认证方式为chap
display ip interface brief //查看接口状态

对端配置(被认证端)

[R2]int s4/0/0
[R2-Serial4/0/0]link-protocol ppp //设置接口在L2层封装PPP协议
[R2-Serial4/0/0]ppp chap user huawei //设置用于认证的账户
[R2-Serial4/0/0]ppp chap password cipher 123456 //设置用于认证的密码

 

9.PPPoE认证

配置 PPPoE 地址池,通过使用全局地址池给对端分配地址,实现 PPPoE Server 为 PPPoE Client动态分配IP地址

[ISP]ip pool pppoe
[ISP-ip-pool-pppoe]gateway-list 20.20.20.1
[ISP-ip-pool-pppoe]network 20.20.20.0 mask 255.255.255.0

配置PPPoE认证端

[ISP]aaa //进入AAA视图
[ISP-aaa]local-user huawei password cipher 123456 //创建用户名为huawei 加密类型为密文 密码为123456的账户
[ISP-aaa]local-user huawei privilege level 0 //设置账户权限等级
[ISP-aaa]local-user huawei service-type ppp //设置huawei账户的用于ppp服务

[ISP]interface Virtual-Template 1 //进入虚拟接口模板VT
[ISP-Virtual-Template1]ppp authentication-mode chap //在主认证端上指明ppp的认证方式为chap
[ISP-Virtual-Template1]remote address pool pppoe //本端PPPoE协议对对端设备的认证方式为CHAP
[ISP-Virtual-Template1]ip address 20.20.20.1 255.255.255.0 //配置虚拟接口地址

[ISP]interface GigabitEthernet 0/0/0
[ISP-GigabitEthernet0/0/0]pppoe-server bind Virtual-Template 1 //在以太网接口G0/0/0上启用PPPoE Server功能

配置 PPPoE 客户端

[R1]interface Dialer1 //用于该设置作为PPPOE客户端的拨号使用
[R1-Dialer0]ppp chap user huawei //账户为huawei
[R1-Dialer0]ppp chap password cipher 123456 //加密方式为密文 密码为123456
[R1-Dialer0]tcp adjust-mss 1200 //MSS,TCP分片设置为1200 MTU=MSS+TCP Header+IP Header
[R1-Dialer0]ip address ppp-negotiate //地址的获取方式从对端服务器得到
[R1-Dialer0]dialer user huawei //用来配置PPP chap认证里面的用户名
[R1-Dialer0]dialer bundle 1 //指定Dialer接口使用的Dialer bundle。设备通过Dialer bundle将物理接口与拨号接口关联起来。

[R1]interface GigabitEthernet0/0/0 //
[R1-GigabitEthernet0/0/0] pppoe-client dial-bundle-number 1 //实现Dialer Bundle和物理接口的绑定,用来指定PPPoE会话对应的Dialer Bundle

[R1] ip route-static 0.0.0.0 0 dialer 1 //配置缺省路由

 

10.端口安全

在交换机端口上打开端口安全功能,将MAC地址绑定到相对应接口中,并在vlan1上有效。(注意:PC的MAC地址需要四位一敲)

[SW1]interface Eth0/0/1
[SW1-Etherneto/0/1]port-security enable
[SW1-Etherneto/0/1]port-security mac-address sticky
[SW1-Etherneto/0/1]port-security mac-address sticky 5489-9890-1CA8 vlan 1
[SW1]interface Eth0/0/2
[SW1-Etherneto/0/2]port-security enable
[SW1-Etherneto/0/2]port-security mac-address sticky
[SW1-Etherneto/0/2]port-security mac-address sticky 5489-98B4-144E vlan 1
[SW1]interface Eth0/0/3
[SW1-Etherneto/0/3]port-security enable
[SW1-Etherneto/0/3]port-security mac-address sticky
[SW1-Etherneto/0/3]port-security mac-address sticky 5489-9837-5862 vlan 1
[SW1-Etherneto/0/3]quit

在交换机上使用display mac-address命令,查看交换机与计算机之间连接的端口,类型是否变为sticky。

 

11.基本ACL

[SW1]acl 2000//进入基本ACL 2000
[SW1-acl-basic-2000]rule permit source 192.168.30.0 0.0.0.255 //允许数据包源网段为 192.168.30.0 的报文通过
[SW1-acl-basic-2000]rule deny //华为未命中的默认运许,所与写一个拒绝所有
[SW1]int G0/0/2
[SW1-GigabitEthernet0/0/2]traffic-filter outbound acl 2000 //将规则应用到 G0/0/2 的端口出方向上
[SW1-GigabitEthernet0/0/2]quit

[SW1-acl-basic-2001]rule deny source 192.168.40.0 0.0.0.255 //拒绝数据包源网段为 192.168.40.0 的报文通过

12.高级ACL

[R1]acl 3000 //进入高级ACL 3000
[R1-acl-adv-3000]rule 5 permit tcp source 192.168.10.1 0 destination-port eq 80 //允许财务部 PC1 对服务器 80 端口的访问
[R1-acl-adv-3000]rule 10 deny ip //拒绝所有IP
[R1]int G0/0/1
[R1-GigabitEthernet0/0/1]traffic-filter outbound acl 3000 //应用到 G0/0/1 的端口出方向上
[R1-GigabitEthernet0/0/1]quit

13.Easy IP

使用Easy IP前需要创建ACL来建立规则,如

[R1]acl 2000
[R1-acl-basic-2000]rule permit source 192.168.10.0 0.0.0.255

[R1-acl-basic-2000]int G0/0/1
[R1-GigabitEthernet0/0/1]nat outbound 2000 //在G0/0/1接口下使用nat outbound命令配置Easy-IP特性,直接使用接口IP地址作为NAT转换后的地址。

14.静态NAPT

在R1的G0/0/1接口上,使用nat server命令定义内部服务器的映射表,指定服务器通信协议为TCP,配置服务器使用的互联网IP为16.16.16.1,服务器内网为192.168.1.1,指定端口号为80。
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat server protocol tcp global 16.16.16.1 80 inside 192.168.1.1 80

 

 

15.动态NAT

 

[R1]nat address-group 1 16.16.16.1 16.16.16.5 //令配置 NAT 地址池

创建基本ACL建立规则

[R1]acl 2000
[R1-acl-basic-2000]rule permit source 192.168.10.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 //命令将ACL2000与地址池相关联,使得ACL中规定的地址可以使用地址池进行地址转换

 

16.静态NAT

 

[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]nat static global 16.16.16.1 inside 192.168.1.1 //命令配置内部地址到外部地址一对一转换

 

17.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 //配置IPV6地址

 

 

weinxin
我的微信
这是我的微信扫一扫
Crq
  • 本文由 发表于 2021年7月7日19:13:05
  • 转载请注明:https://www.cncrq.com/9897.html
IPv6 华为HCIA

IPv6

  IPv6将地址分为了三类:单播、组播、任意播,也就是说我们的IPv6的通信方式也从IPv4的单播、组播、广播发生了一个比较大的改变,那就是没有广播了。 What?没有广播了,那么我们的A...
帧中继 RIP 华为HCIA

帧中继 RIP

实验拓扑   配置命令,自动映射 R1 # sysname R1 # router id 1.1.1.1 # interface Serial1/0/0 link-protocol fr i...
帧中继 OSPF 华为HCIA

帧中继 OSPF

先要了解什么是帧中继 帧中继(frame-ralay)是一种广域网技术,属于分组交换门里的一种;frame-relay是一种二层技术,与具体的物理链路无关。再说说ospf:ospf是一种动态路由协议,...
H3C命令小记 笔记

H3C命令小记

一 Telnet telnet server enable //启动Telnet服务 local-user h3c //创建用户H3C password simple 123456 //为用户创建密文...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: