OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 18.7 Legacy Series »
  • Renew WAN interface via CMD or API
« previous next »
  • Print
Pages: [1]

Author Topic: Renew WAN interface via CMD or API  (Read 10204 times)

lewi3069

  • Newbie
  • *
  • Posts: 15
  • Karma: 2
    • View Profile
Renew WAN interface via CMD or API
« 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.
Logged

marjohn56

  • Hero Member
  • *****
  • Posts: 1676
  • Karma: 170
    • View Profile
Re: Renew WAN interface via CMD or API
« Reply #1 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.



Logged
OPNsense 21.7 - Qotom Q355G4 - ISP - Community Fibre 1Gbps.

Team Rebellion Member - If we've helped you remember to applaud

marjohn56

  • Hero Member
  • *****
  • Posts: 1676
  • Karma: 170
    • View Profile
Re: Renew WAN interface via CMD or API
« Reply #2 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.
Logged
OPNsense 21.7 - Qotom Q355G4 - ISP - Community Fibre 1Gbps.

Team Rebellion Member - If we've helped you remember to applaud

lewi3069

  • Newbie
  • *
  • Posts: 15
  • Karma: 2
    • View Profile
Re: Renew WAN interface via CMD or API
« Reply #3 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!

Quote from: 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.
Quote from: 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.
Logged

franco

  • Administrator
  • Hero Member
  • *****
  • Posts: 13936
  • Karma: 1208
    • View Profile
Re: Renew WAN interface via CMD or API
« Reply #4 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
Logged

marjohn56

  • Hero Member
  • *****
  • Posts: 1676
  • Karma: 170
    • View Profile
Re: Renew WAN interface via CMD or API
« Reply #5 on: January 10, 2019, 10:55:03 am »
There are many ways to skin a cat. :)
Logged
OPNsense 21.7 - Qotom Q355G4 - ISP - Community Fibre 1Gbps.

Team Rebellion Member - If we've helped you remember to applaud

Zeitkind

  • Full Member
  • ***
  • Posts: 178
  • Karma: 25
    • View Profile
Re: Renew WAN interface via CMD or API
« Reply #6 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>).
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 18.7 Legacy Series »
  • Renew WAN interface via CMD or API
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2023 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2