3

I have multiple 3G USB based Modems. I would like them to keep connected simultaneously, NOT necessarily aggregating their bandwidth; a separate intelligent application would manage their utilization effectively.

However I am running into problem of setting up proper routes for the ppp0,ppp1 interfaces: when one of them connects, other's entries in the routing table get updated so it is no more usable. If I reconnect the second one, it would override the first one's routing entries. If I do it over and over, sometimes both of them's entries disappear while in rare cases the two work well.

I have tried it both using NetworkManager as well as WVDial but issue pops up in both of these. Perhaps both of them use same PPP dialer at the backend and thats why this issue appears.

What is the proper solution to make them work together? In the long run, I'd also like them to automatically dial in once USB gets connected.

3
  • Hello, I have the same problem. network-manager doesn't allow me to choose both the connections, so I'm trying to use wvdial. I'd really appreciate some insight on this matter. Feb 8, 2011 at 11:36
  • 1
    Linux supports multiple routing tables. You need a separate table for each connection you make. Setting up a new table can be done using ip-up scripts. This link can give you a beter idea: blog.meisterbrau.org/2009/03/…
    – sharjeel
    Feb 9, 2011 at 14:08
  • I've no idea what the problem is. Anyway, maybe this link to the Linux Advanced Routing & Traffic Control HOWTO is helpful to someone. Feb 15, 2011 at 10:59

2 Answers 2

1

You may wish to try configuring your mobile connections with a simple tweak: checking the Use this connection only for the resources on its network checkbox, which is hidden a little far unfortunately:

Under the settings for your connection, go to the IPv4 tab, click the Routes button, then check the last checkbox on that dialog.

Not tested, but roughly, what should be happening is each pppX device should be getting enabled with correct routes through each of your providers' networks, but the default route should not get set to pass over any of them.

You should then be able to write a simple script that, for instance, pings the same server from each of the interfaces and chooses the fastest one to set the default route; something like:

route_candidate=$(
for iface in `ifconfig -a | grep ppp | awk '{print $1; }'`; do
    echo $iface = `ping -I $iface -c 1 -q 8.8.8.8 | grep avg | awk -F/ '{print $5;}'`
done | sort -k 3 -rn | head -n 1
)

logger "Setting new route from candidate: $route_candidate"

ip route del default
ip route add default dev `echo $route_candidate | awk '{print $1;}'`

I didn't test this completely, but it's roughly what needs to be done; with the addition or modification of using "via whatever_the_default_gw_ip_is" for the ip route add default command. Run this with cron on a regular interval and you have a cheapo system for staying on the "fastest" ISP.

0

I'm having problems connecting to multiple dongles too. I can initialize connection with one router at a time but not both. Do you get to connect to the internet or it just fails on the second one? (please let me know here aswell-> Why NetworkManager doesn't handle more than one 3g Dongle )

It may help to create separate IP tables with iproute2.

Edit the file /etc/iproute2/rtc_tables by simply adding at end something like:

1      ppp0
2      ppp1

Restart the daemon to load the new config. Then you can use a script that runs on ip-up event, like ip-up.local. Something like this may work:

##export variables
export ip4_address_0=$IP4_ADDRESS_0
export iface=$IFACE
export gateway=$IP4_GATEWAY

##generate clean IP
ip=`echo "$ip4_address_0" | cut -d"." -f1-4 | cut -f 1 -d "/"`
##generate ip for subnet
baseip=`echo "$ip" | cut -d"." -f1-3`

if [[ "$iface" == "ppp0" ]] ; then
        TABLE=ppp0
elif [[ "$iface" == "ppp1" ]] ; then
        TABLE=ppp1
fi

##In my case I needed to add 2 defaults using weights, everything else failed 
/usr/sbin/ip route add default scope global nexthop via "$gateway" dev "$iface" weight 1 nexthop via $baseip.0/24 dev "$iface" weight 2 table "$TABLE"
/usr/sbin/ip route add "$baseip.0/24" dev "iface" table "$TABLE"
/usr/sbin/ip route add default via "$gateway" dev "$iface" table "$TABLE"
/usr/sbin/ip rule add from "$ip/32" table "$TABLE"
/usr/sbin/ip rule add to "$ip/32" table "$TABLE"

Hope it helps you out.... Maybe you can help me aswell (Why NetworkManager doesn't handle more than one 3g Dongle)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .