BYD_IT——部品件IT科第一章查询IP对应的交换机端口1定位具体接口判断接口类型确定端口234CONTENTSPAGE目录页获取IP和MAC地址displayarp|include10.1.117.199displaymac-addressc03f-d5e0-cecadisplayndpinterfaceGigabitEthernet1/0/21displaylldpneighbor-informationinterfaceGigabitEthernet1/0/1displaymac-addressinterfaceGigabitEthernet1/0/21一,获取地址一,通过IP地址查询MAC地址得到IP地址后,通过三层交换机ARP协议命令来查询MAC地址和具体接口:例如华为交换机:A15_2F_S7706_10.254.254.1displayarp|include10.1.117.199IPADDRESSMACADDRESSEXPIRE(M)TYPEINTERFACEVPN-INSTANCEVLAN/CEVLAN------------------------------------------------------------------------------10.1.117.199c03f-d5e0-ceca7D-0GE5/0/22查询的IP物理地址老化时间接口类型具体接口------------------------------------------------------------------------------Total:1081Dynamic:1046Static:0Interface:35二,定位接口二,定位具体接口1.得到MAC地址和具体接口类型后,通过网段判断所在厂区,通过mac协议的查询命令,从上到下的顺序查询的接口。(查询到接口后,要判断此接口的直连设备,如是交换机,需继续查询,如是电脑则完成查询)例如华为交换机:[kc_A15_209_S5120_62.253]displaymac-addressc03f-d5e0-cecaMACADDRVLANIDSTATEPORTINDEXAGINGTIME(s)c03f-d5e0-ceca117LearnedGigabitEthernet1/0/21AGING查询的MAC地址对应的VLAN得到类型具体接口老化时间---1macaddress(es)found---三,接口类型三,判断接口类型1,通过ndp或者LLDP协议查询例如ndp协议[kc_A15_209_S5120_62.253]displayndpinterfaceGigabitEthernet1/0/21查询命令(displayndp查询全部接口)Interface:GigabitEthernet1/0/21本设备具体接口Status:Enabled,PktsSnd:111108,PktsRvd:110282,PktsErr:0接口状态Neighbor1:AgingTime:164(s)邻居接口老化时间MACAddress:688f-84ed-1aefMAC地址PortName:GigabitEthernet0/0/28对应设备的具体接口SoftwareVer:Version5.160V200R006C10SPC100软件版本DeviceName:A15-2F-62.249设备名字PortDuplex:FULL接口速度状态(目前全双工)HardwareVer:S1720V200R006C10SPC100硬件版本查询结果三,接口类型三,判断接口类型1,通过ndp或者LLDP协议查询例如LLDP协议[kc_A15_209_S5120_62.253]displaylldpneighbor-informationinterfaceGigabitEthernet1/0/1查询命令LLDPneighbor-informationofport1[GigabitEthernet1/0/1]:Neighborindex:1Updatetime:14days,1hours,11minutes,16secondsChassistype:MACaddressChassisID:3822-d6e1-a203PortIDtype:InterfacenamePortID:GigabitEthernet1/1/1Portdescription:GigabitEthernet1/1/1设备接口的标识Systemname:kc_a15_s3100_62.233设备名字Systemdescription:H3CS3100-26TP-SI设备系统的标识Systemcapabilitiessupported:BridgeSystemcapabilitiesenabled:BridgeManagementaddresstype:ipv4Managementaddress:10.1.62.233对应于设备IP地址Managementaddressinterfacetype:IfIndexManagementaddressinterfaceID:519ManagementaddressOID:0PortVLANID(PVID):1……….查询结果三,接口类型三,判断接口类型2,通过接口类型判断通过查看该接口类型的来判断接口Trunk:代表该接口直连设备肯定不是电脑,而是其他支持Trunk口的设备,例如交换机,无线路由器等。Access:代表该接口直连设备可能电脑、非网管型的交换机,或者智能交换机Hybrid:查看具体配置来判断直连设备例如华为交换机:[kc_A15_209_S5120_62.253-GigabitEthernet1/0/21]displayinterfaceGigabitEthernet1/0/21GigabitEthernet1/0/21currentstate:UPIPPacketFrameType:PKTFMT_ETHNT_2,HardwareAddress:0cda-4117-21cbDescription:to_a15_62.249LoopbackisnotsetMediatypeistwistedpairPorthardwaretypeis1000_BASE_T1000Mbps-speedmode,full-duplexmodeLinkspeedtypeisautonegotiation,linkduplextypeisautonegotiationFlow-controlisnotenabledTheMaximumFrameLengthis9216BroadcastMAX-ratio:100%UnicastMAX-ratio:100%MulticastMAX-ratio:100%AllowjumboframetopassPVID:1Mditype:autoPortlink-type:trunkVLANpassing:1(defaultvlan),2-3,5,10,30,32,60-63,93,115-117,220,226,238,1000,1201,2000VLANpermitted:1(defaultvlan),2-4094Trunkportencapsulation:IEEE802.1qPortpriority:0Lastclearingofcounters:NeverPeakvalueofinput:45611912bytes/sec,at2000-07-0915:16:10查询结果三,接口类型三,判断接口类型3,通过查看mac协议判断如果通过mac-address命令查看,可以查看此接口下有多个mac地址存在,代表此接口直连设备肯定是交换机或者无线路由器,肯定不是电脑。[kc_A15_209_S5120_62.253]displaymac-addressinterfaceGigabitEthernet1/0/21MACADDRVLANIDSTATEPORTINDEXAGINGTIME(s)688f-84ed-1aef1LearnedGigabitEthernet1/0/21AGING001d-0924-2ad662LearnedGigabitEthernet1/0/21AGING4061-869d-dd1e62LearnedGigabitEthernet1/0/21AGING688f-84ed-1aef62LearnedGigabitEthernet1/0/21AGING100d-0e74-93b5117LearnedGigabitEthernet1/0/21AGING3497-f68d-082e117LearnedGigabitEthernet1/0/21AGING3497-f68f-91de117LearnedGigabitEthernet1/0/21AGING68f7-2888-6108117LearnedGigabitEthernet1/0/21AGING8825-93e2-d0a2117LearnedGigabitEthernet1/0/21AGING8825-93e2-d1cf117LearnedGigabitEthernet1/0/21AGINGc03f-d5e0-c5b6117LearnedGigabitEthernet1/0/21AGINGc03f-d5e0-c710117LearnedGigabitEthernet1/0/21AGINGc03f-d5e0-ceca117LearnedGigabitEthernet1/0/21AGINGd8cb-8a2a-5921117LearnedGigabitEthernet1/0/21AGINGe0d5-5e03-f76a117LearnedGigabitEthernet1/0/21AGINGf8bc-1279-1579117LearnedGigabitEthernet1/0/21AGING---16macaddress(es)found---查询结果四,确定端口四,确定端口1,通过以上命令,综合判断接口是否要查询的接口。1:[A15-2F-62.249]displaymac-addressC03F-D5E0-CECA-------------------------------------------------------------------------------MACAddressVLAN/VSILearned-FromType-------------------------------------------------------------------------------c03f-d5e0-ceca117/-GE0/0/12dynamic-------------------------------------------------------------------------------Totalitemsdisplayed=1例子2:[A15-2F-62.249]displaymac-addressGigabitEthernet0/0/12-------------------------------------------------------------------------------MACAddressVLAN/VSILearned-FromType-------------------------------------------------------------------------------c03f-d5e0-ceca117/-GE0/0/12dynamic-------------------------------------------------------------------------------Totalitemsdisplayed=