View Full Version : Persistent Static Routes?
csdk0713
01-21-2005, 02:18 PM
Where do I add my static routes so that they will come back after a reboot? I have my default route defined correctly in /Library/Preferences/SystemConfiguration/preferences.plist. I would have assumed static routes would belong in there as well, but I haven't found an example of that.
- I'm not talking about routed at all...so don't suggest that.
- I don't want to modify the /etc/rc* scripts, because that's not the place for site-specific stuff
I guess this is a general OS X question, but the system I'm interested in right now is 10.3 Server.
Ideas?
Las_Vegas
01-21-2005, 07:03 PM
The process for creating multiple persistent static routes in Mac OS X is actually quite simple. Go to the Network preferences pane. Setup your Built-in Ethernet to your first static route. Go to Show : Network Port Configurations, select Built-in Ethernet and click Duplicate. Name it something like "Built-in Ethernet (2)" and save it. Repeat to create as many routes as you need. Now go to each new "Port" and set them up as needed.
csdk0713
01-24-2005, 04:15 PM
Simple!? You've gotta be kidding me. No offense, but that's about the least-intuitive way of adding a simple static route I've ever seen.
I can't see how adding what appears to be an aliased interface with it's own default route is going to help me here. I don't think you understood what I'm trying to do. I'm working with Xserve cluster nodes that don't/won't have a GUI. Don't get me wrong, I appreciate any help on this, but I just want to make sure we're talking about the same thing.
I've got one network interface. I've got a default route set. There are multiple routers on this network that connect to other subnets NOT through the default route. I can add static routes to these other subnets on the command line with something like:
Assuming my local subnet is 192.168.0.x...
route add -net 10.1.0.0 gateway 192.168.0.2
route add -net 10.2.0.0 gateway 192.168.0.3
This works fine, until I reboot...which is not good. I know I could add those lines to one of the rc scripts, but I don't get a good feeling about modifying those with site-specific config stuff. It seems like there would be a place specifically for static routes, like a .plist or something.
Again, I really do appreciate your help. I'm just somewhat frustrated that something this simple and basic hasn't been documented anywhere (that I can find.)
twm1010
01-25-2005, 08:52 PM
I too am searching for this config file...
twm1010
01-25-2005, 08:53 PM
Vegas: I take it the way mentioned above is also a clever way to have multiple default gateways?
csdk0713
01-26-2005, 08:40 PM
Yeah, that's the part that I didn't like. Your routing table should only have one default route. If you've got more than one, you've got problems.
I've got a call into Apple for their "official" answer on this, as I've been unable to find the answer anywhere and this should be basic Networking 101 stuff. When I hear back, I'll post the results.
Honestly, this is basic networking stuff. I'm more than a little surprised this isn't in documented better, especially on OS X Server.
hayne
01-26-2005, 08:50 PM
The command 'netstat -r' will show you the current state of the routing tables. There is of course only one default route.
I believe that what Apple has implemented is an automatic fail-over system. If you have more than one config entry in Network preferences set up to handle the same sub-net, then it tries the first one in the list and uses that as the default route if it works, otherwise proceeds to try the next one in the list, etc. This is why you can have an Ethernet config, an Airport config, a dialup modem config in the list and it will use whichever one it finds to work.
twm1010
01-27-2005, 08:24 AM
I'm calling Apple today about this, its a bit ridiculous. I've searched the hard drive over and over on where to find some kind of automatically loaded config file. I see a place in netinfo that might be a good place to put it but I'm unsure.
I mean... I could always stop being lazy and write a startup script to do this... but... the point is I shouldn't have to.
mattg
01-27-2005, 08:39 AM
I would really appreciate it if you could post the answer to this if Apple responds to you. I actually just posted the same exact question over on Macrumors (http://forums.macrumors.com/showthread.php?t=107339).
twm1010
03-03-2005, 01:47 PM
Ok Apple basically told me they didn't know what to do, and they referenced me to THIS thread. WTF... applecare sucks... anyway... I've boiled it down to trying to get /etc/crontab to execute a script i've written to add the routes, problem is I'm trying to get it to do it and it won't. I know the script works.
This is what I added to the top of /etc/crontab
@reboot root /bin/addroute
(addroute being the name of my script and for the sake of simplicity i dropped it in /bin)
anybody know what I'm doing wrong?
voldenuit
03-03-2005, 03:31 PM
Even if the OP excluded the option, the Unix way to do this would be an rc.local file called at the end of rc.
The Mac way to do that would be with a Startup-Item, involving the creation of a plist as documented here and elsewhere.
Getting to talk to second-level support at Apple would perhaps produce a more useful answer than what has been posted sofar.
It is entirely possible that Apple considers that people with multiple static routes are probably enough of a Unix-Wizard in the first place to get it to work without asking stupid questions :D .
Though I didn'd check, it is possible that the crontab entry gets executed too early in the boot process for the interfaces to be up. The two methods I mentioned are sure to be run after all (configured) interfaces are up.
mattg
03-03-2005, 03:31 PM
I finally got it to work. Yes, Apple support blows. After many phone calls and emails, I finally just gave up and took it upon myself to figure it out. I can't believe that they don't have a solution for something like this, something that is VERY common among Windows machines (and not *because* they're Windows machines...it's a common networking-related thing to have to do!!)
In the '/library/StartupItems" folder, I have an item (folder) that makes this static route. Mine is called "ICStart" (Wherever you see "ICStart", you can change that name to something else...whatever you want to call it...just make sure you stay consistent)
1.
In that folder, I've got a file called "ICStart"
In that file are these commands:
!/bin/sh
. /etc/rc.common
ConsoleMessage "Running ICStart"
/sbin/route add 10.0.0.0 10.1.1.1
/usr/sbin/QuickTimeStreamingServer
Obviously you'd need to change the IP information to match what you need. Also, the bottom line is in there because my server refuses to automatically start up QTSS on startup for some reason. You don't need that (unless you happen to be running a streaming server).
2. Also in the main folder, I've got a file called "StartupParameters.plist"
In that file are these commands:
{
Description = "Startup Tasks";
Provides = ("ICStart");
Requires = ("Network", "NetworkExtensions", "NFS", "DirectoryServices"$
OrderPreference = "Last";
Messages =
{
start = "Starting ICStart";
stop = "";
};
}
3. Lastly, in the "ICStart" folder, there is another folder called "Resources"
In the "Resources" folder, there's a file called "English.lproj"
There is nothing in that file. I don't know if it's necessary for it to even be there, but I'm leaving it.
You make the "ICStart" folder and everything in it property of the "root" user and the "Admin" group. That should do it for you.
Basically what I did was copy another Startup item I had, and changed the commands in it. Hope this helps...
http://homepage.mac.com/mattgudites/macrumors/term.jpg
spousi
03-03-2005, 03:59 PM
Im looking too, to have set two network interfaces to have two working gateways. Right know on both interfaces information are coming into the computer, but only on the first network interface the computer replays to answer. After studing some FAQs, the computer always sets up the system with the information in this plist:
/Library/Preferences/SystemConfiguration/preferences.plist
After each reboot, the system again reads the plist out and is reconfiguring the system, doesn't matter what you changed by line before.
I am very said to not able to modify the plist, because I don't know what to change or add. Maby some can help me too on doing that.
Thanks and good luck
Spousi
voldenuit
03-03-2005, 07:21 PM
You are aware of the fact that you can re-order the interfaces in the list by dragging the around in the preference pane ?
The first interface that works, wins.
That should cut it, I think.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.