OPNsense Forum

Archive => 18.7 Legacy Series => Topic started by: lewi3069 on January 08, 2019, 10:52:25 pm

Title: Renew WAN interface via CMD or API
Post by: lewi3069 on January 08, 2019, 10:52:25 pm
I have AT&T gig fiber. Their "awesome" modem doesn't support direct passthrough. So you have to configure IP passthrough to get the public IP on the WAN interface. If we loose power the OPNsense box reboots quicker than the ONT and I don't get a public IP until I reboot OPNsense again. This is an issue for things like remote access VPN. Is there an easy way to force a renew or reboot with the API or over SSH so I can build a reboot or renew script.
Title: Re: Renew WAN interface via CMD or API
Post by: marjohn56 on January 08, 2019, 11:31:26 pm
You could use the same as I do, use a Cron event to run  a script that ping checks a wan address such as google's dns server. minw runs every ten minutes, but you can shorten that in the cron entry if you like.


Attached are the script and the config file for adding the cron event. It reboots opnsense if it cannot get a ping response.


Drop the ping_check.sh in /usr/local/sbin

Drop the actions_ping_check.conf in /usr/local/opnsense/service/conf/actions.d/

Goto the shell and select 11, reload all services.

Now go and add a new Cron event, select ping_check as the command, description is whatever you like and set the minutes to whatever, I would not go lower than two.

Note it double checks so it takes about 3 minutes for a reboot to happen.



Title: Re: Renew WAN interface via CMD or API
Post by: marjohn56 on January 09, 2019, 08:49:31 am
forgot to add..


you can just take the interface down and back up using



 ifconfig igb0 down

 ifconfig igb0 up


Of course you need to make sure that the interface id is correct.. in my case it is igb0.
Title: Re: Renew WAN interface via CMD or API
Post by: lewi3069 on January 09, 2019, 10:55:56 pm
This makes sense and should work for this solution. I think I'll just the to modify the script slightly to do an external dyndns check. Thanks!

I have AT&T gig fiber. Their "awesome" modem doesn't support direct passthrough. So you have to configure IP passthrough to get the public IP on the WAN interface. If we loose power the OPNsense box reboots quicker than the ONT and I don't get a public IP until I reboot OPNsense again. This is an issue for things like remote access VPN. Is there an easy way to force a renew or reboot with the API or over SSH so I can build a reboot or renew script.
forgot to add..


you can just take the interface down and back up using



 ifconfig igb0 down

 ifconfig igb0 up


Of course you need to make sure that the interface id is correct.. in my case it is igb0.
Title: Re: Renew WAN interface via CMD or API
Post by: franco on January 10, 2019, 09:53:23 am
The command is:

# confligctl interface reconfigure wan

Where "wan" is the internal interface name "wan", "lan", "opt1", "opt2", etc.


Cheers,
Franco
Title: Re: Renew WAN interface via CMD or API
Post by: marjohn56 on January 10, 2019, 10:55:03 am
There are many ways to skin a cat. :)
Title: Re: Renew WAN interface via CMD or API
Post by: Zeitkind on January 10, 2019, 06:28:30 pm
I somehow miss an easy way to renew a DHCP or xDSL-connection anyway. It's always a pita to troubleshot connection problems, reboot is more or less the only safe way to check if WAN/ISP fails or something else goes wrong. I'd really like to have a dedicated status page for DHCP & xDSL-DHCP with only for DHCP and PPPoA/E relevant log entries and esp. the PPPoE/A replies (like PADI/PADO etc.). And a simple button with "Reconnect" or "Renew IP". Even many cheap plastic routers offer a better GUI.. :(
Same for status of a WAN-DSL-combo interface. The (virtual) DSL-interface is never shown as connected, I added a dummy WAN-interface (static IP) to check the (physical) connection status (like 1000baseT <full-duplex>).