Answer the question
In order to leave comments, you need to log in
How to fix the automatic route switching script?
At the input: a poorly readable script with automatic switching of interfaces with the Internet does not work out as it should, and, unfortunately, I am not strong in networks.
Everything lies here . The script itself is here .
The script works, except for this case: there is an IP on the first interface, the ping does not work, the whole thing switches to the second interface, but the route remains default. How to fix it? There is an opinion that it is necessary to either increase the metric or delete the route, but I won’t pull it myself, can you help?
Answer the question
In order to leave comments, you need to log in
The easiest way to switch from the main Internet provider to the reserve and back when restoring the first one:
#!/bin/sh
if ping -c 15 "ip на первом интерфейсе" | grep "100.0% packet loss"
then
route change default "ip шлюза второго интерфейса"
else
route change default "ip шлюза первого интерфейса"
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question