135

When I'm connected to two networks with separate routers using Wifi and Ethernet, how does my Mac know what connection to use when I visit a website?

0

6 Answers 6

105

From the Apple Support database article regarding network connection priority:

If you connect to the Internet or a network in several different ways (using Wi-Fi or Ethernet, for example), you can change the order of the network port configurations your computer tries when connecting to the Internet or network.

If there are multiple active network port configurations when you try to connect, OS X tries the one at the top of the list first, and then tries the other port configurations in descending order.

In that support article it is also described how you can change the priority order of network connections in System Preferences.

7
  • 2
    If ethernet is higher priority but disabled & Wifi is enabled & connected, what will happen when I plug in to ethernet? Will I disconnect from the network & reconnect? Or stay connected via Wifi? Aug 13, 2013 at 22:25
  • 1
    → anotherdave: the Wi-Fi interface will be turned down (equivalent of an ifconfig en1 down), and the Ethernet interface will be turned up (equivalent of an ifconfig en0 up). If this last one is based on DHCP, this will cause a DHCP request and answer (< 6 s). If any of your interfaces have intermitent drop out, this will lead to an endless interfaces switching and DHCP requests.
    – dan
    Aug 13, 2013 at 23:03
  • 2
    This doesn't explain how a user can know which interface is now used for outgoing trafic, when several interfaces are actives and connected.
    – dan
    Mar 26, 2015 at 8:09
  • 2
    Is ther eany way to route all ssh traffic over wifi and rest over en0 (LAN)?
    – BTR Naidu
    Jun 10, 2016 at 14:46
  • Just note. Since Apple engineers are stupid as, you can only use one interface at a time. And you need to order the one on top you want to use. If you try to access an IP that is not on the top most interface it simply will not work. Aug 6, 2020 at 16:31
79

It's in your Network Preferences. Here's screen shots from 10.7.3.

Access the settings from the gear at the bottom of the network type sidebar.

enter image description here

Choose "Set Service Order..." to drag them into the preferred order.

enter image description here

3
  • 5
    This doesn't explain how a user can know which interface is now used for outgoing trafic, when several interfaces are actives and connected. <br>With such a configuration the Wi-Fi icon in the menu bar may be full black when in fact all your network activity is going through the Ethernet! Such a configuration may create a network loop no user will ever be able to see and debug.
    – dan
    Apr 29, 2015 at 8:59
  • 1
    @danielAzuelos Sure, but that's not the question here. It's about how the Mac chooses, which is a priority based system. If the one on top is working, you're connected. In the main network panel, you can see what interfaces are connected and whether or not it's a successful connection. Cross-ref that with your priority list and you should have your answer. Apr 29, 2015 at 16:26
  • @plainclothes what if you connect / disconnect network interfaces? how does macOS behave? say I'm on wifi and then connect ethernet so now I have both. What happens with existing and now connections? what if I do the opposite? how does priority play into all of this?
    – majorgear
    Apr 12, 2022 at 17:06
20

I recommand you to never use a configuration where you may have at the same time different interfaces up on the same machine. You won't have any easy knowledge and control of this dual connectivity.

This may lead to huge difficulties to analyse even the simplest network trouble.

This may also cause loops within company or personnal networks very hard to diagnose. For example, have a look at the following command:

sysctl -a | grep forwarding

which will show you if IPv4 or IPv6 is going through your Mac from one interface through the other without your knowledge or control.

As much as possible define locations with the interface you know you want to connect to and switch on the right one at will:

Apple menu > Location > Home / AirPort
                      > Office / Ethernet
                      > outside / AirPort [unsecure]
                      > …


When 2 (or more) interfaces (for example Ethernet and Wi-Fi) are flagged green (Connected) within:

Apple menu > System Preferences… > Network

one way to know which one you are taking to reach the outside is the following line command (within a Terminal or xterm window):

route get default | grep interface
1
  • 2
    All the answers explain it on a different level. This one is the best because you can see the changes the computer is making when setting the order through the UI like in the screenshots from @plainclothes
    – J.Money
    Oct 25, 2014 at 0:05
7

The Service Order doesn't work. If you test it, you will find that Mac OS prioritizes Wifi over Ethernet, even if Ethernet is set higher in the Service Order.

One way to test it is to measure your bandwidth (e.g., https://www.fast.com) in the following scenarios:

  1. Connected to Wifi, with Ethernet unplugged
  2. Connected to Ethernet, with Wifi turned off
  3. Connected to Wifi and Ethernet

You will find that the speed from #2 is faster than #1 and #3. You will also find that #1 and #3 are the same speed.

The only solution is to disable WiFi when you connect via Ethernet and turn on Wifi when you disconnect Ethernet.

This script does that automatically!

https://gist.github.com/albertbori/1798d88a93175b9da00b

If you have any issues, search the comments for the error message you encounter. For example, I got the Path had bad ownership/permissions error, but the solution is posted in the comments.

2
  • 1
    1. wlan connected -> all data through wlan 2. wlan connected + lan connected -> all new data through lan, established connections stay an wlan.
    – teekkari
    Jan 16, 2021 at 21:53
  • My test also did not find what was hypothesized (on macOS Sonoma 14.0). Internet speed was fastest when Ethernet was plugged in, regardless of Wifi connection — 5 to 7 times faster than when only WiFi was connected. If you want to see the speedtest results: imgur.com/a/V9y94Ir
    – Nick Byrd
    Oct 25 at 13:35
-1

While this is true for some applications, what I experienced when I had connected my iMac to two ISP's - one wifi and another through LAN - applications like uTorrent and Games could apparently use both networks simultaneously. I got more download speed than individual connections and in case of multiplayer games, I could connect to servers with less lag and latency.

1
  • BitTorrent was built for multiple connections. But most everything else only uses one connection including games. Want proof? Watch your packets and which interfaces they use. Dec 9, 2015 at 16:51
-1

When my M1 iMac arrives, I will be connecting to my old 2013 27" iMac which I'm keeping until a 32-bit program's conversion to 64-bit is beta. I could use Wi-Fi or an ethernet cable (My old Mac has Thunderbolt-1). And I plan on doing some data transferring with my wife's newer iMac with a Thunderbolt-3 cable, carrying my Mac into her Mac's room.

I figure the Thunderbolt-3 is fastest, and Wi-Fi's slowest.

I'm guessing that I should turn off Wi-Fi while I'm doing the transferring, and that's all I will need to do. Is that correct?

1
  • 4
    Hi, you've mistakenly pressed the Post Your Answer button, while you have a new question. Please ask a new question, describing what issue you have and what you've looked into so far. Jun 3, 2021 at 15:22

You must log in to answer this question.

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