If you want to push routes to your client, the easiest way to do so would be adding a classless static route (DHCP option 121) as defined in RFC 3442. Every router has their way of setting these but usually they have one thing in common - you must do so manually. And yes, if you make a single mistake, your Internet connectivity will be lost.
Issue of easy entry has bothered me for long enough to actually do something about it. Below find classless static route option calculator. Just enter routes you want and you will get their hexadecimal representations.
Network | Gateway |
---|---|
Default | |
…
[2019-12-13: Updated script to have default route first (workaround for Ubuntu 19.10 Server).]
[2020-12-26: Added OpenSense/Ubiquiti notation.]
[2022-07-22: Fixed to allow for /32 network.]
Very good calculator, exactly what I was looking for.
I had one problem when using it: in the network field it doesn’t accept /32 addresse, whihc is relevant for example in cloud environment (169.254.169.254/32).
And a feature request for OpenSense and simmilar the format for entering is: 00:c0:a8:37:01:20:a9:fe:a9:fe:c0:a8:37:fe it would be good to have an xxxSense code section as well.
I agree. I need the same /32 notation.
Hey thanks for the workaround comment – saved me a load of troubleshooting. I didn’t realize Ubuntu would need the combined string with default first.
Thank you, it works well
I second that request for the “Hex array” notation @Lacó asked for. It applies to Ubiquiti Unifi routers as well, and trivial as it may seem, one can unintentionally overwrite a digit in that string, and that could ruin your whole day… :) Either way, big thanks for you effort!
Added per popular demand. :)
Hi
Are u ok if i use this tool on a specific webpage ?
Like: https://www.nboquestal.fr/outils/route-calculator/
Of course you are credited on this page.
Thanks for your job! You have make my day!
Feel free to.
Script still does not work for single IPs (or /32) …
Fixed, thanks!
Almost! It seems to be dropping the first octet /32 addresses in the destination descriptor.
Also, for weirdos like me, it would be awesome if the default route option had a checkbox beside it to include/omit it.
You can just delete value in default gateway field and use one next to each item. That should work.
Fixed. Sorry for that.
Thanks for this! Made things a breeze for using with OPNsense.
https://github.com/mullvad/mullvadvpn-app/issues/3827#issuecomment-1332728058
hi, for fortinet router the output is without “0x” in front
Thanks so much for this. I thought a CLI utility for this sort of thing might be nice, so I wrote one over the weekend. It’s up here: https://github.com/chrislea/staticrouter
It doesn’t share any code, but I referenced you here anyway since using this was what put the idea in my head. :)
Thanks again!