link aggregation via command line

franton
Valued Contributor III

Scripting question: I'm trying to bond network ports together on our mac mini servers. I can do it very successfully in the GUI but every attempt i've made at scripting this, creates the bond but fails to add the interfaces to it. Has anyone managed this through terminal?

4 REPLIES 4

jacob_salmela
Contributor II

What have you tried? Maybe something like this would work?

sudo ifconfig bridge0 create
sudo ifconfig bridge0 addm en0 addm en1
sudo ifconfig bridge0 up

franton
Valued Contributor III

I got as far as the following:

eth=$( networksetup -listallhardwareports | grep -A 1 "Hardware Port: Ethernet" | grep "Device: " | cut -c 9- )
teth=$( networksetup -listallhardwareports | grep -A 1 "Hardware Port: Thunderbolt Ethernet" | grep "Device: " | cut -c 9- )
networksetup -createBond bond0 $eth $teth

This creates the bond but doesn't attach the network ports to that bond. On 10.9.2 server at least.

GaToRAiD
Contributor II

@franton have you tried to add

networksetup -addDeviceToBond <device name> <bond name>

franton
Valued Contributor III

I'll have another go once i've recovered from the JNUC induced jet lag!