What's new

Working Link Aggregation Config RT-AC66U

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

@anders,

your output still shows router is configured correctly

the problem is with the synology
can't help much with that, but did you try reboot
both router and synology

@RMerlin
you make me laugh

if saintdev doesn't beat me to it, I'll modify the script tonight
 
I suspect the AC66U could also be configured the same way as the N66U. Possibly the N16 too (I forgot if they share the same switch).

AC56 is a different story. I implemented most of the 5310x support in robocfg by now (at least robord/wr works properly now), so once you know the proper registers, it might probably be used to do the same configuration as well.

Having a quick look at the vlan code in robocfg, there's a chance it might even work already since it relies on robo_write - untested however.

Are you saying that robocfg might work for all models? Or at least for sure for the AC66U and N66U, and maybe for the N16 and AC56?

Here's a script that assumes that is true. This is untested, but should be correct. The server I have link aggregation setup on is currently recording some TV, so I can't test it at the moment.

Code:
#!/bin/sh

# TODO: Store VLAN IDs in nvram?
VLANS="${BOND_VLANS:-3 4}"

bond_set()
{
	# bond_iface param value
	[ -d "/sys/class/net/${1}/bonding" ] || return 1
	[ -f "/sys/class/net/${1}/bonding/${2}" ] || return 1

	echo "${3}" > "/sys/class/net/${1}/bonding/${2}"
}
PORTS="1 2 3 4"

for vlan in ${VLANS}; do
	local vlan1_ports="8t"
	
	for port in ${PORTS}; do
		if [ "${port}" != "${1}" ]; then
			vlan1_ports="${port} ${vlan1_ports}"
		fi
	done
	
	# Remove port from the default VLAN
	robocfg vlan 1 ports "${vlan1_ports}"
	# Add it to new VLAN
	robocfg vlan ${vlan} ports "${1} 8t"
	# Create new VLAN interface
	vconfig add eth0 ${vlan}
	
	PORTS="${vlan1_ports% 8t}"
	shift
done

# Insert bonding module
modprobe bonding

# 802.3ad mode
bond_set bond0 mode "802.3ad"

# LACPDUs every 1 sec
bond_set bond0 lacp_rate fast

# 100msec MII link monitoring
bond_set bond0 miimon 100

# Bring up bond0
ip link set bond0 up

for vlan in ${VLANS}; do
	# enslave VLAN to bond0
	bond_set bond0 slaves "+vlan${vlan}"
	# Allow VLANs to access the AP
	iptables -I INPUT 1 -i "vlan${vlan}" -j ACCEPT
done

# Bridge the bond0 allowing AP access
brctl addif br0 bond0

# We allow bond0 to access the AP
iptables -I INPUT 1 -i bond0 -j ACCEPT

This will handle bonding 3 ports if you want, just make sure to set BOND_VLANS with 3 IDs. It's little more messy and not as robust as I would like. The et commands had to be taken out. Doing bitwise ops in POSIX sh is a little more than I want to get into.
 
I'll test it out tonight as well, after I run those networkmap tests

I'll be leaving work in a few minutes

another thing I thought of, we might want to check that vlan3 or vlan4 etc do not already exist
before we create them, they could already be in use
 
Are you saying that robocfg might work for all models? Or at least for sure for the AC66U and N66U, and maybe for the N16 and AC56?

I only support these four router models with the firmware itself, so I can't speak for any other router.

I added 5301x support to robocfg, for at least the roboread and write commands:

https://github.com/RMerl/asuswrt-merlin/commit/bf096f39adc6c9f9ce16f67bba4a3f5780b55502
https://github.com/RMerl/asuswrt-merlin/commit/356928f1b327b9582aa6f05b7117db6376050b09

Dunno when I will have time to see if the vlan commands also work.
 
I'll test it out tonight as well, after I run those networkmap tests

I'll be leaving work in a few minutes

another thing I thought of, we might want to check that vlan3 or vlan4 etc do not already exist
before we create them, they could already be in use

Yeah, there are a lot of other issues with that script. What if you pass port 8, an invalid port, more ports than VLANs, etc. I didn't feel like taking the time to fix all of them.
 
my thoughts on it, is that there are so many possiblities
I can understand providing a default script
probably port 3 & 4
this would meet the needs of 95% of anybody doing this

everybody else should probably just configure manually
what about other bonding modes, etc ....
too many variables
I think 1 default option is plenty

but that's just me :)
 
Port 3 and 4 are used by Asuswrt for people with IPTVs relying on VLAN tagging. That's why more flexibility would be needed.
 
getting tired, but page 3 script works fine on AC66U
so yes robocfg works and sysfs works

will get to the latest script, maybe tomorrow
 
@saintdev

so test your latest script above

here's the output from cmd line

Code:
t@RT-AC66U:/jffs# ./LinkAgg
Invalid ports ' 8t'.
Invalid ports ' 8t'.

cat /proc/net/bonding/bond0

seems to show no issues, and ifconfig shows vlans 3 & 4
robocfg show
on the other hand does not recognize or display vlans 3 & 4 when using the latest script

