OPNsense Forum
Archive => 20.1 Legacy Series => Topic started by: Amr on May 30, 2020, 09:13:52 am
-
Hello guys,
I'm trying to write a script to switch between gateways (the machine has only 1 wan interface) when one goes down by pinging a remote host, triggered by a cron-job.
my problem is I can't change the default gateway when I type
route delete default
route add default 192.168.1.1
and checking the gateway by typing
netstat -nr
It shows that the changes were made but going to the GUI nothing changed and by reloading the interface my changes are overwritten.
Also, I'd like to know the variable that holds the current gateway value.
-
Why don't you just add a second gateway with a lower priority? As soon as first fails, the second is used. No need for scripting.
https://docs.opnsense.org/manual/gateways.html
-
hello hbc,
Why don't you just add a second gateway with a lower priority?
Well I tried it once, but it didn't work so I assumed that the gateway group functionality is limited to multiple wan interfaces setup, and since I have only one wan interface (right now) I thought of scripting, If you can confirm that gateway groups work in single wan interface might give it a try.
thanks for your help.
-
I did not mention gateway groups. Just multiple gateways with different priorities. But gateway group should work, too.