Switch Port Control

Sometimes it can be handy to turn up or down a switch port. For example, you may want to play a prank on an annoying co-worker. Other times, it may be a case of disabling a host that is infected with a virus and spewing packets all over the network. Whatever the case may be, it can be helpful to have something like this in your toolbox.

Most people attach a serial cable from a laptop to the management port on the switch to configure it or manage it. To manage a switch via SNMP, you generally have to create a VLAN (which may encompass all the ports on the switch). This VLAN is configured with an IP address, which allows for SNMP access and control. The actual ability to manage a port comes via the Bridge MIB (RFC 1493). Most if not all switch vendors implement this MIB. Many vendors also have their own MIB that may enhance or extend the Bridge MIB, but we will focus on the RFC version to keep things generic.

To successfully manage a switch port, you have to know the following bits of information:

  • IP address of host on port

  • MAC address of host on port

  • Switch port number

The key to managing your switch ports is keeping track of which hosts are on which switch ports. Tobias Oetiker, creator of MRTG, created a Perl script called Cammer (http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/contrib/cammer). Cammer displays which MAC addresses are on a switch, along with IP address information. It does this by querying the Address Resolution Protocol (ARP) table on a router ...

Get Essential SNMP, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.