Add static route at startup
Is there an easy way to add a static route each time I reboot my mac?
Cheers
Is there an easy way to add a static route each time I reboot my mac?
Cheers
Ah, that will cost extra! ;)
Barney-15E hit the nail on the head. That is you will want to load this script on boot by using a LaunchDaemon.
For example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.custom.staticroute</string>
<key>ProgramArguments</key>
<array>
<string>/etc/rc.local</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Let me reword the question.
How can I get this shell script to run at start up?
--- snip ---
❯ cat route.add.sh
#!/bin/sh
sudo route -n add -net <ip_block>/<netmask> <nexthop>
--- snip ---
"static route"?
"Static Route" as in configuring a specific network route for your Mac to take when communicating to the Internet?
You could create a LaunchDaemon plist to run your script.
You would not need sudo as a launch daemon is run as root.
Add static route at startup