You can use telnet program for this way google "MinimalisticTelnet" and use example for understand this solution
Another way is use to SNMP Protocol such as this example :
Notice : for work with snmp i get change and customize SnmpSharpNet library , and call it in my program
using SnmpSharpNet;
Then write this code for disable ports from 1 to 6 :
Console.WriteLine("Ports Disabler ");
UdpTarget target = new UdpTarget((IPAddress)new IpAddress("192.168.1.200"));
Pdu pdu = new Pdu(PduType.Set);
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.1"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.2"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.3"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.4"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.5"), new Integer32(2));
pdu.VbList.Add(new Oid("1.3.6.1.2.1.2.2.1.7.6"), new Integer32(2));
AgentParameters aparam = new AgentParameters(SnmpVersion.Ver2, new OctetString("2645"));
SnmpV2Packet response;
try
{
// Send request and wait for response
response = target.Request(pdu, aparam) as SnmpV2Packet;
}
catch (Exception ex)
{
// If exception happens, it will be returned here
Console.WriteLine(String.Format("Request failed with exception: {0}", ex.Message));
target.Close();
return;
}
// Make sure we received a response
if (response == null)
{
Console.WriteLine("Error in sending SNMP request.");
}
else
{
// Check if we received an SNMP error from the agent
if (response.Pdu.ErrorStatus != 0)
{
Console.WriteLine(String.Format("SNMP agent returned ErrorStatus {0} on index {1}",
response.Pdu.ErrorStatus, response.Pdu.ErrorIndex) + response.ToString());
}
else
{
// Everything is ok. Agent will return the new value for the OID we changed
Console.WriteLine(String.Format("Agent response {0}: {1}",
response.Pdu[0].Oid.ToString(), response.Pdu[0].Value.ToString()));
}
}
I hope this answer be useful and can help you ,