Adding persistent route on Ubuntu
I have to using VPN in my office for connecting to some services and add some routes to my Ubuntu routing table. But the routes will be removed after reboot. So I have to add them manually again. I googled that and find a solution for adding the routes when interface is coming up. You need to create a script under “/etc/network/if-up.d/”, for creating the script, follow the below steps: 1. Create script file by using “cat” command or other text editors: #cat > your-script-file #!/bin/bash route add -net x.x.x.x netmask x.x.x.x gw x.x.x.x route … route … CTRL+D (For saving file) Make the script file as an executable script file: #chmod +x your-script-file Then restart networking service or unplug and plug your network and run “route -n”. If the routes network are available, then the routes will be added to routing table. Note: You script should be saved without “.sh”. I tested it on Ubuntu 14.04. Run the below command for test: run-parts –test /etc/network/if-up.d