also my HP1910, is on the other end of this link and reports a problem with the link, and designates 1 port as inactive, due to no pair

as simple reboot, using this in services-start
Code:
#!/bin/sh
robocfg vlan 1 ports "1 2 8t"
robocfg vlan 3 ports "3 8t"
robocfg vlan 4 ports "4 8t"
# Create the interfaces
vconfig add eth0 3
vconfig add eth0 4
# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring,$
modprobe bonding
# 802.3ad mode
echo 802.3ad > /sys/class/net/bond0/bonding/mode
# LACPDUs every 1 sec
echo fast > /sys/class/net/bond0/bonding/lacp_rate
# Bring up bond0
ip link set bond0 up
# 100msec MII link monitoring
echo 100 > /sys/class/net/bond0/bonding/miimon
# enslave vlans to bond0
echo +vlan3 > /sys/class/net/bond0/bonding/slaves
echo +vlan4 > /sys/class/net/bond0/bonding/slaves
# Bridge the bond0 allowing AP access
brctl addif br0 bond0
# We allow these VLANs to access the AP
iptables -I INPUT 1 -i vlan3 -j ACCEPT
iptables -I INPUT 1 -i vlan4 -j ACCEPT
iptables -I INPUT 1 -i bond0 -j ACCEPT

both ends of bond are happy :)

I did not do any additional testing tonight
but I did think about the IPTV issue RMerlin mentioned
and if that's his purpose of offering different ports
IPTV also sets up vlans
so confirming that vlans don't already exist is going to be critical

maybe something as simple as

Code:
if [[ `ifconfig | grep vlan${1}` ]]; then
 
ok here's an attempt at a script for doing this

Download LinkAgg

I've run a bunch of test and it seems to work fine
even if you run it multiple times without rebooting

Usage: /path/to/LinkAgg <port> <port>
Example: /path/to/LinkAgg 3 4
Only 2 ports are currently supported

