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, ports not used based on company policies must be closed.
This makes it necessary for me to clearly understand the usage of each port. What should I do?
First, I want to see the IP address of the host connected to each port on the vswitch. However, as you know, the vswitch does not have this function, however, you can see the MAC address corresponding to the port, but if the port is active. Although the results can be seen by simply using show mac add, there will also be a lot of unnecessary information. here we can use pipeline commands (I have found this for a long time !!)
Show mac add | include Fa include is the key times of 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.
Cd \ set a = 1: begin ping *. *. *. % A % arp-*. *. *. % A % | findstr "dynamic ARP"> mac-ip.log set a = % a % + 1 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 the same. 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 SEPM (Symantec Endpoint Protection Manager) is directly available.
After obtaining the information, you can associate them. I did this in excel (not afraid of jokes, 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.