[Beowulf] How can i get the port number of a switch port via snmp?

Michael Di Domenico mdidomenico at gmail.com
Thu Sep 8 11:33:31 PDT 2005

I'll also echo Robert's statements about managed or unmanaged.  being
a network engineer by trade i have often written scripts in perl that
utilize linux and the net-snmp toolkit to query Cisco switches through
snmp and then setting a particuliar port as admin. up/down

i can't locate the perl offhand, but from the shell using net-snmp,
you can use the following commands to retrieve the interface status
and then snmpset the variable to change the interface into a down

snmpwalk -c $COMM $IPADDR ifDesc | grep "FastEthernet"

use this to get the instance from the ifDesc (ie ifDesc.0 ~ fastethernet0/0)

snmpget -c $COMM $IPADDR ifAdminStatus.0
snmpget -c $COMM $IPADDR ifOperStatus.0

use this to check the status for the ports

snmpset -v1 -c $COMM $IPADDR ifAdminStatus.0 = 2

use this to set the port into a down state

On 9/8/05, Robert G. Brown <rgb at phy.duke.edu> wrote:
> On Thu, 8 Sep 2005, Zhang Hui wrote:
> > Hi,all
> >
> >       I need to disable a switch port my machine is connected to. But first I have to know the port number,haven't i?
> >       So how can i get the port number?
> >       Or, anyone gets better ideas? Thanks a lot.
> Is your switch managed or unmanaged?  If unmanaged, I don't believe you
> can, at least in software -- unplug it is about all you can do (although
> you can also take down the connecting NIC).
> If managed, then it probably speaks SNMP.  I'm not an expert on SNMP but
> IIRC you may need a device specific toolkit to manage it, depending on
> who makes the switch and how portable they really made the interface.
> You might look here:
>   http://net-snmp.sourceforge.net/tutorial/tutorial-5/
> for starters -- I believe this is a linux/OS snmp toolkit that may do
> all that you need to do, with examples.
> Remember GIYF.
>    rgb
> --
> Robert G. Brown                        http://www.phy.duke.edu/~rgb/
> Duke University Dept. of Physics, Box 90305
> Durham, N.C. 27708-0305
> Phone: 1-919-660-2567  Fax: 919-660-2525     email:rgb at phy.duke.edu
> _______________________________________________
> Beowulf mailing list, Beowulf at beowulf.org
> To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf

More information about the Beowulf mailing list