Hello everyone -
I managed to get link aggregation working with the 68u router model and wanted to share my method in this how-to guide.
Environment
-
Router Model: AC68U using ports 3 & 4
-
Firmware: Asuswrt-Merlin 376.47 with JFFS enabed
-
Switch: Netgear GSM7224R (including other 802.3ad capable switches)
-
User Scripts (in /jffs/scripts/): firewall-start and services-start
Inspiration & Credits
- LinkAgg script by
@KAD -
http://forums.smallnetbuilder.com/showthread.php?t=12735
- DD-WRT forum post by
@mrengles -
http://www.dd-wrt.com/phpBB2/viewtopic.php?p=869756
Description
After several attempts (and many failures) to get link aggregation working using the LinkAgg script, I decided to further investigate the underlining cause for the failures and concluded:
1. LinkAgg, which has bugs, was designed to work with the 66u model which uses different internal switch port mappings (this was mentioned in several posts)
2. For some reason, Vlan 3 does not appear to work properly in the 68u model. This meant that I needed to use vlan 4 and vlan 5 instead.
3. The use of the xmit_hash_policy option and the corresponding switch/NAS hashing option was needed in order for link aggregation to work with a variety of switches
& NAS boxes *new edit.
4. A simpler method was required to get link aggregation working across reboots and firmware updates.
Enough said - let's get to it
Step 1 - NVRAM Edits |
Note: You will need to repeat this step if you clear the nvram ie. Beta to Final versions, resetting to Factory default
Apply the following changes to the router's nvram:
Code:
nvram set vlan4ports="3 5t"
nvram set vlan5ports="4 5t"
nvram set vlan4hwname=et0
nvram set vlan5hwname=et0
nvram commit
Step 2 - Create/Edit services-start script
Include the following code in services-start script located in /jffs/scripts/ (you will need to create this file from scratch, if you haven't done so already, with the right permissions)
Code:
#!/bin/sh
# Logger Services
logger -t "($(basename $0))" $$ SERVICES-START being started....
logger -t "($(basename $0))" $$ Bonding ports 3 and 4 commencing....
# Pre-Bonding
robocfg vlan 1 ports "1 2 5*"
# Bonding
sleep 2s
modprobe bonding
# Setting mode to 802.3ad
echo 802.3ad > /sys/class/net/bond0/bonding/mode
# Setting LACP rate to fast
echo fast > /sys/class/net/bond0/bonding/lacp_rate
# Setting MII monitoring interval to 50
echo 50 > /sys/class/net/bond0/bonding/miimon
# Setting xmit hash policy to layer3+4
echo 1 > /sys/class/net/bond0/bonding/xmit_hash_policy
ip link set bond0 up
echo +vlan4 > /sys/class/net/bond0/bonding/slaves
echo +vlan5 > /sys/class/net/bond0/bonding/slaves
brctl addif br0 bond0
# Post-Bonding
sleep 2s
logger -t "($(basename $0))" $$ Bonding Status....
cat /proc/net/bonding/bond0 | sed 's/^/+++ /' | logger
Step 3 - Create/Edit firewall-start script
Include the following code in firewall-start script located in /jffs/scripts/ (you will need to create this file from scratch, if you haven't done so already, with the right permissions)
Code:
#!/bin/sh
# Bonding IPtables rules
iptables -I INPUT -i vlan4 -j ACCEPT
iptables -I INPUT -i vlan5 -j ACCEPT
iptables -I INPUT -i bond0 -j ACCEPT
# Firewall/IPtables Performance Tweak for Bond0 to be placed right after the above bonding rules and before your custom rules - if any.
iptables -D INPUT `iptables --line-numbers -nL INPUT | grep ESTABLISHED | tail -n1 | awk '{print $1}'`
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Step 4 - Set the switch's LAG hashing mode
This is the LAG config for the 2 switch ports you have connected to the router's port 3 and 4.
- Set the hashing mode to "Source/Destination MAC, VLAN, EtherType, source MODID/port" or the equivalent mode in your switch.
Step 5 - Reboot
You should now have link aggregation working with your 68u router and 802.3ad capable switch