Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't modify/update/change WAN gateway using API #8417

Open
nbari opened this issue Mar 8, 2025 · 1 comment
Open

Can't modify/update/change WAN gateway using API #8417

nbari opened this issue Mar 8, 2025 · 1 comment
Labels
incomplete Issue template missing info

Comments

@nbari
Copy link

nbari commented Mar 8, 2025

Describe the bug

Can't change the WAN Gateway using the API.

In my attempts to automate this process, I tried this without success:

First, obtain current settings and save them into a file:

 curl -u "user":"pass"-s https://opnsense/api/routing/settings/get > current_gateway.json

I edited the file and updated the gateway field, later submitted data with:

 curl -u "user":"pass"- -d @current_gateway.json  -X POST -k -s https://opnsense/api/routing/settings/set 

It returns {"result":"saved"}

If I use the endpoint setGateway, for example:

https://<opnsense>/api/routing/settings/setGateway?uuid=625a757c-87e2-42d4-b1e3-607c9e0aa270"

I get: {"errorMessage":"Endpoint not found"}

I am trying to follow https://docs.opnsense.org/development/api/core/routing.html

Then I tried to reconfigure with:

curl -u "user":"pass"- -d "" -X POST -k -s https://opnsense/api/routing/settings/reconfigure 

Returned {"status":"ok"} but nothing changed.

To Reproduce

Genetare user/key to use the API then get the current settings:

    curl -u "user":"pass"-s https://opnsense/api/routing/settings/get > current_gateway.json

edit the gateway on the JSON and submit with:

     curl -u "user":"pass"- -d @current_gateway.json  -X POST -k -s https://opnsense/api/routing/settings/set 

Then try to reconfigure:

     curl -u "user":"pass"- -d "" -X POST -k -s https://opnsense/api/routing/settings/reconfigure 

notice I had to pass -d "" otherwise returned this error:

<!DOCTYPE html>
<html lang="en">
 <head>
  <meta charset="UTF-8" />
  <title>411 Length Required</title>
 </head>
 <body>
  <h1>411 Length Required</h1>
 </body>
</html>

Expected behavior

That the gateway is changed

Describe alternatives you considered

I also tried via SSH using:

route delete default

And then

 route add -net 0.0.0.0/0 X.X.X.Y

But it returns:

add net 0.0.0.0: gateway X.X.X.Y fib 0: Invalid argument

It only works If I set back existing WAN

Additional context

I am using OPNsense-25.1 in a Proxmox cluster, but every time the VM is moved to another node within the cluster, its WAN GW needs to be changed.

Wondering if WAN gateway could be changed with configctl?

I also added all the gateways as WANS (System: Gateways: Configuration) in the hope that dpinger automatically detects when the VM is down and uses the working gateway. However, I noticed that for it to work, I need to flush the states or do pfctl -F state.

Not sure if it is a bug in the API, but still can't find how via cli/ssh/api change the WAN IP. any ideas?

Environment

OPNsense 25.1.2-amd64 in proxmox VM
FreeBSD 14.2-RELEASE-p2
OpenSSL 3.0.16

@OPNsense-bot
Copy link

Thank you for creating an issue.
Since the ticket doesn't seem to be using one of our templates, we're marking this issue as low priority until further notice.

For more information about the policies for this repository,
please read https://github.com/opnsense/core/blob/master/CONTRIBUTING.md for further details.

The easiest option to gain traction is to close this ticket and open a new one using one of our templates.

@OPNsense-bot OPNsense-bot added the incomplete Issue template missing info label Mar 8, 2025
nbari added a commit to nbari/proxmox that referenced this issue Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete Issue template missing info
Development

No branches or pull requests

2 participants