Created
July 1, 2015 18:27
-
-
Save ThisIsAreku/82318f49b70aae6372d0 to your computer and use it in GitHub Desktop.
Bridge eth0 and eth1 in Synology (DS414slim)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SCRIPT_NAME="S03synobridge.sh" | |
SCRIPT_PATH="/usr/syno/etc/rc.d/" | |
GATEWAY="192.168.0.254" | |
NETMASK="255.255.255.0" | |
IP="192.168.0.1" | |
if [ "$1" == "install" ]; then | |
if [ ! -f "${SCRIPT_PATH}${SCRIPT_NAME}" ]; then | |
echo "Installing script into /usr/syno/etc/rc.d/"; | |
SCRIPTPATH=$(realpath $0); | |
cp "$SCRIPTPATH" "${SCRIPT_PATH}${SCRIPT_NAME}"; | |
chmod +x "${SCRIPT_PATH}${SCRIPT_NAME}"; | |
echo "Running synobridge"; | |
else | |
echo "Script is already present. Exit now"; | |
exit; | |
fi | |
fi | |
if ! lsmod | grep "stp" &> /dev/null ; then | |
echo "Adding module STP" | |
insmod /lib/modules/stp.ko; | |
fi | |
if ! lsmod | grep "bridge" &> /dev/null ; then | |
echo "Adding module bridge" | |
insmod /lib/modules/bridge.ko | |
fi | |
if ! cat /proc/net/dev | grep 'br0' &> /dev/null ; then | |
echo "Configuring br0" | |
brctl addbr br0 | |
brctl stp br0 off | |
brctl addif br0 eth0 | |
brctl addif br0 eth1 | |
brctl show | |
fi | |
echo "Configuring interfaces" | |
ifconfig eth0 0.0.0.0 promisc up | |
ifconfig eth1 0.0.0.0 promisc up | |
ifconfig br0 $IP netmask $NETMASK up | |
route add default gw $GATEWAY dev br0 | |
echo "Enabling ip_forward" | |
echo "1" > /proc/sys/net/ipv4/ip_forward |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment