Who is the other end of the vswitch port?

Source: Internet
Author: User

The company's UTP access points are far more than the access layer switch ports, and employees often adjust their positions for some reason, which forces us to change ports on the switch to meet their needs, however, based on the company policy, unused ports must be closed. This makes it necessary for me to clearly understand the usage of each port. What should I do?

First of all, I want to see the IP address of the host connected to each port on the vswitch. But you know that the vswitch does not have this function, but you can seeMAC address corresponding to the portBut if the port is active.

Simple use

 
 
  1. show mac add 

Although you can also see the results, there will be a lot of unnecessary information, here you can use the pipeline command this I have been looking for a long time to find !!)

 
 
  1. Show mac add | include Fa
Include is the key to the command, while Fa is the keyword you want to filter in the result. It is case sensitive and character-sensitive.

This shows the relationship between the port and MAC.

How can we find the relationship between MAC, IP, and host name?

The first thing I think of is the ARP Protocol. But how can I use it? I used batch processing.

The principle is to ping the target IP Address by using the ping command so that it has arp records in the local cache, and then use the ARP command to display the correspondence between the IP address and MAC address. This record will not exist if there is no communication between the local host and the target host before ARP is used .) Redirects the output result to the text, but there is a problem: how does bat implement loops? Here I think of the for and variables in C language. This knowledge point gives me some ideas .) This is used for the set and goto statements.

 
 
  1. cd \ 
  2. set a=1 
  3. :begin 
  4. ping *.*.*.%A% 
  5. arp -a *.*.*.%A% |findstr "dynamic ARP" >> mac-ip.log 
  6. set a=%a%+1 
  7. goto begin 

This command can only find the MAC of the host with the same network segment. If there are multiple network segments, you know how to do it.

Don't look at this short piece of code. I 've been studying it for a long time. I used to be very dismissive about DOS. Now I find that scripts are a good thing and I can't do without it anymore, however, I found that many things are connected. C language is really a good thing. I have always been a loyal fan of it because it has given me a lot of computer ideas, in my opinion, it is one of the three treasures of the network administrator ).

The above method is basically not used unless there is no DHCP. But we did. A few days later, I thought of this problem. DHCP directly listed the corresponding IP address and MAC address, and exported the list. I was so depressed!

The corresponding host name and IP address are cheap, and SEPMSymantec Endpoint Protection Manager) is available directly.

After obtaining the information, you can associate them. I am not afraid of making jokes in excel. I 've been doing this for a long time, I was despised by my colleagues.) I mainly used text to columns (this is not worth mentioning for anyone I know) and VLOOKUP functions. Finally, the two are linked.

This article is from the "heartache cainiao" blog and will not be reposted!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.