image
image

Go Back   macosx.com > Mac Help Forums > Mac OS X System & Mac Software

Reply
 
Thread Tools
  #1  
Old January 24th, 2006, 03:35 PM
Registered User
 
Join Date: Jan 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
tiburm is on a distinguished road
Permanent Static Route Mac Os X 10.4.0

Hi friends, i want to know how I can put a static route in my system MAC OS X 10.4.0 when i restart my computer.

TXS
Reply With Quote
  #2  
Old January 24th, 2006, 05:59 PM
Giaguara's Avatar
Chmod 760
 
Join Date: Nov 2002
Location: ~
Posts: 7,734
Thanks: 2
Thanked 22 Times in 22 Posts
Giaguara is a jewel in the roughGiaguara is a jewel in the roughGiaguara is a jewel in the rough
Would these be of any help?

http://www.macosx.com/forums/archive...p/t-13926.html
http://forums.macosxhints.com/archiv...p/t-33745.html

To add a static route e.g.:

Code:
sudo route -nv add -net 192.168 -interface en0
To avoid having to do this everytime you reboot:

Code:
cd /System/Library/StartupItems
sudo cp -R NetworkExtensions NetworkLocal
cd NetworkLocal
sudo mv NetworkExtensions NetworkLocal
sudo vi NetworkLocal
- replace the startup section with the comand above:

Code:
#!/bin/sh

##
# Load network kernel modules
##

. /etc/rc.common

StartService ()
{
ConsoleMessage "Loading Network Local"
route -nv add -net 192.168 -interface en0
}

StopService ()
{
return 0
}

RestartService ()
{
return 0
}

RunService "$1"
sudo vi StartupParameters.plist
-- edit it to get

Code:
{
Description = "Network Local";
Provides = ("NetworkLocal");
Requires = ("Network");
OrderPreference = "None";
}

cd Resources/English.lproj
sudo vi Localizable.strings
-- edit it to get:

