You are not logged in.

#1 2008-12-26 18:17:29

mcover
Member
From: Germany
Registered: 2007-01-25
Posts: 134

network adapter bonding/multilink possibilities?

Hey everyone,

I looking for ways how to use bonding or multilink with linux. Since bonding is only really possible in a setup where multiple ports/adapters are available to access the exact same network, I'm probably more looking for multilink ideas since I want to connect to completely independant networks.

I've already written a script enabling me to create a multilink with 2 adapters that connect to different networks and all connections are balanced (according to weight) accross those. This gives a pretty good boost when many many connections are needed at the same time, like bittorrent, but its not exactly what I'm looking for.

Another solution would be that both adapters are used for the same connections and in the end linux packetfiltering (through iptables) would pick the packet from the adapter which delivers first. I've been looking for instructions how to do something like this but can't find anything.

If anyone got an idea, that would be great. I am specifically looking for ways to improve my wireless signal with 2 wifi adapters. the router I have seems to be really bad and keeps on breaking my connection - I know I could buy a new router, but why buy a router when I have 2 wifi adapters which I can experiment with and try to solve my problem that way.

If there is a way how to "combine" 2 wifi adapters to get a better signal, I'd be glad to hear it as well.

If anyone is interested in the script I wrote to setup a multilink for 2 adapters that split the connection-load (the basic idea is from an old archived gentoo-wiki):

#!/bin/bash

if [ `whoami` != "root" ]; then
    echo "This program must be run as root."
    exit 0
fi

if [ $# -ne 4 ]; then
    echo "Usage: "`basename $0`" dev1 weight1 dev2 weight2"
    exit 1
fi

get_netmask ()
{
    ifconfig $1 | grep -m 1 'Mask' | awk '{print $4}' | awk -F":" '{print $2}'
}

get_ip ()
{
    ifconfig $1 | grep -m 1 'inet addr' | awk '{print $2}' | awk -F":" '{print $2}'
}

get_gateway ()
{
    route -n | grep $1 | sed "s/default/0.0.0.0/g" | sed "s/^.*:.*$//g" | grep "^0.0.0.0" | awk '{print $2}'
}

get_cider_mask ()
{
    ip route | grep "$1.*src *$2" | awk '{print $1}'
}

DEV1=$1
WEIGHT1=$2
DEV2=$3
WEIGHT2=$4
IP1=`get_ip $DEV1`
IP2=`get_ip $DEV2`
NETMASK1=`get_netmask $DEV1`
NETMASK2=`get_netmask $DEV2`
CIDER_NETMASK1=`get_cider_mask $DEV1 $IP1`
CIDER_NETMASK2=`get_cider_mask $DEV2 $IP2`
GATEWAY1=`get_gateway $DEV1`
GATEWAY2=`get_gateway $DEV2`

if [ -z "$GATEWAY1" ];then
    echo -n "Please enter GATEWAY for $DEV1: (Default=$GATEWAY2) "
    read GATEWAY1
    [ -z "$GATEWAY1" ] && GATEWAY1=$GATEWAY2
fi

if [ -z "$GATEWAY2" ]; then
    echo -n "Please enter GATEWAY for $DEV2: (Default=$GATEWAY1) "
    read GATEWAY2
    [ -z "$GATEWAY2" ] && GATEWAY2=$GATEWAY1
fi

route del default $DEV1 &> /dev/null
route del default $DEV2 &> /dev/null

echo "Debug: $DEV1 $WEIGHT1 $IP1 $NETMASK1 $CIDER_NETMASK1 $GATEWAY1"
echo "Debug: $DEV2 $WEIGHT2 $IP2 $NETMASK2 $CIDER_NETMASK2 $GATEWAY2"

ip route add $CIDER_NETMASK1 dev $DEV1 src $IP1 table 1
ip route add default via $GATEWAY1 table 1
ip rule add from $IP1 table 1

ip route add $CIDER_NETMASK2 dev $DEV2 src $IP2 table 2
ip route add default via $GATEWAY2 table 2
ip rule add from $IP2 table 2

ip route add default scope global\
    nexthop via $GATEWAY1 dev $DEV1 weight $WEIGHT1\
    nexthop via $GATEWAY2 dev $DEV2 weight $WEIGHT2

exit 0

Offline

#2 2008-12-26 19:58:57

daf666
Member
Registered: 2007-04-08
Posts: 470
Website

Re: network adapter bonding/multilink possibilities?

Offline

#3 2008-12-27 13:05:19

mcover
Member
From: Germany
Registered: 2007-01-25
Posts: 134

Re: network adapter bonding/multilink possibilities?

this is exactly what i've done in my script, but not exactly what i'm looking for. i want to either combine my wifi adapters into one more powerful one or have a multilink, but both do the same work in parallel but whichever one is faster "wins".

Offline

Board footer

Powered by FluxBB