Bueno esta viendo unos ejemplos de c# y por accidente ejecute este que me cambia la ip local la máscara y la puerta, pero ahora ya no tengo acceso a Internet después que ejecute este codigo en mi los, intente reestablecer con CMD usando el comando ipconfig/release pero me dice que "no se puede realizar ninguna operacion...."
Y quisiera saber como revertir esto
string IPAddress = "192.168.1.101";
string SubnetMask = "255.255.255.0";
string Gateway = "192.168.1.254";
ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");
ManagementObjectCollection objMOC = objMC.GetInstances();
foreach (ManagementObject objMO in objMOC)
{
if (!(bool)objMO["IPEnabled"])
continue;
try
{
ManagementBaseObject objNewIP = null;
ManagementBaseObject objSetIP = null;
ManagementBaseObject objNewGate = null;
objNewIP = objMO.GetMethodParameters("EnableStatic");
objNewGate = objMO.GetMethodParameters("SetGateways");
objNewGate["DefaultIPGateway"] = new string[] { Gateway };
objNewGate["GatewayCostMetric"] = new int[] { 1 };
objNewIP["IPAddress"] = new string[] { IPAddress };
objNewIP["SubnetMask"] = new string[] { SubnetMask };
objSetIP = objMO.InvokeMethod("EnableStatic", objNewIP, null);
objSetIP = objMO.InvokeMethod("SetGateways", objNewGate, null);
MessageBox.Show("Updated IPAddress, SubnetMask and Default Gateway!");
}
catch (Exception ex)
{
MessageBox.Show("Unable to Set IP : " + ex.Message);
}
1º Seleciona el icono de red con el boton derecho (abrir configuracion de red y internet)
2º seleciona Ethernet
3º seleciona la red....1,2,
4º abajo puede configurar la ip, ponla en automatico