Code:
(?xml version="1.0" encoding="UTF-8"?)
(!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd")
(plist version="0.9")
(dict>
(key>Loading Network Local(/key)
(string>Loading Network Local(/string)
(/dict)
(/plist)
You could also edit the Network startup file and add the single line but that could get replaced if system is upgraded.
__________________
MacBook Pro + Mac mini | Newton 2000 | @Work : Dell D620 & 2x20" + a lot of Macs | Workstation, VC & Fusion
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do.
~ Samuel Clemens | Rants | Photos
Reply With Quote
  #3  
Old April 6th, 2006, 04:05 PM
Registered User
 
Join Date: Apr 2001
Location: Bellingham, Washington
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
roarkh is on a distinguished road
First I would like to thank Giaguara for the previous post, it has helped me more than any other I could find in setting up a persistant static route on Tiger.

I did run into a few gotchas that may have to do with changes Apple has made with updates or just unknown differences in our installations so I thought I would post my method in the hopes that it might help someone else.

I am assuming that anyone digging this deep into the system has probably enabled the root user so everything that follows assumes that you have opened a Terminal and typed 'su' to become root. Of course be very careful whenever doing anything as root on your system.

The first problem I ran into was that there was no /System/Library/StartupItems/NetworkExtensions on my system so I did not start with a copy of something Apple provided as Giaguara did.

So here we go...

Code:
cd /Library/StartupItems
I believe that /Library/StartupItems is a more correct location for 3rd party (non Apple) startup scripts so I am putting mine there instead of /System/Library/StartupItems.

Code:
mkdir AddRoutes
cd AddRoutes
Use your favorite editor (I recommend vi or nano) to create a file named "AddRoutes" containing the following being careful to replace the (in blue) "route" command with your route:

Code:
#!/bin/sh

# Set up static routing tables 
# Roark Holz, Thursday, April 6, 2006

. /etc/rc.common

StartService ()
{
        ConsoleMessage "Adding Static Routing Tables"
        route add -net 192.168.3.0/24 192.168.0.180
}

StopService ()
{
        return 0
}

RestartService ()
{
        return 0
}

RunService "$1"
Then, create the file "StartupParameters.plist" containing the following:

Code:
{
        Description     = "Add static routing tables";
        Provides        = ("AddRoutes");
        Requires        = ("Network");
        OrderPreference = "None";
}
Now we set up the proper permissions:

Code:
chmod 755 AddRoutes StartupParameters.plist
That's it. The stuff in "Resources/English.lproj" appears to be unnecessary, at least this works fine on my system (10.4.5 running on an iMac G5).

Reboot your computer and your route should be active. You can verify with a 'netstat -r' command on the Terminal.

Roark Holz
Reply With Quote
  #4  
Old June 13th, 2006, 10:25 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
osxis is on a distinguished road
Thank you very much roarkh... I followed step by step the instructions you posted ... but it still doesn't work.
With the netstat -r command I can see the route added in the routing table but when I try to reach the ip or the net tracert doesn't reach it.
Instead if I disable the startupitem and digit in the terminal the route add command it works...
What am I doing wrong or what is the tip ?

I'm going mad with this ... please help me
Reply With Quote
  #5  
Old June 13th, 2006, 04:13 PM
Registered User
 
Join Date: Apr 2001
Location: Bellingham, Washington
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
roarkh is on a distinguished road
I'm not sure why the route would not work if you can see it in the routing table.

I would definitely check the ownership and permissions on everything. Your mileage may vary but I have...

Code:
Roark-Holzs-iMac:/Library root# cd /Library
Roark-Holzs-iMac:/Library root# ls -l
--- Stuff Removed ---
 0 drwxr-xr-x     6 root    wheel     204 Apr  6 13:22 StartupItems
--- Stuff Removed ---


Roark-Holzs-iMac:/Library root# cd StartupItems
Roark-Holzs-iMac:/Library/StartupItems root# ls -l
drwxr-xr-x   4 root  wheel  136 Apr  6 12:50 AddRoutes


Roark-Holzs-iMac:/Library/StartupItems root# cd AddRoutes
Roark-Holzs-iMac:/Library/StartupItems/AddRoutes root# ls -l
-rwxr-xr-x   1 root  wheel  292 Apr  6 10:05 AddRoutes
-rwxr-xr-x   1 root  wheel  127 Apr  6 09:47 StartupParameters.plist


File contents...

Roark-Holzs-iMac:/Library/StartupItems/AddRoutes root# cat AddRoutes
#!/bin/sh

# Set up static routing tables 
# Roark Holz, Thursday, April 6, 2006

. /etc/rc.common

StartService ()
{
        ConsoleMessage "Adding Static Routing Tables"
        route add -net 192.168.3.0/24 192.168.0.180
}

StopService ()
{
        return 0
}

RestartService ()
{
        return 0
}

RunService "$1"


Roark-Holzs-iMac:/Library/StartupItems/AddRoutes root# cat StartupParameters.plist
{
        Description     = "Add static routing tables";
        Provides        = ("AddRoutes");
        Requires        = ("Network");
        OrderPreference = "None";
}
Is all of this similar to what you have?

Roark
Reply With Quote
  #6  
Old June 15th, 2006, 05:07 AM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
osxis is on a distinguished road
Yes everything is equal to that....
I solved it just adding sudo in front of route add and now it works ....

Someone suggested me an alternate method : use login item , but don't have a clue of how to do them.. do you have some hints about them ?
Reply With Quote
  #7  
Old June 28th, 2006, 10:26 AM
Registered User
 
Join Date: Jan 2006
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
tiburm is on a distinguished road
Hi Roarkh, I need help about the route.

I make in /Library/Startupitems/Addroutes the two files Addroutes and StartupParameters.plist with the same data like the exemple. But when i restart my computer never happen, the static route is not there. In my file Addroutes I put:

StartService ()
{
Console Message "Adding Static Routing Tables"
route add -n 192.168.0.0 192.168.0.10 255.255.0.0
}

with the others parameters, to add my route.

I make the new folder Addroutes in /Library/System/Startupitems, and i see in /System/Library/Startupitems that i haved a folder with the name StaticRoutes with a similiar script.

So my question is:
Where i put Addroutes?
I need remove the folder StaticRoutes in System/Library/Startupitems?

TXS
Reply With Quote
  #8  
Old October 30th, 2006, 04:11 PM
Registered User
 
Join Date: Mar 2005
Location: Warrington, UK
Posts: 124
Thanks: 0
Thanked 1 Time in 1 Post
andyhargreaves is on a distinguished road
Hi

Sorry to revive old threads, but I have tried all the suggestions here and on the other linked threads, and I cannot get any persistent routes at all. Has anyone any tips for making this work?? The routes I am adding do not show up in netstat -r after a reboot. The line I am using in the StartupItems subfolder is

Code:
sudo route -nv add -host 191.253.0.0 -netmask 255.255.0.0 -interface 192.157.10.241
I've also tried all variations with and without sudo, and with and without /sbin/route

Thanks

Andy
__________________
Macbook, 2.0GHz, 2Gb, 160Gb. 10.5
Mac Mini, 1.42GHz G4, 512Mb, 80Gb. 10.4

1G iPod Touch 8Gb
1G iPod Nano 2Gb white
1G iPod Shuffle 512Mb
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Static route bizantl Networking & Compatibility 0 December 11th, 2005 01:27 PM
permanent share jcombs_31 Networking & Compatibility 0 November 18th, 2005 02:23 PM
adding permanent static routes? vanyel Networking & Compatibility 1 July 22nd, 2005 08:01 PM
Help me fix my lan. I think I need a static route? Fahrvergnuugen Unix & X11 5 September 1st, 2002 11:03 AM
Adding static route lenoil Mac OS X System & Mac Software 5 March 6th, 2002 10:56 PM


All times are GMT -5. The time now is 05:54 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.