A switch is a layer-2 device. It works with MAC addresses and knows nothing about IP addresses.
A DHCP server will only have MAC addresses for devices that have requested an IP address. Servers, switches, printers etc. probably won't use DHCP.
Other ideas:
- If your subnet is small you could ping every address and look at the ARP cache in your host. This should find most things with an IP address, but not everything necessarily responds to a PING. For a large subnet this will be slow, and isn't really good practice.
- You could ping the multicast all-hosts address (224.0.0.1) and examine the ARP cache, but that will only find multicast capable devices.
- Ping the subnet broadcast address and examine the ARP cache. Again, not everything will necessarily respond.
Combining these approaches will probably get most things, but you'll have trouble finding, for example, a printer with a static address that doesn't respond to ping.
If you don't understand these terms find a tutorial on networking before you go any further.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…