案例1:华为交换机根据IP查他对应的MAC地址和交换机端口

设备
核心交换机: 华为S5735S-S24T4S-A
VRP ® software, Version 5.170 (S5735 V200R019C10SPC500)

接入层交换机:华为S5720-28p-LI-AC
VRP ® software, Version 5.170 (S5720 V200R011C10SPC600

配置说明

华为交换机根据已知一个IP查他对应的MAC地址,

已知终端ip:192.168.1.11
1.首先在核心交换机

dis arp | include 192.168.1.11


显示

IP ADDRESS MAC ADDRESS E XPIRE(M) TYPE INTERFACE VPN-INSTANCE VLAN
192.168.1.11 6xxx-9xxx-fxxx 12 D-0 GE0/0/11
Total:113 Dynamic:196 Static:0 Interface:4

找到ip:192.168.1.11对应mac地址为6xxx-9xxx-fxxx

查哪些IP已绑定的对应该的MAC地址

display current-configuration | include 192.168.1


显示

dhcp server static-bind ip-address 192.168.1.9      mac-address xxxx-xxxx-xxxx
dhcp server static-bind ip-address 192.168.1.108 mac-address xxxx-xxxx-xxxx
dhcp server static-bind ip-address 192.168.1.149  mac-address xxxx-xxxx-xxxx

2.然后找到对应接入层交换机

dis mac-address 6xxx-9xxx-fxxx

[ACCESS]dis mac-address 6xxx-9xxx-fxxx
MAC Address VLAN/VSI/BD Learned-From Type
6xxx-9xxx-fxxx 16/-/- GE0/0/18 dynamic
找到mac地址:6xxx-9xxx-fxxx对应端口号GE0/0/18

查看接口对应有哪些mac地址

dis mac-address g0/0/23

MAC Address VLAN/VSI/BD Learned-From Type

3d9c-232d-091a 16/-/- GE0/0/23 dynamic

案例2:知道终端的MAC地址,不知道它在那个交换机接口;

不知道VLAN等配置信息;需要通过MAC地址去配置电脑的静态IP地址

1.获取终端的MAC地址

电脑上直接CMD:ipconfigall

编辑

 其他设备也一样,看设备屁股后面有没有一串的MAC地址

2.登录交换机,查询在那个交换机的接口下

  • 建议在核心或者汇聚去查询MAC地址
  • 查询后发现 它的VLAN是105,交换机的接口是Eth-Trunk6
  • 所以要继续去查询Eth-Trunk6这个接口的信息

编辑

3.查询接口信息

  • 查询接口可以发现之前做了标注的,是98.187,
  • 这里是内部标记,代表下一跳地址是98.187,中间串了交换机的
  • 也可以通过接口配置判断,终端的口应该是access口,不会是trunk口
  • 如果没做备注的,就去机房里面看这个接口的打标
  • 如果打标也没做,备注也没做,只能去现场用网线仪测试了

编辑

4.进入终端交换机查询接口信息

  • 可以看到接口是ACCESS
  • vlan是105

编辑

三、举一反三,用IP也可以查到MAC地址

命令:dis arp

dis arp | include 172.16.xx.xx 

解释:查询交换机路由表

举例:

华为交换机常用配置命令

一、交换机常用命令

作用

命令

查看交换机运行的配置 

display current 

查看当前视图下配置生效的命令

dis this

查看arp路由表,即ip与mac的对应表

d arp

路由标筛选某个网段 

display arp | inclue 10.0.2.

disp arp | in   10.0.2

查询交换机各端口学习到终端设备的物理地址

display mac-address

查看某端口下mac地址表项

display mac-address GigabitEthernet 0/0/X

进入系统视图

sys进入,在系统视图下输入quit或者return返回用户视图

system-view 或者 sys 或者 system

进入某个接口

interface GigabitEthernet 0/0/23  

int g0/0/23

设置接口的默认VLAN  

port default vlan 501

设置端口工作模式

设置接口是access或者trunk

port link-type access/ trunk

关闭接口

shutdown

开启接口

undo shutdown

删除单个端口单个配置

interface g0/0/1

display this
clear configuration interface Ethernet 0/0/1

查看日志信息

display trapbuffer 

display logbuffer 

关闭所有警告信息

undo terminal monitor 

开启/关闭信息中心

undo info-center enable

display cpu-usage

 display memory-usage 

 display alarm urgent 

display device 

display version 

display interface Ethernet brief

display interface brief //查看端口闭开情况

display routing-table //查看路由信息

display interface description

display interface brief

display counters

display counters error

display counters rate

display ip interface

dis,是display字母缩写,也可以用一个字母d代替

current,意思是当前的意思,缩写cur

mac-address,MAC地址,缩写mac-add

二、命令解释

1.华为交换机查询终端MAC地址

命令:dis mac-address

解释:查询交换机各端口学习到终端设备的物理地址

举例:

编辑

查询出来后:分为MAC Address/VLAN/LEARNED-FROM/TYPE

查询出来终端的MAC地址

MAC Address

匹配的VLAN号

VLAN/VSI

是从那个接口获取到的

LEARNED-FROM

类型

TYPE

2.华为交换机查询ARP路由表

命令:dis arp

dis arp | include 172.16.xx.xx

解释:查询交换机路由表

举例:

编辑

查询出来后:分为IP Address/MAC ADDRESS/EXPIRE(M)/TYPE/INTERFACE

IP-Address

查询出来终端的IP

MAC ADDRESS

物理地址

EXPIRE(M)

过期时间

TYPE

类型

VLAN

配备的VLAN号

LEARNED-FROM

是从那个接口获取到的       

INTERFACE

接口

华为交换机端口组设置

华为交换机如何进行端口批量设置
永久端口组:port-group name
临时端口组:port-group group-member

创建端口组1:port-group g1
将交换机端口1~24加入端口组1: group-member gigabitethernet 0/0/1 to gigabitethernet 0/0/24  

group-member g 0/0/1 to g0/0/24
端口链路类型访问:    port link-type access  
将端口组加入vlan 301: port default vlan 301

临时端口组

sy
system-view
port-group  cjw.com
port linke-type access
port default  vlan 100
qu
dis vlan
dis cu
undo port-group cjw.com

port-group group-member g0/0/1 to g0/0/24
port default vlan1

port

port linke-type access
port default vlan 300

interface g
interface GigabitEnthernet 0/0/2
port linke-type access


interface GigabitEthernet 0/0/1
port-isolate enable


华为交换机终端重置

重置console密码


恢复出厂态默认console密码是admin@huawei.com
掉电重启,界面显示Press Ctrl+B or Ctrl+E to enter BootROM menu …时按Ctrl+B 
输入密码admin@huawei.com
进入BootROM MENU
选择7.Clear password for console user
提示Note: Clear password for console user? Yes or No(Y/N): 
输入y确认
再次显示BootROM MENU
选择1.Boot with default mode重启设备,再登陆不需要密码
<HUAWEI>sys            #进入系统管理视图(system-view)
[HUAWEI]user-interface console 0    #进入console控制模式
[HUAWEI-ui-console0]authentication-mode password    #工作模式为密码模式
[HUAWEI-ui-console0]set authentication password cipher mima123    #设置console密码为可逆向解码模式,密码为mima123
[HUAWEI-ui-console0]quit    #退出console模式(q)
[HUAWEI]q        #退出系统视图
<HUAWEI>save    #保存配置
验证是否成功:
<HUAWEI>q         #先退出登录
Password:输出以上配置的密码可以成功登陆

配置telnet登陆


<HUAWEI>sys        进入系统视图
[HUAWEI]telnet server enable    #开启telnet权限
[HUAWEI]user-interface maximum-vty 15        #设置虚拟用户最多15个同时在线(不同交换机规格不同,大多是是5个)
[HUAWEI]user-interface vty 0 4    #进入虚拟终端
[Huawei-ui-vty0-4]authentication-mode aaa    #配置用户对终端接口的管理模式为aaa(aaa表示输入正确用户名密码才允许登陆,password表示输入正确密码可以登陆)
[HUAWEI-ui-vty0-4]protocol inbound telnet        #添加协议池包含telnet(可以将telnet改成all,保证其他协议也会加入)
[Huawei-ui-vty0-4]q         #退出虚拟终端
[HUAWEI]aaa        #进入aaa管理模式
[HUAWEI-aaa]local-user goldencis password cipher huawei1234        #设置telnet登陆用户名为goldencis密码是huawei1234
[HUAWEI-aaa]local-user huawei privilege level 15    #设置用户权限级别
[HUAWEI-aaa]local-user goldencis service-type telnet    设置goldencis登陆服务类型
[HUAWEI-aaa]q         #退出aaa模式
[HUAWEI]interface vlanif 1        #进入vlan1
[HUAWEI-Vlanif1]ip address 192.168.8.112 255.255.255.0        #配置vlan1的IP和子网掩码,不需要配置网关

验证配置是否生效

交换机连接外网,验证PC通过网线与交换机连接,PC上网正常。

PC通过网线与交换机连接(网络口即可),cmd命令行telnet 上一步设置的交换机维护IP,输入用户名密码登陆正常。

此时交换机可以通过telnet方式进行管理,不需要再连接串口了。

重置设置就完成啦!

如果交换机配置混乱无法理清,但知道console登陆密码,可以通过命令恢复出厂设置:

登陆交换机<HUAWEI>
<HUAWEI>reset saved-configuration
The configuration will be erased to reconfigure. Continue? [Y/N]:y
<HUAWEI>reboot
Warning: The configuration has been modified, and it will be saved to the next startup saved-configuration file . Continue? [Y/N]:n
System will reboot! Continue?[Y/N]:y
重启后有默认密码,华为默认密码一般为admin@huawei.com 再参照以上步骤重置console密码就可以啦

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