Results 1 to 4 of 4

Thread: Adding static route on Mac OSX

  1. #1
    Join Date
    Jan 2009
    Posts
    58

    Adding static route on Mac OSX

    If I am adding static route on some of the MAC clients which have MAC OSX 10.4, it runs properly but when the machine is rebooted, the static route does not remains. What can I do to keep it at static route?

  2. #2
    Join Date
    Jan 2008
    Posts
    3,388

    Re: Adding static route on Mac OSX

    The problem with adding static routes in CLI on Mac OS X is that it is volatile and will disappear on reboot. To solve that problem you have to add the command in some sort of script and run it on start up. Here we run into the next problem, adding static routes doesn't work if the link isn't up on the network card.

    I have solved that problem with a Startup Item written specifically for each situation with the criterias given at that time. That might not be the best solution for you but it has always worked for me. I have used it in 10.3.x and 10.4.x. There might be other better ways to solv the problem.

  3. #3
    Dr. V Guest

    Re: Adding static route on Mac OSX

    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.


    Courtesy: MacOSX Forums

  4. #4
    Join Date
    Nov 2005
    Posts
    3,026

    Re: Adding static route on Mac OSX

    You'll need to switch to root to have appropriate permissions;
    sudo route add 192.168.2.0/24 192.168.1.1

    where 192.168.2.0 is the subnet you want to add the route to, 24 is the 24 bit subnet mask and 192.168.1.1 is the gateway.

Similar Threads

  1. How to add the Static route for the service port of Cisco WLC 4400?
    By Super-Man in forum Networking & Security
    Replies: 5
    Last Post: 31-12-2011, 07:10 PM
  2. How to configure a static route on packet tracer
    By Raffaele in forum Networking & Security
    Replies: 3
    Last Post: 01-08-2009, 07:51 PM
  3. Cannot Add Static Route on Cisco Router
    By Aarya in forum Networking & Security
    Replies: 3
    Last Post: 28-11-2008, 07:35 PM
  4. DHCP Static route
    By ¡!Aidemin!¡ in forum Windows Server Help
    Replies: 4
    Last Post: 14-11-2007, 01:15 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,199,990.42163 seconds with 17 queries