文章目录
一、基本配置
0.基本信息查看命令
#查看交换机运行的配置
display current
#查看交换机运行的配置,查找配置acl的接口
display current interface | begin acl
#查看交换机的基本信息,包括设备型号、软件版本、运行时间等
display device
#查看交换机的软件版本信息,包括软件版本、发布日期等
display version
#查看交换机的端口信息,包括端口名称、端口状态、端口速率、端口 VLAN 号、端口带宽等
display interface
#查看交换机的端口信息,包括端口名称、端口状态、端口速率等
display interface brief
#查看交换机的当前配置信息,包括所有的命令和参数
display current-configuration
#查看交换机的保存的配置信息,包括所有的命令和参数
display saved-configuration
#查看交换机的 ARP 表信息,包括 IP 地址、MAC 地址、端口名称等
display arp
dis arp | include 192.168.0.10
#查看mac地址表
dis mac-address
dis mac-address 014c-00a4-ss24
#查IP已绑定的MAC地址
display current-configuration | include 192.168.1
#查看交换机的路由表信息,包括目的地址、下一跳地址、路径类型等。
display ip route
#查看交换机的MAC地址
dis bridge mac-address
#查看某个接口信息 dis this显示当前接口配置
dis int g0/0/1
#查看当前视图下配置生效的命令
dis this
#查看历史命令查询
display history-command
#查询设备上所有VLAN包含的接口信息
display port vlan
#查询设备上所有动态表项信息。
display port vlan active
1.基本配置-配置接口IP和DHCP等
<A>sys
Enter system view, return user view with Ctrl+Z.
[A]int
#进入g0/0/0口
[A]int g0/0/0
#配置接口IP
[A-GigabitEthernet0/0/0]ip add 192.168.1.1 255.255.255.0
[A-GigabitEthernet0/0/0]ip address 192.168.1.1 255.255.255.0
#开启dhcp
[A-GigabitEthernet0/0/0]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[A]int g0/0/0
#开启接口dhcp
[A-GigabitEthernet0/0/0]dhcp select interface
#配置接口dhcp DNS
[A-GigabitEthernet0/0/0]dhcp server dns-list 192.168.1.100
#添加静态路由表: 192.168.3.0 段路由指向 192.168.2.1 ,
[H]ip route-s
[H]ip route-static 192.168.3.0 255.255.255.0 192.168.2.1
[H]ip route-static 192.168.3.0 24 192.168.2.1
#撤销指定静态路由
[H]undo ip rou 192.168.3.0 255.255.0.0 192.168.2.1
[H]undo ip route-static 192.168.3.0 255.255.0.0 192.168.2.1
#查看ip路由表
[A]dis ip rou
[A]display ip routing-table
#查看静态路由表
[A]dis ip rou pro sta
[A]dis ip rou protocol static
[A]display ip routing-table protocol static
#查看指定ip路由表
[A]dis ip rou 192.168.1.2
2. Vlan
2.1 创建Vlan
#创建VLAN 10和VLAN 20
[A]vlan 10
[A-vlan10]quit
[A]vlan 20
[A-vlan20]quit
#创建多个VLAN 30 和 40
[A] vlan batch 30 40
#创建VLAN 41-50
[A] vlan batch 41 to 50
#查看VLAN
[A] display vlan
#查看指定VLAN的详细信息
[A] display vlan 10
#查看系统中所有VLAN的汇总信息
[A] display vlan summary
#删除单个VLAN10。
[A] undo vlan 10
#删除批量VLAN10到VLAN20。
[A] undo vlan batch 10 to 20
2.2 access和trunk
#access接口类型:交换机连接PC主机的链路为access
#进入接口并定义接口链路
[A] int g0/0/1
[A-GigabitEthernet0/0/1] port link-type access
#接口划分vlan10
[A-GigabitEthernet0/0/1] port default vlan 10
#恢复access接口的缺省配置
[A-GigabitEthernet0/0/1] undo port default vlan
#trunk接口类型:交换机与其它交换机端口相连的
#进入接口并定义接口链路
[A] int g0/0/1
[A-GigabitEthernet0/0/1] port link-type trunk
#允许VLAN10 20通过
[A-GigabitEthernet0/0/1] port trunk allow-pass vlan 10 20
#允许所有VLAN通过
[A-GigabitEthernet0/0/1] port trunk allow-pass vlan all
#恢复trunk 接口的缺省配置,trunk 改为 access
[A-GigabitEthernet0/0/1] undo port trunk allow-pass vlan all
[A-GigabitEthernet0/0/1] port trunk allow-pass vlan 1
[A-GigabitEthernet0/0/1] port link-type access
2.3 接口批量加入VLAN
通过端口组,可以把接口批量加入VLAN。
#access接口类型
#创建端口组pg1
[A] port-group pg1
#把接口gigabitethernet1/0/1到gigabitethernet1/0/5加入端口组
[A-port-group-pg1] group-member gigabitethernet1/0/1 to gigabitethernet1/0/5
#批量修改端口gigabitethernet1/0/1 to gigabitethernet1/0/5的链路类型为access
[A-port-group-pg1] port link-type access
#批量把端口gigabitethernet1/0/1 to gigabitethernet1/0/5加入VLAN10
[A-port-group-pg1] port default vlan 10
#trunk接口类型
#创建端口组pg1
[A] port-group pg1
[A-port-group-pg1] group-member gigabitethernet1/0/1 to gigabitethernet1/0/5
#批量修改端口gigabitethernet1/0/1 to gigabitethernet1/0/5的链路类型为trunk
[A-port-group-pg1] port link-type trunk
#批量把端口gigabitethernet1/0/1 to gigabitethernet1/0/5 加入VLAN10和VLAN20
[A-port-group-pg1] port trunk allow-pass vlan 10 20
2.4 VLANIF
利用三层交换机vlanif接口和路由器实现不同网段之间的通信
#批量创建 VALN 10 和 VLAN 20
[A]vlan batch 10 20
#配置进入VLANIF10接口
[A]interface vlanif 10
#配置接口IP地址
[A-Vlanif10]ip address 1.1.1.254 24
#显示接口IP状态与配置信息
[A]display ip interface brief
#清除指定接口配置
[A]clear configuration int g0/0/1
2.5 其他命令
#重命名设备
<Huawei>sys
[Huawei]sysname A
[A]
#退出系统视图 保存配置
[A]q
<A>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]
#重启
[A]q
<A>reboot
#设置用console线连接时永不超时,默认是10min
[A]user-interface console 0
[A-ui-console0]idle-timeout 0
#关闭接口
shutdown
#开启接口
undo shutdown
3. ACL
3.1 创建访问控制规则
ACL规则:
ACL Number 2000 【访问控制列表编号】
rule 15 permit source 10.1.1.0 0.0.0.255
a、 rule 规则编号
1、默认取值为:5(方便后续新增规则)
2、以5的倍数增长(方便后续新增规则)
3、规则编号越小越优先匹配
4、一旦命中规则,则无需继续匹配
b、动作
1、允许(permit)
2、拒绝(deny)
c、匹配项
1、源IP + 通配符
2、目的IP + 通配符
3、协议类型
4、源端口
5、目的端口
#创建命名为test的高级acl
[A]acl name test advance
#创建规则:拒绝 192.168.10.0 访问 192.168.30.0
[A-acl-adv-test]rule deny ip source 192.168.10.0 0.0.0.255 destination 192.168.
30.0 0.0.0.255
#创建规则:允许所有源ip访问所有目标地址
[A-acl-adv-test]rule permit ip source any destination any
#显示当前配置
[A-acl-adv-test]dis this
#在接口调用acl test
[A-GigabitEthernet0/0/1]traffic-filter inbound acl name test
#撤销在接口调用的acl name test
[A-GigabitEthernet0/0/1]undo traffic-filter inbound acl name test
#查看交换机的所有ACL配置列表
display acl all
#删除acl中规则5
[A-acl-adv-test]undo rule 5
#删除acl test
[A]undo acl name test
三级标题
示例:
总结
提示:这里对文章进行总结: