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

Unable to set a gateway as default gateway #231

Closed
mitch40 opened this issue May 16, 2022 · 1 comment · Fixed by #230
Closed

Unable to set a gateway as default gateway #231

mitch40 opened this issue May 16, 2022 · 1 comment · Fixed by #230
Labels
backlog Issues backlogged for inclusion in future releases feature request New feature or request

Comments

@mitch40
Copy link

mitch40 commented May 16, 2022

I'm trying to set a gateway (named "TRUEWAN") as the default gateway (there is already a default gw defined on WAN iface, i want to replace it).

In the documentation, i didn't see information about that, so i've naively done a GET on /api/v1/routing/gateway/detail (i've removed unecessary code) :

{
   "status":"ok",
   "code":200,
   "return":0,
   "message":"Success",
   "data":{
       "WAN_DHCP":{
         "dynamic":true,
         "ipprotocol":"inet",
         "gateway":"192.168.201.9",
         "interface":"em0",
         "friendlyiface":"wan",
         "friendlyifdescr":"WAN",
         "name":"WAN_DHCP",
         "attribute":"system",
         "isdefaultgw":true,
         "monitor":"192.168.201.9",
         "descr":"Interface WAN_DHCP Gateway",
         "tiername":""
      },
      "TRUEWAN":{
         "interface":"em1",
         "ipprotocol":"inet",
         "name":"TRUEWAN",
         "nonlocalgateway":"",
         "gateway":"192.168.200.100",
         [...]
      }
   }
}

So, i've viewed isdefaultgw was set to True for WAN_DHCP gateway. I thinked i had just to set this parameter during the POST:

Data Request:
{'client-id': 'admin', 'client-token': 'pfsense', 'interface': 'em1', 'ipprotocol': 'inet', 'name': 'TRUEWAN', 'gateway': '192.168.200.100', 'monitor_disable': True, 'action_disable': True, 'isdefaultgw': True, 'apply': True}

Response:
{'status': 'ok', 'code': 200, 'return': 0, 'message': 'Success', 'data': {'interface': 'lan', 'ipprotocol': 'inet', 'name': 'TRUEWAN', 'nonlocalgateway': '', 'gateway': '192.168.200.100', 'monitor_disable': '', 'action_disable': '', 'monitor': '192.168.200.100', 'weight': 1, 'data_payload': 1, 'latencylow': 200, 'latencyhigh': 500, 'losslow': 10, 'losshigh': 20, 'interval': 500, 'loss_interval': 2000, 'time_period': 60000, 'alert_interval': 1000}}

BUT, setting this property seems to be ignored... What am i doing bad?

Capture d’écran 2022-05-16 195450

@jaredhendrickson13
Copy link
Owner

Hey!

Currently it looks like this feature does not exist. The /api/v1/routing/gateway endpoint only interacts with the gateway objects directly, and the /api/v1/routing/gateway/detail can only be used to read verbose details about the configured gateway. An entirely new endpoint to update the default gateway would need to be added since pfSense stores the default gateway settings in a separate configuration area. That being said, this may be a feature that is small enough to justify including in the next patch. I plan on releasing a patch later this week or early next week. I can do a little research and see what would be required. I'll keep this open as a feature request in the meantime.

There are also a couple potential workarounds if you need something sooner:

  1. You could try to update the gateway object that is currently set as the default gateway to use the interface, IP, etc. of your preferred gateway using a PUT request to /api/v1/routing/gateway. This may have undesired effects though and would not work with certain multi-WAN setups.
  2. You could create your gateway using the /api/v1/routing/gateway endpoint, and then use the /api/v1/firewall/rule to create rules with the gateway field set your new gateway. This would enable policy-based routing for the rule and route matching traffic out the correct gateway. This could be used to simulate a default gateway without actually setting the default gateway. This may not be ideal if you have many configured interfaces as each would need a rule routing it out the correct gateway.

Thanks!

@jaredhendrickson13 jaredhendrickson13 added feature request New feature or request backlog Issues backlogged for inclusion in future releases labels May 17, 2022
@jaredhendrickson13 jaredhendrickson13 linked a pull request May 22, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog Issues backlogged for inclusion in future releases feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants