OPNsense Forum

English Forums => Development and Code Review => Topic started by: ecor6633 on February 17, 2021, 02:20:51 PM

Title: API to renew DHCP when down
Post by: ecor6633 on February 17, 2021, 02:20:51 PM
Hello,

I'm quite new to OPNsense. I'm a developer facing occasionally the same issue so I'm trying to find a way to program a solution.

Fom time to time my WAN interface has its DHCP status down (I see it under Interfaces->overview->expand WAN/igb0) and it stops my internet connectivity. I see there a renew button which from now on has always solved the issue.

What I'd like to do is write a simple script that would check the status (down) of that DHCP and click on the renew button for me so I could run it periodically and solve the issue without even having to log into OPNsense UI.

I hope that /api/diagnostics/interface/getInterfaceStatistics will allow me to detect somehow the DHCP down. (Problem haven't occurred yet since I discovered that API) but then, if it works is there a way to trigger the renew from any API ?

By the way I post this in development because I'm trying a developer approach but if you have any other solution whatever it uses the API or not I'm interested.

Thanks a lot
Title: Re: API to renew DHCP when down
Post by: elcocoloco on February 22, 2021, 04:03:25 PM
Would start monitoring the gateway via API / CRON, which is more logical imho.

After that down and up interface

https://forum.opnsense.org/index.php?topic=10924.0