Skip to main content
Solved

Set network interfaces order


Forum|alt.badge.img+8

Hi all,
I'm facing an issue for the Macs of my company.
I need to set up the network service order for the different interfaces.
The main goal is to setup the interfaces as follow:
1- Ethernet (built in, Thunderbolt or USB)
2- Wifi
Basically I need to set up as primary interface any Eth connection detected and as secondary the Wifi. All the others can follow.

Does anyone has a solution/suggestion for this?
Thanks everybody.

Cheers,
Jack

Best answer by jrwilcox

That should be the default for OS X.

View original
Did this topic help you find an answer to your question?

6 replies

Forum|alt.badge.img+8
  • Contributor
  • 82 replies
  • Answer
  • July 27, 2015

That should be the default for OS X.


Forum|alt.badge.img+18
  • Valued Contributor
  • 1007 replies
  • July 27, 2015

I have a perl function that does it like this... If we are using the internal VPN and have named a service with VPN in the name it will put VPN first, Ethernet second and Wi-Fi last. And I believe you are incorrect @jrwilcox on all of the new models that do not have a built in Ethernet, Wi-Fi is en0 and tends to get sorted to the top, but, as I do not build stock machines very often and I know my stuff is setting it I could be quite wrong as well.

sub setNetworkServiceOrder {
    my $netcmd = "networksetup";
    my $listarg = "-listnetworkserviceorder";
    my $setarg = "-ordernetworkservices";
    my @disabled;
    my @hdw;
    my @vpns;
    open N, "$netcmd $listarg |", or die "$progname: list $!
";
    while (<N>) {
        chomp;
        next if /^An asterisk/;
        next if /^$/;
        my $port =$_;
        my ($num, $interface) = (split " ", $port, 2);
        if ($interface =~ /s/) {
            $interface = ""$interface"";
        }
        if ($num =~ /*/) {
            push @disabled, $interface;
            my $tmpline = <N>;
        }
        else {
            my $tmpline = <N>;
            if (($tmpline =~ /IPSec/) || ($tmpline =~ /L2TP/)) {
            push @vpns, $interface;
        }
            else {
                if ($interface =~ /Ethernet/) {
                    unshift @hdw, $interface;
                }
                else {
                    push @hdw, $interface;
                }
            }
        }
    }
    close N;
    my $serviceorder = join " ", @vpns, @hdw, @disabled;
    syslog('notice', "Network Service Order: %s",$serviceorder);
    system("$netcmd $setarg $serviceorder");
    return;
}

Forum|alt.badge.img+8
  • Contributor
  • 82 replies
  • July 27, 2015

I think you should check when you plug in an ethernet adapter it will removed to the top of the list if there is link. I know it was designed this way and I don't think they have changed since I managed the Ethernet team at Apple.


Forum|alt.badge.img+8
  • Author
  • Contributor
  • 59 replies
  • July 27, 2015

Thanks @jrwilcox .
Today I imaged a new machine and actually the Ethernet connection was above the Wifi.
If in the network service order the wifi is above the Eth, when I plug the cable the Eth remains below the Wifi.
Anyway, by default Eth is on top of Wifi therefore at the moment I'm fine with that.
Thanks again.
Cheers

Jack


Forum|alt.badge.img+8
  • Contributor
  • 82 replies
  • July 27, 2015

If it has not been changed by the user at some point and Ethernet gets a dhcp address it should have priority over wifi. You can actually check the default order System Preferences>Network Click on the gear in the lower right corner and select Set Service Order. That is the default service order if all devices have link and a dhcp address.


Forum|alt.badge.img+18
  • Valued Contributor
  • 1007 replies
  • July 27, 2015

I concur, created a new location and added two ethernet interfaces and they have higher priority than the wifi does. I put my stuff in place back in 10.5 or 10.6 timeframe and have not checked it since. Good job getting that right.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings