Route Add For Mac Os X
ref: http://nellen.it/blog/2012/01/permanent-static-routes-for-mac-os-x/
Route Add For Mac Os X 10.13
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 172.17.8.101. Free download Travel - Route Planner Travel - Route Planner for Mac OS X. Travel - Route Planner - ★★★ No.1 Most Paid travel app in US Mac App Store ★★★ ★Features★. Easy to use planning tool.
cd /Library/StartupItems
sudo mkdir ./AddRoutes
cd ./AddRoutes
Mac Os Route Command
sudo touch ./AddRoutes
sudo nano ./AddRoutes
#!/bin/sh
# Set static routing tables
. /etc/rc.common
StartService ()
{
sleep 10
ConsoleMessage “Adding Static Routing Table”
sudo /sbin/route add -net 10.0.0.0 -netmask 255.0.0.0 -gateway w.x.y.z
}
StopService ()
{
return 0
}
StopService ()
{
return 0
}
RestartService ()
{
return 0
}
RunService “$1”
sudo touch StartupParameters.plist
sudo nano StartupParameters.plist
{
Description = “Add static routing tables”;
Provides = (“AddRoutes”);
Requires = (“Network”);
OrderPreference = “None”;
}
sudo chmod 755 /Library/StartupItems/AddRoutes/*
sudo chown -R root:wheel /Library/StartupItems/AddRoutes
netstat -nr
When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.
Specific cases
Case 1: conflicting additional routes.
In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:
In the above case the VPN is a PPTP VPN that uses ppp0 as the network interface. With this additional route, I can now access all the hosts I need to on the VPN. This won't solve the case of trying to access addresses on the 10.0.y.0/24 subnet though.
Case 2: conflicting subnet between VPN and local network.
Fairly often a VPN on a private address space subnet can end up conflicting with a local subnet. For example if both the remote and local networks share the 192.168.0.0/24 subnet then our VPN connection ends up being pretty useless as all of the remote addresses will end up being routed to the local network device.
It is possible to get around this in some cases as long as the VPN IP address doesn't conflict directly with a local IP address that you need access to. In this case we need to add a specific route for the remote IP:
In the above case I'm routing the host 192.168.0.x (replace the x with your specific address) via the tun0 device (in this case an OpenVPN connection).
Useful commands to debug routing issues.
The following command will show the existing routing table (IPv4 only):
The following command will show you how a specific host will get routed: