有时候我们有机器的权限,但是想知道这台机器插到交换机的哪个口了,本身的VLAN是多少。 怎么办呢?

一句话解决:

tcpdump -i ens3 -s 1500 -c1 -nn -vvv 'ether[20:2]=0x2000'  

输出如下,对应的VLAN是101,插到了Gi1/0/39口,一目了然。

tcpdump: listening on ens3, link-type EN10MB (Ethernet), capture size 1500 bytes  
14:43:50.631178 CDPv2, ttl: 180s, checksum: 0x0edd (unverified), length 455  
    Device-ID (0x01), value length: 17 bytes: 'tokyo-c02.dedi.jp'
    Version String (0x05), value length: 261 bytes: 
      Cisco IOS Software, Catalyst L3 Switch Software (CAT3K_CAA-UNIVERSALK9-M), Version 15.2(2)E6, RELEASE SOFTWARE (fc1)
      Technical Support: http://www.cisco.com/techsupport
      Copyright (c) 1986-2016 by Cisco Systems, Inc.
      Compiled Sat 17-Dec-16 00:22 by prod_rel_team
    Platform (0x06), value length: 19 bytes: 'cisco WS-C3650-48TQ'
    Address (0x02), value length: 13 bytes: IPv4 (1) 10.224.7.252
    Port-ID (0x03), value length: 21 bytes: 'GigabitEthernet1/0/39'
    Capability (0x04), value length: 4 bytes: (0x00000029): Router, L2 Switch, IGMP snooping
    VTP Management Domain (0x09), value length: 5 bytes: 'tokyo'
    Native VLAN ID (0x0a), value length: 2 bytes: 101
    Duplex (0x0b), value length: 1 byte: full
    AVVID trust bitmap (0x12), value length: 1 byte: 0x00
    AVVID untrusted ports CoS (0x13), value length: 1 byte: 0x00
    Management Addresses (0x16), value length: 13 bytes: IPv4 (1) 10.224.7.252
    unknown field type (0x1a), value length: 12 bytes: 
      0x0000:  0000 0001 0000 0000 ffff ffff
    unknown field type (0x1f), value length: 1 byte: 
      0x0000:  00
    unknown field type (0x1004), value length: 15 bytes: 
      0x0000:  3730 3730 2e38 6265 612e 6162 3030 00
    unknown field type (0x1003), value length: 1 byte: 
      0x0000:  31
1 packet captured  
2 packets received by filter  
0 packets dropped by kernel  
1 packet dropped by interface  
comments powered by Disqus