I am a fresh graduate and have just got my first job as a programmer in Hong Kong. As the topic described, I need to use C# to control the ports on the Cisco switch.
I have search and study for quite a long time so I have the basic knowledge about SNMP and MIB. I can find some articles talking about how to manage a cisco switch but none of them specified how do I enable and disable ports. At this moment I think I need to config the switch so that it enable the SNMP service, then I should send a SNMP Set packet to turn on/off the particular port. Is it correct?
Anyone have some experience on it and like to share with me? Please leave some suggestion. And if you have read some useful websites before, please kindly leave the url here so I can have a look too.
Thank you so much for your attention.
I know three methods (I am most fond of the first):
Option 1:
A common way to approach something like this is automated telnet (or automated ssh) to send the appropriate commands. IOS is pretty standardized for the most part and works quite well this way-
TCL's Expect package is perfect for this kind of thing... I imagine there is a C# implementation.
This works best if you are already familiar with IOS syntax.
Option 2:
This is probably what you want:
IF-MIB::ifAdminStatus is writable via SNMP
(Here is an example using NET-SNMP):
Interface UP:
snmpset -v1 -c community hostname IF-MIB::ifAdminStatus.interface i 1
Interface DOWN:
snmpset -v1 -c community hostname IF-MIB::ifAdminStatus.interface i 2
(Where 'interface' is a digit that represents a interface, the value is available in the same MIB- do a walk on 1.3.6.1.2.1.2.2.1.2 to find the interface values and descriptions.)
(Again there will likely be a C# implementation of snmpset you can leverage... and you must configure the SNMP communities on the device beforehand.)
Option 3:
It is possible to use SNMP to trigger an upload or download of config via a TFTP server.
This is sometimes used in this sequence:
1. download running config
2. alter that config
3. upload config
4. copy the uploaded config to the running config (overwrites what's active on the device)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With