Monday, August 09, 2010

Multiple Internet connection in Linux

I was facing trouble to use EDGE/GPRS (ppp) with another Ethernet connection together.
Ethernet connection was used for local network.

# ip route show
10.64.64.64 dev ppp0  proto kernel  scope link  src 10.130.4.218
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.2  metric 1
default via 192.168.1.1 dev eth0  proto static

ppp connected but still default route is eth0. To use the ppp connection as default
# ip route change default via 10.64.64.64 dev ppp0

You will find
# ip route show
10.64.64.64 dev ppp0  proto kernel  scope link  src 10.130.4.218
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.2  metric 1
default via 10.64.64.64 dev ppp0
remember you may need to set the nameserver (edit the /etc/resolv.conf).


On the other hand you may have 2 default connection settings:
# ip route show
10.64.64.64 dev ppp0  proto kernel  scope link  src 10.130.130.252
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.1
172.16.0.0/16 dev eth1  proto kernel  scope link  src 172.16.8.69
default via 172.16.8.1 dev eth1
default via 10.64.64.64 dev ppp0  proto static

I mainly want to use ppp0, so I am removing the eth1 from default list:
#ip route del default via 172.16.8.1


If you want to use multiple uplinks/providers:
http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html
http://lartc.org/howto/lartc.rpdb.multiple-links.html

example:
#ip route change default scope global nexthop via 10.64.64.64 dev ppp0  weight 2 nexthop via 192.168.1.1 dev eth0 weight 1

Install "iptraf", which is an useful tool for analysis:
#apt-get install iptraf

You can also define any IP address  to use specific connection.
This might helpful if you want to listen on-line radio without interrupting your main work.

I am specifying an IP address for listening an on-line radio station by using a backup slow connection via eth1:
#ip route add 85.xx.174.181 via 172.16.8.1 dev eth1

-enjoy

1 comment:

rahid said...

Is there any way to use Banglalion WiMAX USB Dongle in Linux. Pls reply