Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

routing with more than one default gateway

Hi,

here is my problem:


usually I'm using Internet with WLAN-connection. Sometimes I want to connect my mac additionally with the LAN on work. As soon as I plug in the ethernet, there is a new item in the routing table, so I have two default-gateways - one to the WLAN-router and one to the standard-gateway of my work's LAN.


So for example I cannot take new mails from my private pop-account and for using internet I have to register a proxy-server. That's circuitous!


My idea is to create a plist-file in launchDaemons-directory, that deletes the default-gateway-item to my work's standard-gateway and adds a net-route to this only for my work's network.


Is it really a good idea or nonsens? What's a better way?


Thank you for your help!

MacBook Air, Mac OS X (10.7.3)

Posted on Feb 14, 2012 7:29 AM

Reply
1 reply

Feb 14, 2012 11:28 AM in response to gluxem

So you want to do dual-homing.


First remember that Macs really are setup, out of the box, to be a one connection at time machine. And, there is a service order for interfaces. Which you can set in Systems Prefs Network.


However, I think this is what you are looking for:


open a terminal and do:

sudo sysctl -w net.inet.ip.forwarding=1


This command will allow the Mac to use two defaults gateways. Then it will be up to you to populate the routing table with what route goes to what gateway.


To add a static route every time you boot (taking from Dr. V on techarena)


http://forums.techarena.in/operating-systems/1187193.htm


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.

routing with more than one default gateway

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.