Unable to add a static route

Started by sunny, January 26, 2025, 07:03:46 AM

Previous topic - Next topic
January 26, 2025, 07:03:46 AM Last Edit: January 26, 2025, 08:58:13 AM by sunny
I have added a static route in the panel, however it doesn't show up in the status list, anyone know why?
https://imgur.com/a/GcnGTno

There is an error in the logs
Quote from: sunny/usr/local/etc/rc.routing_configure: The command '/sbin/route add -inet '100.100.0.0/16' '158.132.209.248'' returned exit code '1', the output was 'add net 100.100.0.0: gateway 158.132.209.248 fib 0: Invalid argument'

That likely means that you don't have a gateway declared with an IP address of 158.132.209.248. Fix that, and your static route should work.

System: Gateways: Configuration

The OPNsense UI for creating static routes requires that you select from already-defined gateways, so I don't think it's a case of it not having been defined. If it's not reachable (directly), it could cause that failure, though.

OP, what is (supposed to be) at 158.132.209.248? What output do you get from `route -n get 158.132.209.248` in a shell?

Quote from: bartjsmit on January 26, 2025, 09:59:43 AMThat likely means that you don't have a gateway declared with an IP address of 158.132.209.248. Fix that, and your static route should work.

System: Gateways: Configuration
I do have a gateway route
https://imgur.com/a/Twzdn8a

Quote from: dseven on January 26, 2025, 02:25:55 PMThe OPNsense UI for creating static routes requires that you select from already-defined gateways, so I don't think it's a case of it not having been defined. If it's not reachable (directly), it could cause that failure, though.

OP, what is (supposed to be) at 158.132.209.248? What output do you get from `route -n get 158.132.209.248` in a shell?

It is another router, which normally for windows I would do "ROUTE ADD 100.100.0.0 MASK 255.255.0.0 158.132.209.248" to route all traffic to that machine, but now I would like to do it in opnsense.

Here is the output of the command: https://imgur.com/a/jHfIBx8

Quote from: sunny on January 27, 2025, 06:30:57 AMI do have a gateway route
Is 158.132.209.248 the OPNsense WAN IP or is it on a router beyond the next hop? I don't think the standard routing supports source routes. You may have to look at FRR https://docs.opnsense.org/manual/dynamic_routing.html

So 158.132.209.248 is routed via your default gateway (10.22.36.2). Is that what you expect?

What are you trying to accomplish with your static route? Are you trying to force the path that the traffic takes over the internet (i.e. source routing)?

If you set the "Far gateway" option on the gateway that you created, your route for 100.100.0.0/16 should get added, but it's probably not going to work as you expect (unless your upstream default gateway knows what to do with it).

Quote from: dseven on January 27, 2025, 10:04:26 AMSo 158.132.209.248 is routed via your default gateway (10.22.36.2). Is that what you expect?

What are you trying to accomplish with your static route? Are you trying to force the path that the traffic takes over the internet (i.e. source routing)?

If you set the "Far gateway" option on the gateway that you created, your route for 100.100.0.0/16 should get added, but it's probably not going to work as you expect (unless your upstream default gateway knows what to do with it).

Thank you, after I enable the Far gateway option, everything works.