I have two network devices aboard my macbook pro:

  • WIFI (en1): Used for general traffic. Connects to an ip of 192.168.19.* via DHCP
  • LAN (en0): Used for specific traffic. Connects to an ip of as a static IP. Does not connect to a router, only a switch for direct routing connection.

I have 4 IP addresses I need to access on the LAN:


The rest of the traffic needs to go to Wi-Fi. I have tried setting up a routing table for the specific ip addresses, but I only managed to mess up my network. I do not venture out into the world of networking too often, but this was the latest command I have been trying:

sudo route add -host -interface en0

This command killed my ability to use ping. It told me that ping could not allocate memory (is that even possible)? It also killed my wifi access. Logging out and back in fixed the issue. I really do not mind to make this solution permanent, so I am fine with a temporary routing.


If I currently have been trying:

sudo route flush
sudo route add default

This gets everything to work for about a minute. But after such minute it "forgets" the routing to WiFi while retaining LAN's (en0) routing. If I unplug and replug my LAN (en0) cable, the process works for another minute.


These were some of commands entered as a request by d34dh0r53.

$ netstat -rn
Routing tables

Destination        Gateway            Flags        Refs      Use   Netif Expire
default          UGSc            4        0     en0
default         UGScI           0        0     en1
127                UCS             0        1     lo0          UH              5  1429023     lo0
169.254            link#4             UCS             0        0     en0
192.168.2          link#4             UCS             4        0     en0        0:27:22:2e:5f:1a   UHLWIi          2        0     en0   1199          UHS             0        0     lo0       90:a2:da:0:f5:63   UHLWIi          1     1433     en0   1191      ff:ff:ff:ff:ff:ff  UHLWbI          0        7     en0
192.168.19         link#5             UCS             2        0     en1       3e:d0:f8:aa:28:56  UHLWIi          0        2     en1   1192          UHS             1        0     lo0     ff:ff:ff:ff:ff:ff  UHLWbI          0        5     en1

Destination                             Gateway                         Flags         Netif Expire
::1                                     link#1                          UHL             lo0
fe80::%lo0/64                           fe80::1%lo0                     UcI             lo0
fe80::1%lo0                             link#1                          UHLI            lo0
fe80::%en0/64                           link#4                          UCI             en0
fe80::226:4aff:fe00:b68a%en0            0:26:4a:0:b6:8a                 UHLI            lo0
fe80::%en1/64                           link#5                          UCI             en1
fe80::226:bbff:fe03:cbd%en1             0:26:bb:3:c:bd                  UHLI            lo0
ff01::%lo0/32                           fe80::1%lo0                     UmCI            lo0
ff01::%en0/32                           link#4                          UmCI            en0
ff01::%en1/32                           link#5                          UmCI            en1
ff02::%lo0/32                           fe80::1%lo0                     UmCI            lo0
ff02::%en0/32                           link#4                          UmCI            en0
ff02::%en1/32                           link#5                          UmCI            en1
$ traceroute -n
traceroute to (, 64 hops max, 52 byte packets
 1  2.499 ms  3.392 ms  3.829 ms
$ traceroute -n google.com
traceroute: unknown host google.com
  • The OS handles routing, not the hardware. Jun 15, 2012 at 20:23
  • Is everything 192.168.2.X on the LAN? If it is, that makes the solution much simpler.
    – LawrenceC
    Jun 15, 2012 at 20:36
  • @ultrasawblade Yes, everything on that network is 192.168.2.* Jun 15, 2012 at 20:56

3 Answers 3


You shouldn't need to create any routing rules by hand for that configuration, provided that all the 192.168.2.x addresses you want to communicate with are down the interface with the 192.168.2.x address.

  1. Go to System Preferences -> Network
  2. Select your Ethernet device, make sure "Configure IPv4" is set to "Manually", that your subnet mask is set to, and that the router box is empty.

Once this is done, netstat -rn should still show the routes for both of the subnets, but only a "link#4" route in place of the default route through

If you don't want a default route, leave the router box blank. The value in the router box is only used to set up a default route through this network interface, and it isn't used for anything else.

  • Thank you! That was it! I had everything set up properly except for the in the router field. I put in the ip address in the router field to match a "router" on the lan side. I thought it was required, but I see now that it took over the default route for general traffic. Jun 26, 2012 at 17:37
  • Thanks for this! Had the same problem and worked for me perfectly. Aug 11, 2015 at 12:34

The problem is that your en0 interface is adding a default route which is taking precedence over the default route established by the 802.11 interface. I'm not exactly sure why, but it's either the fact that BSD is preferring a wired interface over a wireless one, or it's preferring a statically configured interface over a dynamically configured one. You can tell that the en0 default route is being used by the Refs column; Refs is a metric indicating the current number of active uses of the route, so we can see that it's getting all of the traffic.

The solution is to remove that route, preferable permanently from the routing table so that traffic that is destined for hosts other than those on your local networks traverses the default gateway established by DHCP on en1. The first thing I would check is in the configuration panel for en0 make sure that you have not entered anything in the router field. The information in that field is added as a default gateway. If that does not work we need to manually delete the route, the reason that route flush does not work is that I believe it tells OS X to reload it's routing information from the interface configuration files, hence reverting your change after a short time. The following command should remove the default route for the en0 interface until either networking is restarted or the system is IPLed:

sudo route delete -net

If you want to make this change permanent you can either a) create a service in /Library/StartupItems which seems like too much work to me or b) add that line to /etc/rc.local with a command such as:

echo 'route delete -net' >> /etc/rc.local

You may need to add a sleep <number_of_seconds> command before that line in /etc/rc.local to avoid running the command before the interfaces are fully up and the routing table established.

Hope this helps and good luck!

  • Thank you for your lengthly response. The default route to was the problem, but @rakslice found that I made a mistake while entering my routing information for the en0 connection. I put the ip address in the router field in the believe that it was required. After removing the default router ip, I also removed the bad default route to Again, thanks for your help. Jun 26, 2012 at 17:48
  • 1
    Kind of bummed I didn't get the bounty: "The first thing I would check is in the configuration panel for en0 make sure that you have not entered anything in the router field. The information in that field is added as a default gateway." But it's all good in the end, glad you got it working.
    – d34dh0r53
    Jun 26, 2012 at 19:13

You want to set your Wifi IP as your default gateway, and remove any default gateway (or route to connected to the LAN or

This is of course easier if you can set your en1 to a fixed IP that will work with the wifi.

You might have to add as a route to the network. However, this should be automatic since it can tell that is directly connected by virtual of what you assigned to the interface.

So traffic going to any 192.168.2.X will go out of, and traffic going anywhere else will go out of your en1's IP address.

  • I set my wifi order to the top via the network sys preferences. But I am not sure how to remove any default gateway connected to the LAN. Jun 15, 2012 at 21:22
  • maybe sudo route del default, not exactly sure how to do it on freebsd/mac osx but it should be similar.
    – LawrenceC
    Jun 16, 2012 at 3:31
  • The command on mac is sudo route delete default Ping is still active. However, it shutdown access to the wifi traffic excluding the router ip. Jun 16, 2012 at 20:25
  • You get internet through your wifi, correct, i.e. if you don't connect via LAN and only Wifi, you can reach external sites like Google, etc.?
    – LawrenceC
    Jun 17, 2012 at 1:10
  • Yes, WiFi is for general traffic such as google.com (primarily for the google maps api) Jun 17, 2012 at 4:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .