[Solved] Persistent routes on Ubuntu 20

Oldirtyb Asks: Persistent routes on Ubuntu 20
I am trying to automate the addition of some static/persistent routes in Ubuntu 20 when setting up new hosts. The ip route command does not persist after reboot. The routes are based on a bond name for the ethernet. For example, bonds that contain “3110” get two specific routes added, and bonds that contain “5000” get two specific routes added, etc. I have a bash script that can cat the routes into a file based on the bond names but I am not sure of the best way to get that to run at boot. I thought about rc.local calling the script but rc.local on Ubuntu 20 requires a lot of additional setup. I am still learning a lot about Ubuntu 20 and I feel like there must be a super easy way to do this once at machine setup and then forget about it. Right now I am adding the static routes manually to /etc/netplan/50-cloud-init.yaml. I also considered a way to add these via puppet but came up with nothing easy because each of those yaml has machine specific variables like the mac address. Any input is greatly appreciated.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.