Joeri Verdeyen bio photo

Joeri Verdeyen

Web-engineer, cyclist, Nespresso lover, Strava pusher.

Twitter LinkedIn Instagram Github Stackoverflow Strava

Add persistent static routes on OS X Yosemite

When I setup my development environment with Docker, I’ll have to add a static route on every reboot. Here is a simple workaround on how to add a persistent static route on OS X Yosemite. This example will route all subnet-addresses 10.1.*.* traffic to the Vagrant machine with IP

Create a simple bash script

Create a new file /usr/local/bin/

vim /usr/local/bin/

Add the following lines in /usr/local/bin/ You can add more routes if you want to.

sudo route -n add -net

Make the script executable.

chmod +x /usr/local/bin/

Add the bash script to the LaunchAgents

sudo vim ~/Library/LaunchAgents/com.docker.scripts.routes.static.plist
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN>
<plist version="1.0">
        <string>Persist static routes workarround</string>

Load and enable the plist file

launchctl load ~/Library/LaunchAgents/com.docker.scripts.routes.static.plist


Check if the route is added after a reboot

$ netstat -nr  | grep ""
10.1/16         UGSc            0        0 vboxnet

Thanks for reading

Feel free to leave a comment if you have remarks or like this post