Code:
#!/bin/sh
if [ $# -lt 2 -o $# -gt 2 ]; then
	echo "No Args"
	exit
fi
if [ $1 = $2 ]; then
	echo "Invalid Port Entries"
	exit
fi
if [ "$1" != "1" ] && [ "$1" != "2" ] && [ "$1" != "3" ] && [ "$1" != "4" ]; then
	echo "Not A Valid Port"
	exit
fi
if [ "$2" != "1" ] && [ "$2" != "2" ] && [ "$2" != "3" ] && [ "$2" != "4" ]; then
	echo "Not A Valid Port"
	exit
fi
VLANS=$(ip link show | grep vlan* | cut -d ' ' -f 2 | cut -d '@' -f 1)
if [ ${#VLANS} = "5" ]; then
	if [ "$VLANS" = "vlan1" ]; then
		VLAN1="1 2 3 4 8t"
		TMP=$(echo $VLAN1 | sed -e "s/$1 //g")
		TMP1=$(echo $TMP | sed -e "s/$2 //g")
		robocfg vlan 1 ports "$TMP1"
		robocfg vlan 3 ports "$1 8t"
		robocfg vlan 4 ports "$2 8t"
		# Create the interfaces
		vconfig add eth0 $1
		vconfig add eth0 $2
		BONDS=$(ip link show | grep bond0: | cut -d ' ' -f 2 | cut -d ':' -f 1)
		if [ ${#BONDS} = "" ]; then
			bond=bond0
			# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring)
			modprobe bonding
			# 802.3ad mode
			echo 802.3ad > /sys/class/net/$bond/bonding/mode
			# LACPDUs every 1 sec
			echo fast > /sys/class/net/$bond/bonding/lacp_rate
			# Bring up bond
			ip link set $bond up
			# 100msec MII link monitoring
			echo 100 > /sys/class/net/$bond/bonding/miimon
			# enslave vlans to bond
			echo +vlan3 > /sys/class/net/$bond/bonding/slaves
			echo +vlan4 > /sys/class/net/$bond/bonding/slaves
			# Bridge the bond allowing AP access
			brctl addif br0 $bond
			# We allow these VLANs to access the AP
			iptables -I INPUT 1 -i vlan3 -j ACCEPT
			iptables -I INPUT 1 -i vlan4 -j ACCEPT
			iptables -I INPUT 1 -i $bond -j ACCEPT
		else
			bond=bond0
			modprobe -r bonding
			# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring)
			modprobe bonding
			# 802.3ad mode
			echo 802.3ad > /sys/class/net/$bond/bonding/mode
			# LACPDUs every 1 sec
			echo fast > /sys/class/net/$bond/bonding/lacp_rate
			# Bring up bond
			ip link set $bond up
			# 100msec MII link monitoring
			echo 100 > /sys/class/net/$bond/bonding/miimon
			# enslave vlans to bond
			echo +vlan3 > /sys/class/net/$bond/bonding/slaves
			echo +vlan4 > /sys/class/net/$bond/bonding/slaves
			# Bridge the bond allowing AP access
			brctl addif br0 $bond
			# We allow these VLANs to access the AP
			iptables -I INPUT 1 -i vlan3 -j ACCEPT
			iptables -I INPUT 1 -i vlan4 -j ACCEPT
			iptables -I INPUT 1 -i $bond -j ACCEPT
		fi
	else
		echo "Bonding Failed WTF!!"
	fi
else
	VLAN2=vlan$1
	tmp=$(echo "$VLANS" | grep $VLAN2)
	a=$1
	if [ $VLAN2 = "vlan2" ]; then
		a=`expr $a + 1`
		VLAN2=vlan$a
		tmp=$(echo "$VLANS" | grep $VLAN2)
	fi
	while [ $tmp = $VLAN2 ];
	do
		a=`expr $a + 1`
		VLAN2=vlan$a
		tmp=$(echo "$VLANS" | grep $VLAN2)
		if [ $VLAN2 = "vlan2" ]; then
			a=`expr $a + 1`
			VLAN2=vlan$a
			tmp=$(echo "$VLANS" | grep $VLAN2)
		fi
	done
	VLAN2=$( echo "$VLAN2" | sed -e "s/vlan//g" )
	VLAN1="1 2 3 4 8t"
	TMP=$(echo "$VLAN1" | sed -e "s/$1 //g")
	robocfg vlan 1 ports "$TMP"
	robocfg vlan $VLAN2 ports "$1 8t"
	vconfig add eth0 $VLAN2
	VLAN3=vlan$2
	VLANS=$(ip link show | grep vlan* | cut -d ' ' -f 2 | cut -d '@' -f 1)
	tmp1=$(echo "$VLANS" | grep $VLAN3)
	b=$2
	if [ $VLAN3 = "vlan2" ]; then
		b=`expr $b + 1`
		VLAN3=vlan$b
		tmp1=$(echo "$VLANS" | grep $VLAN3)
	fi
	while [ $tmp1 = $VLAN3 ];
	do
		b=`expr $b + 1`
		VLAN3=vlan$b
		tmp1=$(echo "$VLANS" | grep $VLAN3)
		if [ $VLAN3 = "vlan2" ]; then
			b=`expr $b + 1`
			VLAN3=vlan$b
			tmp1=$(echo "$VLANS" | grep $VLAN3)
		fi
	done
	VLAN3=$( echo "$VLAN3" | sed -e "s/vlan//g" )
	TMP1=$(echo $TMP | sed -e "s/$2 //g")
	robocfg vlan 1 ports "$TMP1"
	robocfg vlan $VLAN3 ports "$2 8t"
	vconfig add eth0 $VLAN3
	BONDS=$(ip link show | grep bond0: | cut -d ' ' -f 2 | cut -d ':' -f 1)
	if [ ${#BONDS} = "" ]; then
		bond=bond0
		# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring)
		modprobe bonding
		# 802.3ad mode
		echo 802.3ad > /sys/class/net/$bond/bonding/mode
		# LACPDUs every 1 sec
		echo fast > /sys/class/net/$bond/bonding/lacp_rate
		# Bring up bond
		ip link set $bond up
		# 100msec MII link monitoring
		echo 100 > /sys/class/net/$bond/bonding/miimon
		# enslave vlans to bond
		echo +vlan$VLAN2 > /sys/class/net/$bond/bonding/slaves
		echo +vlan$VLAN3 > /sys/class/net/$bond/bonding/slaves
		# Bridge the bond allowing AP access
		brctl addif br0 $bond
		# We allow these VLANs to access the AP
		iptables -I INPUT 1 -i vlan$VLAN2 -j ACCEPT
		iptables -I INPUT 1 -i vlan$VLAN3 -j ACCEPT
		iptables -I INPUT 1 -i $bond -j ACCEPT
	else
		bond=bond0
		modprobe -r bonding
		# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring)
		modprobe bonding
		# 802.3ad mode
		echo 802.3ad > /sys/class/net/$bond/bonding/mode
		# LACPDUs every 1 sec
		echo fast > /sys/class/net/$bond/bonding/lacp_rate
		# Bring up bond
		ip link set $bond up
		# 100msec MII link monitoring
		echo 100 > /sys/class/net/$bond/bonding/miimon
		# enslave vlans to bond
		echo +vlan$VLAN2 > /sys/class/net/$bond/bonding/slaves
		echo +vlan$VLAN3 > /sys/class/net/$bond/bonding/slaves
		# Bridge the bond allowing AP access
		brctl addif br0 $bond
		# We allow these VLANs to access the AP
		iptables -I INPUT 1 -i vlan$VLAN2 -j ACCEPT
		iptables -I INPUT 1 -i vlan$VLAN3 -j ACCEPT
		iptables -I INPUT 1 -i $bond -j ACCEPT
	fi
fi
 
Last edited:
I thank you all for the effort! - but regardless what I do, I can't make it work with the Synology 712+ - not even with this last script from KAD.

When I check all settings it all seems to be running smooth - but not with the NAS.

Of course I might be doing something wrong, but Im more into thinking that there can be some minor settings in the standard since its not working.

My concern is even bigger when I look at the Synology webpage where I can see that they recommend certain switches for LinkAgg Use.

So unless some of you can make it work with a Synology NAS and tell me how, I might just have to go buy a new switch :confused:
 
Updated Script

LinkAgg 1.1

Script Clean Up
Consolidated redundancies into functions
Add Help menu : -h --help
Add Status Check : -s --status
If bond creation failed set vlan1 back to "1 2 3 4 8t"

At the moment I can't think of anything else that I should add

Code:
#!/bin/sh
# Written By KAD
# Dynamic Link Aggregation Setup
# Version 1.1

Help()
{
	echo -e "\n----  Link Aggregation Help  ----"
	echo -e "\nDynamically enable Link Aggregation using 802.3ad"
	echo "802.3ad requires a Switch/PC/NAS which..."
	echo "also supports 802.3ad to fucntion correctly"
	echo -e "\nUsage: /path/to/LinkAgg <port> <port>"
	echo "Example: /path/to/LinkAgg 3 4"
	echo -e "Only 2 ports are currently supported\n"
	exit
}

#Set all needed bonding parameters
Create_Bond()
{
	# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring)
	modprobe bonding
	# 802.3ad mode
	echo 802.3ad > /sys/class/net/${1}/bonding/mode
	# LACPDUs every 1 sec
	echo fast > /sys/class/net/${1}/bonding/lacp_rate
	# Bring up bond
	ip link set ${1} up
	# 100msec MII link monitoring
	echo 100 > /sys/class/net/${1}/bonding/miimon
	# enslave vlans to bond
	echo +${2} > /sys/class/net/${1}/bonding/slaves
	echo +${3} > /sys/class/net/${1}/bonding/slaves
	# Bridge the bond allowing AP access
	brctl addif br0 ${1}
	# We allow these VLANs to access the AP
	iptables -I INPUT 1 -i ${2} -j ACCEPT
	iptables -I INPUT 1 -i ${3} -j ACCEPT
	iptables -I INPUT 1 -i ${1} -j ACCEPT
	#Check Bond Status
	Check_Bond_Status
}

#Check that bond creation was successful
#If Bond was unsuccessful set vlan1 back to default
Check_Bond_Status()
{
	Check1=$(ip link show | grep bond0: | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ $Check1 != "UP" ]; then
		echo "Bonding Failed - Set vlan1 back to Default Settings"
		robocfg vlan1 ports "1 2 3 4 8t"
		exit
	fi
	VLAN1=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 1)
	VLAN2=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 2)
	if [ $VLAN1 = "" ]; then
		echo "Bonding Failed - Set vlan1 back to original Settings"
		robocfg vlan1 ports "1 2 3 4 8t"
		exit
	fi
	if [ $VLAN2 = "" ]; then
		echo "Bonding Failed - Set vlan1 back to original Settings"
		robocfg vlan1 ports "1 2 3 4 8t"
		exit
	fi
	Check2=$(ip link show | grep $VLAN1 | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ $Check2 != "UP" ]; then
		echo "Bonding Failed - Set vlan1 back to original Settings"
		robocfg vlan1 ports "1 2 3 4 8t"
		exit
	fi
	Check3=$(ip link show | grep $VLAN2 | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ $Check3 != "UP" ]; then
		echo "Bonding Failed - Set vlan1 back to original Settings"
		robocfg vlan1 ports "1 2 3 4 8t"
		exit
	fi
	Check4=$(cat /proc/net/bonding/bond0 | grep "bond bond0 has no active aggregator")
	if [ $Check4 != "" ]; then
		echo "Bonding Failed - Set vlan1 back to original Settings"
		robocfg vlan1 ports "1 2 3 4 8t"
		exit
	fi
	echo -e "\nBond0 Successfully Created"
	exit
}

# Status Checker
if [ "$1" = "-s" -o "$1" = "--status" ]; then
	Check1=$(ip link show | grep bond0: | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ $Check1 != "UP" ]; then
		echo "Status : bond0 not UP"
		exit
	fi
	VLAN1=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 1)
	VLAN2=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 2)
	if [ $VLAN1 = "" ]; then
		echo "Status : Slave 1 does not exist"
		exit
	fi
	if [ $VLAN2 = "" ]; then
		echo "Status : Slave 2 does not exist"
		exit
	fi
	Check2=$(ip link show | grep $VLAN1 | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ $Check2 != "UP" ]; then
		echo "Status : Slave 1 not UP"
		exit
	fi
	Check3=$(ip link show | grep $VLAN2 | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ $Check3 != "UP" ]; then
		echo "Slave : Slave 2 not UP"
		exit
	fi
	Check4=$(cat /proc/net/bonding/bond0 | grep "bond bond0 has no active aggregator")
	if [ $Check4 != "" ]; then
		echo "Status : No Active Aggregator for bond0"
		exit
	fi
	echo -e "\nBond0 Up & Running Correctly"
	exit
fi

# Enable Help Menu
if [ "$1" = "-h" -o "$1" = "--help" ]; then
	Help
fi

# Number of ports must equal 2
if [ $# -lt 2 -o $# -gt 2 ]; then
	echo -e "\nError : Incorrect Number of Ports"
	Help
fi

# The Ports Must not be the same
if [ $1 = $2 ]; then
	echo -e "\nError : Port Entries Must Be Unique"
	Help
fi

# Valid port1 entries are 1,2,3,4
if [ "$1" != "1" ] && [ "$1" != "2" ] && [ "$1" != "3" ] && [ "$1" != "4" ]; then
	echo -e "\nError : Port1 : Not A Valid Port"
	Help
fi

# Valid port2 entries are 1,2,3,4
if [ "$2" != "1" ] && [ "$2" != "2" ] && [ "$2" != "3" ] && [ "$2" != "4" ]; then
	echo -e "\nError : Port2 : Not A Valid Port"
	Help
fi

#Store current vlan1 config for later use
DefaultVLAN=$(robocfg show | grep vlan1 | cut -d ':' -f 3 | sed -e "s/^ //")
#Find how many vlans exist
VLANS=$(ip link show | grep vlan* | cut -d ' ' -f 2 | cut -d '@' -f 1)
#If only 1 vlan exist
if [ ${#VLANS} = "5" ]; then
	#Check if only 1 vlan exist it should be vlan1
	if [ "$VLANS" = "vlan1" ]; then
		VLAN1="1 2 3 4 8t"
		TMP=$(echo $VLAN1 | sed -e "s/$1 //g")
		TMP1=$(echo $TMP | sed -e "s/$2 //g")
		robocfg vlan 1 ports "$TMP1"
		robocfg vlan 3 ports "$1 8t"
		robocfg vlan 4 ports "$2 8t"
		# Create the interfaces
		vconfig add eth0 $1
		vconfig add eth0 $2
		BONDS=$(ip link show | grep bond0: | cut -d ' ' -f 2 | cut -d ':' -f 1)
		#Check that bond0 does not exist
		if [ ${#BONDS} = "" ]; then
			Create_Bond bond0 vlan3 vlan4
		#If bond0 already exist remove it
		else
			modprobe -r bonding
			Create_Bond bond0 vlan3 vlan4
		fi
	#Only 1 vlan exist but it's not vlan1
	else
		echo -e "\nBonding Failed WTF!!\n"
		Help
	fi
# if more than 1 vlan exist
else 
	#Find first available vlan
	VLAN2=vlan$1
	tmp=$(echo "$VLANS" | grep $VLAN2)
	a=$1
	# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
	if [ $VLAN2 = "vlan2" ]; then
		a=`expr $a + 1`
		VLAN2=vlan$a
		tmp=$(echo "$VLANS" | grep $VLAN2)
	fi
	while [ $tmp = $VLAN2 ];
	do
		a=`expr $a + 1`
		VLAN2=vlan$a
		tmp=$(echo "$VLANS" | grep $VLAN2)
		# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
		if [ $VLAN2 = "vlan2" ]; then
			a=`expr $a + 1`
			VLAN2=vlan$a
			tmp=$(echo "$VLANS" | grep $VLAN2)
		fi
	done
	# Create First vlan for bond
	# Remove port from vlan1 so we can use it in bond
	VLAN2=$( echo "$VLAN2" | sed -e "s/vlan//g" )
	VLAN1="1 2 3 4 8t"
	TMP=$(echo "$VLAN1" | sed -e "s/$1 //g")
	robocfg vlan 1 ports "$TMP"
	robocfg vlan $VLAN2 ports "$1 8t"
	vconfig add eth0 $VLAN2
	#Find second available vlan
	VLAN3=vlan$2
	VLANS=$(ip link show | grep vlan* | cut -d ' ' -f 2 | cut -d '@' -f 1)
	tmp1=$(echo "$VLANS" | grep $VLAN3)
	b=$2
	# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
	if [ $VLAN3 = "vlan2" ]; then
		b=`expr $b + 1`
		VLAN3=vlan$b
		tmp1=$(echo "$VLANS" | grep $VLAN3)
	fi
	while [ $tmp1 = $VLAN3 ];
	do
		b=`expr $b + 1`
		VLAN3=vlan$b
		tmp1=$(echo "$VLANS" | grep $VLAN3)
		# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
		if [ $VLAN3 = "vlan2" ]; then
			b=`expr $b + 1`
			VLAN3=vlan$b
			tmp1=$(echo "$VLANS" | grep $VLAN3)
		fi
	done
	# Create Second vlan for bond
	# Remove port from vlan1 so we can use it in bond
	VLAN3=$( echo "$VLAN3" | sed -e "s/vlan//g" )
	TMP1=$(echo $TMP | sed -e "s/$2 //g")
	robocfg vlan 1 ports "$TMP1"
	robocfg vlan $VLAN3 ports "$2 8t"
	vconfig add eth0 $VLAN3
	BONDS=$(ip link show | grep bond0: | cut -d ' ' -f 2 | cut -d ':' -f 1)
	#Check that bond0 does not exist
	if [ ${#BONDS} = "" ]; then
		Create_Bond bond0 vlan$VLAN2 vlan$VLAN3
	else
	#If bond0 already exist remove it
		modprobe -r bonding
		Create_Bond bond0 vlan$VLAN2 vlan$VLAN3
	fi
fi
 
Last edited:
I connect my NAS to port 3-4 on the ASUS Router, and I able to connect.

I enable the option in DSM to LinkAgg through SMB, and it comes out with an error saying that it failed to establish IEEE 802.3ad connection - but it leaves the option on.

I run the script.

I can't connect at all to the NAS through SMB.

I connect to NAS to any other port, and Im able to connect.


Furthermore I've done some different attempts where I start by connecting one cable, then enable 802.3ad, run the scripts, and then finally connect last cable.

But no luck :(
 
try - A.

plug in both sets of cables

then try set up LinkAgg on router first

can you still reach synology NAS ?

if yes, proceed to set up LinkAgg on synology NAS

or

try - B.

plug in both sets of cables

set up LinkAgg on synology NAS

set up LinkAgg on Router
(according to above you will loose connection to synology NAS)

reboot synology NAS

see if you can now access synology NAS?

-- Just as a note. My Dad has the Synology 1512+
When he set up LinkAgg is was a pain in the ***
a lot of problems similiar to what you described already
and he has a dedicated switch with LinkAgg support
I'd have to check with him to be sure
but I think Synology requires the other end of the Link to be created first
so you would need to create the link on the router
then create the link on the synology NAS

Also the one thing I thought was odd about the synology set up instructions
they show the set up using DHCP
I've never used DHCP with LinkAgg
but it's possible if reconfiguring the network, a different IP gets assigned to the NAS
 
Since there will always be just one more thing

LinkAgg 1.2

extended help menu
create delete bond function
combined error recovery and status checker into 1 function
remove dead/unused vlan's when delete bond
extended output of status checker
lots of script clean up

Code:
#!/bin/sh
# Written By KAD
# Dynamic Link Aggregation Setup
# Version 1.2

Help()
{
	echo -e "\n----  Link Aggregation Help  ----"
	echo -e "\nDynamically enable Link Aggregation using 802.3ad"
	echo "802.3ad requires a Switch/PC/NAS which..."
	echo "also supports 802.3ad to fucntion correctly"
	echo -e "\nUsage: /path/to/LinkAgg <port> <port>"
	echo "Example: /path/to/LinkAgg 3 4"
	echo -e "Only 2 ports are currently supported\n"
	echo -e "\n--- Special Flags ---"
	echo -e "\nHelp: -h or --help"
	echo "Status: -s or --status"
	echo -e "Delete: -d or --delete\n"
	exit
}

#Set all needed bonding parameters
Create_Bond()
{
	# Insert bonding module and set parameters (802.3ad, 100ms MII link monitoring)
	modprobe bonding
	# 802.3ad mode
	echo 802.3ad > /sys/class/net/${1}/bonding/mode
	# LACPDUs every 1 sec
	echo fast > /sys/class/net/${1}/bonding/lacp_rate
	# Bring up bond
	ip link set ${1} up
	# 100msec MII link monitoring
	echo 100 > /sys/class/net/${1}/bonding/miimon
	# enslave vlans to bond
	echo +${2} > /sys/class/net/${1}/bonding/slaves
	echo +${3} > /sys/class/net/${1}/bonding/slaves
	# Bridge the bond allowing AP access
	brctl addif br0 ${1}
	# We allow these VLANs to access the AP
	iptables -I INPUT 1 -i ${2} -j ACCEPT
	iptables -I INPUT 1 -i ${3} -j ACCEPT
	iptables -I INPUT 1 -i ${1} -j ACCEPT
	#Check Bond Status
	sleep 10
	Check_Bond_Status BondCreated
	echo "Bond Created Successfully"
}

# Delete Bond Function
Delete_Bond()
{
	# Get vlan's used in current bond
	DELETEVLAN1=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 1)
	DELETEVLAN2=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 2)
	# Remove bonding module, this also deletes bond0
	modprobe -r bonding
	# Set vlan1 back to default
	if [[ "$1" = "-d" -o "$1" = "--delete" ]]; then
		robocfg vlan 1 ports "1 2 3 4 8t"
		ReturnDefaultPorts="vlan1 default ports restored to - 1 2 3 4 8t"
		# Remove dead vlan's
		if [[ $DELETEVLAN1 != "" -o $DELETEVLAN1 != NULL ]]; then
			vconfig rem $DELETEVLAN1
			DeadVLAN1="Removed Dead $DELETEVLAN1"
		fi
		if [[ $DELETEVLAN2 != "" -o $DELETEVLAN2 != NULL ]]; then
			vconfig rem $DELETEVLAN2
			DeadVLAN2="Removed Dead $DELETEVLAN2"
		fi
		echo -e "\nbond0 Deleted\n"
		echo "$ReturnDefaultPorts"
		echo "$DeadVLAN1"
		echo "$DeadVLAN2"
		exit
	else
		return
	fi
}

# Status Checker
Check_Bond_Status()
{
	Check1=$(ip link show | grep bond0: | cut -d '<' -f 2 | cut -d ',' -f 4)
	if [ "$Check1" != "UP" ]; then
		Check1=NONE
		Error1="Status : bond0 not UP"
	fi
	CHECKVLAN1=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 1)
	CHECKVLAN2=$(cat /sys/class/net/bond0/bonding/slaves | cut -d ' ' -f 2)
	if [[ "$CHECKVLAN1" = "" -o "$CHECKVLAN1" = NULL ]]; then
		CHECKVLAN1=NONE
		PORT1=NONE
		Check2=NONE
		Error2="Status : Slave 1 does not exist"
	else
		Check2=$(ip link show | grep "$CHECKVLAN1" | cut -d '<' -f 2 | cut -d ',' -f 4)
		if [ "$Check2" != "UP" ]; then
			PORT1=NONE
			Check2=Down
			Error3="Status : Slave 1 not UP"
		elif [ "$Check2" = "UP" ]; then
			PORT1=$(robocfg show | grep "$CHECKVLAN1" | cut -d ':' -f 3 | sed -e "s/^ //" | cut -d ' ' -f 1)
		fi
	fi
	if [[ "$CHECKVLAN2" = "" -o "$CHECKVLAN2" = NULL ]]; then
		CHECKVLAN2=NONE
		PORT2=NONE
		Check3=NONE
		Error4="Status : Slave 2 does not exist"
	else
		Check3=$(ip link show | grep "$CHECKVLAN2" | cut -d '<' -f 2 | cut -d ',' -f 4)
		if [ "$Check3" != "UP" ]; then
			PORT2=NONE
			Check3=Down
			Error5="Status : Slave 2 not UP"
		elif [ "$Check3" = "UP" ]; then
			PORT2=$(robocfg show | grep "$CHECKVLAN2" | cut -d ':' -f 3 | sed -e "s/^ //" | cut -d ' ' -f 1)
		fi
	fi
	if [[ "$Check1" = "NONE" -o "$CHECKVLAN1" = "NONE" -o "$PORT1" = "NONE" -o "$Check2" = "NONE" -o "$Check2" = "Down" -o "$CHECKVLAN2" = "NONE" -o "$PORT2" = "NONE" -o "$Check3" = "NONE" -o "$Check3" = "Down" && "$1" = "BondCreated" ]]; then
		Delete_Bond -d
	elif [ "$1" = "BondCreated" ]; then
		return
	fi
	echo -e "\n--- Bond Errors ---"
	echo "$Error1"
	echo "$Error2"
	echo "$Error3"
	echo "$Error4"
	echo "$Error5"
	echo -e "\n--- Bond Status ---\n"
	echo -e "Bond Status: bond0 $Check1"
	echo -e "Slave 1 Status: vlan=$CHECKVLAN1 Link=$Check2 Port=$PORT1"
	echo -e "Slave 2 Status: vlan=$CHECKVLAN2 Link=$Check3 Port=$PORT2\n"
	exit
}

# Status Check Flag
if [[ $1 = "-s" -o $1 = "--status" ]]; then
	Check_Bond_Status
fi

# Delete Bond Flag
if [[ $1 = "-d" -o $1 = "--delete" ]]; then
	Delete_Bond $1
fi

# Enable Help Menu
if [[ $1 = "-h" -o $1 = "--help" ]]; then
	Help
fi

# Number of ports must equal 2
if [[ $# -lt 2 -o $# -gt 2 ]]; then
	echo -e "\nError : Incorrect Number of Ports"
	Help
fi

# The Ports Must not be the same
if [ $1 = $2 ]; then
	echo -e "\nError : Port Entries Must Be Unique"
	Help
fi

# Valid port1 entries are 1,2,3,4
if [[ $1 != "1" && $1 != "2" && $1 != "3" && $1 != "4" ]]; then
	echo -e "\nError : Port1 : Not A Valid Port"
	Help
fi

# Valid port2 entries are 1,2,3,4
if [[ $2 != "1" && $2 != "2" && $2 != "3" && $2 != "4" ]]; then
	echo -e "\nError : Port2 : Not A Valid Port"
	Help
fi

#Find how many vlans exist
VLANS=$(ip link show | grep vlan* | cut -d ' ' -f 2 | cut -d '@' -f 1)
#If only 1 vlan exist
if [ ${#VLANS} = "5" ]; then
	#Check if only 1 vlan exist it should be vlan1
	if [ "$VLANS" = "vlan1" ]; then
		VLAN1="1 2 3 4 8t"
		TMP=$(echo $VLAN1 | sed -e "s/$1 //g")
		TMP1=$(echo $TMP | sed -e "s/$2 //g")
		robocfg vlan 1 ports "$TMP1"
		robocfg vlan 3 ports "$1 8t"
		robocfg vlan 4 ports "$2 8t"
		# Create the interfaces
		vconfig add eth0 $1
		vconfig add eth0 $2
		BONDS=$(ip link show | grep bond0: | cut -d ' ' -f 2 | cut -d ':' -f 1)
		#Check that bond0 does not exist
		if [ ${#BONDS} = "0" ]; then
			Create_Bond bond0 vlan3 vlan4
		#If bond0 already exist remove it
		else
			Delete_Bond
			Create_Bond bond0 vlan3 vlan4
		fi
	#Only 1 vlan exist but it's not vlan1
	else
		echo -e "\nBonding Failed WTF!!\n"
		Help
	fi
# if more than 1 vlan exist
else 
	#Find first available vlan
	VLAN2=vlan$1
	tmp=$(echo "$VLANS" | grep "$VLAN2")
	a=$1
	# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
	if [ $VLAN2 = "vlan2" ]; then
		a=`expr $a + 1`
		VLAN2=vlan$a
		tmp=$(echo "$VLANS" | grep "$VLAN2")
	fi
	while [[ "$tmp" = "$VLAN2" ]];
	do
		a=`expr $a + 1`
		VLAN2=vlan$a
		tmp=$(echo "$VLANS" | grep "$VLAN2")
		# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
		if [ $VLAN2 = "vlan2" ]; then
			a=`expr $a + 1`
			VLAN2=vlan$a
			tmp=$(echo "$VLANS" | grep "$VLAN2")
		fi
	done
	# Create First vlan for bond
	# Remove port from vlan1 so we can use it in bond
	VLAN2=$( echo -e "$VLAN2" | sed -e "s/vlan//g" )
	VLAN1="1 2 3 4 8t"
	TMP=$(echo "$VLAN1" | sed -e "s/$1 //g")
	robocfg vlan 1 ports "$TMP"
	robocfg vlan $VLAN2 ports "$1 8t"
	vconfig add eth0 $VLAN2
	#Find second available vlan
	VLAN3=vlan$2
	VLANS=$(ip link show | grep vlan* | cut -d ' ' -f 2 | cut -d '@' -f 1)
	tmp1=$(echo "$VLANS" | grep "$VLAN3")
	b=$2
	# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
	if [ $VLAN3 = "vlan2" ]; then
		b=`expr $b + 1`
		VLAN3=vlan$b
		tmp1=$(echo "$VLANS" | grep "$VLAN3")
	fi
	while [[ "$tmp1" = "$VLAN3" ]];
	do
		b=`expr $b + 1`
		VLAN3=vlan$b
		tmp1=$(echo "$VLANS" | grep "$VLAN3")
		# vlan2 is used by system internals and does not show up in ip link, useage of vlan2 is not allowed
		if [ $VLAN3 = "vlan2" ]; then
			b=`expr $b + 1`
			VLAN3=vlan$b
			tmp1=$(echo "$VLANS" | grep "$VLAN3")
		fi
	done
	# Create Second vlan for bond
	# Remove port from vlan1 so we can use it in bond
	VLAN3=$( echo "$VLAN3" | sed -e "s/vlan//g" )
	TMP1=$(echo "$TMP" | sed -e "s/$2 //g")
	robocfg vlan 1 ports "$TMP1"
	robocfg vlan $VLAN3 ports "$2 8t"
	vconfig add eth0 $VLAN3
	BONDS=$(ip link show | grep bond0: | cut -d ' ' -f 2 | cut -d ':' -f 1)
	#Check that bond0 does not exist
	if [ ${#BONDS} = "0" ]; then
		Create_Bond bond0 vlan$VLAN2 vlan$VLAN3
	else
	#If bond0 already exist remove it
		Delete_Bond
		Create_Bond bond0 vlan$VLAN2 vlan$VLAN3
	fi
fi
 
No luck so far.

Cant connect at all on port 3/4 - not even with Link Agg Disabled.

Should I do ANYTHING else but run the script?

I download it?
Use Chmod +X
I run it

But it doesn't work :mad:
 
If you're using LinkAgg version 1.2

what is the output of
Code:
/Path/to/LinkAgg -s

if there are no error messages and you're still unable to connect to synology
what happens when you do

Code:
/Path/to/LinkAgg -d

using -d does this restore access to your synology?
 
This is what happens

Code:
admin@RT-AC66U:/tmp/home/root# /jffs/scripts/LinkAgg 3 4
Bond Created Successfully
admin@RT-AC66U:/tmp/home/root# /jffs/scripts/LinkAgg -s

--- Bond Errors ---






--- Bond Status ---

Bond Status: bond0 UP
Slave 1 Status: vlan=vlan3 Link=UP Port=3
Slave 2 Status: vlan=vlan4 Link=UP Port=4

admin@RT-AC66U:/tmp/home/root# /jffs/scripts/LinkAgg -d

After "LinkAgg 3 4" I can't connect.

When I run "LinkAgg -d" Im able to connect again.

Br

Anders
 
I'm not sure what else can be done, I think it's clearly some issue on the synology side

I sent an email to my Dad, to see if he remembers any tips on synology set up

He confirms that synology LinkAgg set up had to be done after the router/switch was set up for LinkAgg

so.
1.Confirm LinkAgg is not enabled on synology
2. plug in both cables
3. Enable LinkAgg on Router or Switch
4. then enable LinkAgg on synology

he said, that was the only way, he could get link agg to successfully activate on synology

edit: some other interesting test
you said you can't reach syno via SMB
what about the management webpage
what about ping
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top