Yesterday i had a situation that cause me headache for a while , I have a web server running win2k3 it has 2 NIC's
one of them assigned to public area network
and the other is not functioning
The place where the server is ,
is messy and cables on the floor so any one can stumble with
cables on the floor and indeed it happened somebody stumbled with the cable and unplugged it form the functioning NIC adapter when s/he returned the cable s/he didn't return it to the right functioning NIC adapter by the way both NIC are enabled
So i made a little trip to place where the server is and begun to do some troubleshooting if you can visualize the situation the unfunction NIC is enabled and it has private ip address so the the icons of connectivity are blinking so i didn't gave care to troubleshoot connectivity after a period i noticed that cable is plugged into the unfunction NIC
so i decided to write a tiny script to handle the situation if someone unplugged the cable and put it and in the unfunction NIC
a college of mine said you could simply assign the other NIC with same TCP/IP settings and he is right and yes its legal to assign same TCP/IP settings to different NIC but it must be disconnected i can do it and make my life much more easier but i decided to automate the process
and write batch script using netsh and automate it as cron job that's all
Code:
(netsh interface show interface | find /i "Local Area Connection" | findstr /B "Enabled" > nul && netsh interface show interface | find /i
"Local Area Connection" | findstr "Connected" > nul)
&& (netsh diag ping adapter 1 | find /I "Reply"
&& IF %ERRORLEVEL% == 0 echo extra check was successful )
|| (echo going to assign TCP/IP settings from a file & netsh -f c:\location1.txt && echo all is done)