How to set network devices priority on afp/smb transfers

afpethernetroutersmbwifi

I've got ethernet and wifi in the network devices. I use internet through wifi and file sharing over ethernet (we got an access point with DHCP and an ethernet switch with static IP – the access point and the switch are using two different subclasses) And yes, I got the LAN on the top of the devices priority.

We don't have any NAS, we just use the "File Sharing" feature on OS X.
What drives me crazy is the fact that when I click on the server list on the left sidebar in Finder I can connect to other iMacs, but – I don't know why – sometimes I connect through wifi and sometimes over ethernet.
I disabled gateway and DNS on the ethernet configuration, and for a while it seemed to fix the problem.

I solve it by disabling wifi, so OS X is forced to use only ethernet.
How can I force AFP/SMB sharing to use ethernet instead of wifi?
Should I look for some bonjour tweaking?
It would be great to block bonjour discovering over wifi.

Best Answer

Below is a network diagram based on what I have read thus far. I have made some assumptions about the IP numbering conventions, but that will have no effect on the overall scenario.

I am assuming that you are using two different subnets rather than 2 different classes of networks. But, either way, you have two very different network IP addressing schemes for your Ethernet network and another for your WiFi Network

enter image description here

Assumptions:

  • Wi-Fi is used to connect to the Internet. This means that your computer gets it IP, DNS and gateway settings via DHCP from the router.

  • The device (in this case the NAS) that you are transferring files to is on the Ethernet network and the addresses are set STATICALLY. That means the IP, DNS, and Gateway info must be manually configured.

What we don't know:

  • How the networks on the iMac are configured. Did you duplicate the DNS and gateway settings from the Ethernet to the WiFi?
  • How the network on the NAS is configured. Did you specify a DNS, and gateway here as well?
  • How the routers are configured. What did you use for gateway, DNS, route advertisement, etc.

All of this missing information plays a key role in why network traffic is taking the route it is taking.


What we know:

The key comment here is what @sekmo said

"....the problem is that when you try to reach a local resource, sometimes the machines use wifi instead of ethernet... "

The only way that a network adapter will forward traffic from one segment to another is if it knows about it. This means:

  1. The router is connected to the switch (the yellow line)
  2. The network route to get to 10.1.1.0 is being advertised to the clients on 192.168.1.0 by the router.

We also know that your computer (iMac) is not acting as a router because it already knows the routes to each network. It would NEVER send a file destined for the NAS through the WiFi router unless there was a connection between the two networks.

Why would your iMac choose WiFi for file transfer rather than the faster Ethernet?

The reason for this comes down to response time. If the computer you are transferring to has gone to sleep, it will take longer to respond back than the WiFi router which is always on. That's how your system automatically prioritizes traffic for you - it doesn't look for the fastest to transfer, it looks for the quickest to respond to it's request.

What you have done here is put two network adapters, even though they are addressed completely differently, on the same network. You would expect them to load balance, or prioritize traffic based on destination, but because the two networks literally overlap each other, you are creating a bunch of network overhead.

Solution

The easy solution would be to remove the connection between the WiFi router and the Ethernet router (yellow line). This way, neither router will advertise a path you don't want traffic to go down.

You also want to remove the DNS and Gateway settings from all the Ethernet connected nodes - there should be no reason for them to get to the Internet and you want only ONE path to the Internet and ONE path to your NAS.

(Disclaimer: You can create redundant networks, but that is outside the scope of this document and your question)

However....

This is not a recommended setup. There is no need to create a dual homed, multiple gateway network with Internet traffic and file transfer traffic going on completely different networks. Unless you are running a server which is doing multiple duty as a file server, web server, and Internet proxy, a single connection is more than sufficient.

If speed is that critical to you, look at getting multiple ETHERNET adapters and bonding them together - you will need to upgrade you switch to accommodate this.

And...

If you ARE running a server, WiFi for the Internet has to be the worst way to configure this.