• 0
Sign in to follow this  
Hugo Jocelius

Monitorar Internet automaticamente (gateway)

Question

Compartilhando....

Num cenário onde seu pc usa ip fixo,
Voce tem duas internets ( ip dos routers 192.168.0.1 e .3 ),
Caso uma delas caia, voce quer que ela mude pra outra automaticamente sem gastar com hardware,

Crie um .bat com o codigo abaixo:

xxxxxxxxxxdel pingresult.txt
del ipconfig.txt
ping 8.8.8.8 > pingresult.txt
FINDSTR /m "Esgotado" pingresult.txt
IF NOT %ERRORLEVEL%==0 exit
ipconfig > ipconfig.txt
FINDSTR /m "192.168.0.1" ipconfig.txt
IF NOT %ERRORLEVEL%==1 goto SIM
IF NOT %ERRORLEVEL%==2 goto não

:não
netsh interface ipv4 set address "Ethernet" static 192.168.0.9 255.255.255.0 192.168.0.1
exit

:SIM
netsh interface ipv4 set address "Ethernet" static 192.168.0.9 255.255.255.0 192.168.0.3
exit


xxxxxxx

Crie um atalho para este .bat e coloque-o para que seja sempre executado como adm.

Configure o agendador do windows pra rodar o ATALHO a cada X minutos!

Espero ter ajudado!

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this