I decided to write this simple HOWTO so people can set up international and local ADSL accounts using PPPoE on (K)ubuntu.
I'm assuming that the international account is an expensive SAIX based one and the local one is a cheap IS based on but it will work for any ISP account.
If you're using Ubuntu you may have to replace references to "sudo kedit" with the Ubuntu equivalents such as "gksudo" or "sudo gedit" since KDE and it's apps probably won't be installed by default.
I prefer good old vi because it's practically universal across *nix machines but let me not start a flame war.
Install required packages
Configure ADSL router/modem
Make sure your ADSL modem is in bridge mode. I won't discuss how to do that since it's different for each modem and it will be part of the modem documentation anyway.
Create PPPoE accounts
Run pppoeconf and set up the international account.
Accept the defaults provided by pppoeconf and say yes to the start at boot option.
Now test the connection with pon dsl-provider
Your Internet connection should be working and if you list the interfaces with ifconfig you should see ppp0 listed.
Disconnect ppp0 before continuing. poff dsl-provider
Now is where we need to start with some custom changes because dual ADSL connections are practically unheard of overseas and pppoeconf only caters for one account in one config file (dsl-provider).
Move the dsl-provider file located in /etc/ppp/peers to "international".
sudo mv /etc/ppp/peers/dsl-provider /etc/ppp/peers/international
We need to do this because when we set up the local account it will overwrite dsl-provider.
Run pppoeconf again and set up the local account but make sure you answer no to the "Use peer DNS" question. We only want to use the DNS servers provided from the ISP from the international account. Say yes to the start at boot option.
Move the dsl-provider config to "local".
sudo mv /etc/ppp/peers/dsl-provider /etc/ppp/peers/local
Let's edit the international and local configs by hand.
I'll only list the parameters that you need to check.
A hash before the line means the line is commented out.
For the international connection :
sudo kedit /etc/ppp/peers/international
noipdefault
defaultroute
replacedefaultroute
usepeerdns
For the local connection :
sudo kedit /etc/ppp/peers/local
noipdefault
# defaultroute
# replacedefaultroute
# usepeerdns
If you want to manage the connections manually or test them you can use the following commands.
pon international
poff international
pon local
poff local
Depending on what order you do then ppp0 and ppp1 can swap around at will which is not desirable and we will fix it in the next section.
Also since the DNS entries in /etc/resolv.conf are only being set up by the international account you won't be able to browse any web sites unless it is connected.
For the moment the local account won't route any traffic because it is not the default route.
Configure interfaces
As we saw in the previous section we have a problem where ppp0 and ppp1 can swap depending on which account was connected first and it's not desirable especially for routing purposes.
To fix this we need to set up the accounts so that we can use interface names like ppp0 and ppp1 instead.
Let's make the necessary changes to /etc/network/interfaces.
sudo kedit /etc/network/interfaces
If you scroll down to the bottom of the file you should see a block that looks like the following :
auto dsl-provider
iface dsl-provider inet ppp
provider dsl-provider
What we're going to do is duplicate the block and replace the interface names with ppp0 and ppp1 for the international and local accounts respectively.
Simply replace the block with the following :
auto ppp0
iface ppp0 inet ppp
provider international
auto ppp1
iface ppp1 inet ppp
provider local
Make sure that the line pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf is at the bottom of the file!
The auto ppp* tells the system to start the connections at boot time.
Now if we want to control the connections we can use the ifup and ifdown commands (interface up and interface down).
Test the connections to make sure there are no problems.
sudo ifup ppp0
sudo ifup ppp1
ifconfig should list both interfaces
sudo ifdown ppp0
sudo ifdown ppp1
Don't use pon or poff from now on unless you want to create a mess - stick with ifup and ifdown. pon and poff don't worry about interface names so if you run pon three times for international you'll end up with ppp0, ppp1 and ppp2.
Static routing
Now the fun part where we actually get the traffic flowing.
We should have two interfaces configured and working.
ppp0 is the international interface and is the default route through which all traffic will flow.
ppp1 is our local interface and we need to tell the system to route all the South African traffic through the interface instead of the international interface.
We'll use static routing to do this and I'll do it in steps so as to not cause too much confusion.
Download Armin's list of local routes from http://alm.za.net/ip/localroutes4.txt
The list is updated every 24 hours and we'll use it instead of duplicating his work.
It contains all the network addresses that are specific to South Africa.
Place the file in /etc/ppp/ sudo mv localroutes4.txt /etc/ppp
We need to create a small script that tells the system to add the routes to the interface when if comes up.
Create a file in /etc/ppp/ip-up.d/ called "zanet".
sudo kedit /etc/ppp/ip-up.d/zanet
Paste the following in the file :
#!/bin/sh -e
# Called when a new interface comes up
# add custom routing for zanet (local South Africa) on ppp1 device
if [ "$PPP_IFACE" = "ppp1" ]
then
cat /etc/ppp/localroutes4.txt | sed s/'\$LOCAL'/$PPP_IFACE/ | while read localroute
do
# Change net to host for /32 addresses
# This is a bug workaround - Armin must fix his list script.
if [[ $localroute =~ "/32" ]]
then
localroute=`echo $localroute | sed s/net/host/`
$localroute
else
$localroute
fi
done
fi
# We need to route DNS lookups via ppp0 (SAIX) instead of ppp1 (IS)
# The static routing will cause the DNS lookups to be made through the local IS
# connection and the SAIX network will block the lookups because they don't originate
# from their network.
if [ "$PPP_IFACE" = "ppp0" ]
then
cat /etc/resolv.conf | sed s/nameserver// | sed s/' '// | while read nameserver
do
route add -host $nameserver $PPP_IFACE
done
fi
Static routing should now work unless you made a mistake or I forgot something.
Test it by starting ppp0 and then ppp1.
If run route -n you should see huge list of static routes for the ppp1 interface and only a few for ppp0.
Automatic localroute updates
You could get wget to retrieve a new list of local routes every so often manually or with a cronjob but I'll leave that up to you.
Automatic interface reconnection
If an interface drops the ppp daemon will try to reconnect it but eventually it will give up.
Below is a simple script that I run every 5 minutes from a user cron job that attempts to bring the interface up again.
Sometimes the interface is down but there seems to be some sort of dirty state in the pppoe library so I do an ifdown before an ifup which fixes the problem.
#!/bin/bash
PATH=$PATH:/sbin
# Make sure ppp0 is still up
if [ "`ifconfig | grep ppp0`" == '' ]
then
sudo ifdown ppp0
sudo ifup ppp0
fi
# Make sure ppp1 is still up
if [ "`ifconfig | grep ppp1`" == '' ]
then
sudo ifdown ppp1
sudo ifup ppp1
fi
The crontab syntax is :
*/5 * * * * sh /path-to-some-place/check_connections.sh
You'll first need to chmod +x the file of course.
You should now have a dual connection setup which will start automatically at boot time.
I set up Shorewall for some extra protection - if anyone wants to know how to configure it for dual connections I'll add it but it is explained in th docs quite well already.
I hope this information will be useful to someone.
I'm assuming that the international account is an expensive SAIX based one and the local one is a cheap IS based on but it will work for any ISP account.
If you're using Ubuntu you may have to replace references to "sudo kedit" with the Ubuntu equivalents such as "gksudo" or "sudo gedit" since KDE and it's apps probably won't be installed by default.
I prefer good old vi because it's practically universal across *nix machines but let me not start a flame war.
Install required packages
- pppoeconf
You need to make sure that you have pppoeconf installed.
It's not essential but I'm not the type that likes writing half a dozen PAP and CHAP configs to set up a connection.
dpkg -s pppoeconf will tell you if it's installed.
To install it if it's missing : sudo apt-get install pppoeconf
- RP-PPPoE
Install the PPPoE protocol from Roaring Penguin.
http://www.roaringpenguin.com/en/penguin/openSourceProducts/rpPppoe
The installation instructions are in the download file but you don't need to run the GUI or use it to set up a PPPoE connection. All we need it for is the protocol which is in a library.
Do the following :
tar zxf rp-pppoe-3.8.tar.gz
cd rp-pppoe-3.8/src
./configure
sudo make install
Configure ADSL router/modem
Make sure your ADSL modem is in bridge mode. I won't discuss how to do that since it's different for each modem and it will be part of the modem documentation anyway.
Create PPPoE accounts
Run pppoeconf and set up the international account.
Accept the defaults provided by pppoeconf and say yes to the start at boot option.
Now test the connection with pon dsl-provider
Your Internet connection should be working and if you list the interfaces with ifconfig you should see ppp0 listed.
Disconnect ppp0 before continuing. poff dsl-provider
Now is where we need to start with some custom changes because dual ADSL connections are practically unheard of overseas and pppoeconf only caters for one account in one config file (dsl-provider).
Move the dsl-provider file located in /etc/ppp/peers to "international".
sudo mv /etc/ppp/peers/dsl-provider /etc/ppp/peers/international
We need to do this because when we set up the local account it will overwrite dsl-provider.
Run pppoeconf again and set up the local account but make sure you answer no to the "Use peer DNS" question. We only want to use the DNS servers provided from the ISP from the international account. Say yes to the start at boot option.
Move the dsl-provider config to "local".
sudo mv /etc/ppp/peers/dsl-provider /etc/ppp/peers/local
Let's edit the international and local configs by hand.
I'll only list the parameters that you need to check.
A hash before the line means the line is commented out.
For the international connection :
sudo kedit /etc/ppp/peers/international
noipdefault
defaultroute
replacedefaultroute
usepeerdns
For the local connection :
sudo kedit /etc/ppp/peers/local
noipdefault
# defaultroute
# replacedefaultroute
# usepeerdns
If you want to manage the connections manually or test them you can use the following commands.
pon international
poff international
pon local
poff local
Depending on what order you do then ppp0 and ppp1 can swap around at will which is not desirable and we will fix it in the next section.
Also since the DNS entries in /etc/resolv.conf are only being set up by the international account you won't be able to browse any web sites unless it is connected.
For the moment the local account won't route any traffic because it is not the default route.
Configure interfaces
As we saw in the previous section we have a problem where ppp0 and ppp1 can swap depending on which account was connected first and it's not desirable especially for routing purposes.
To fix this we need to set up the accounts so that we can use interface names like ppp0 and ppp1 instead.
Let's make the necessary changes to /etc/network/interfaces.
sudo kedit /etc/network/interfaces
If you scroll down to the bottom of the file you should see a block that looks like the following :
auto dsl-provider
iface dsl-provider inet ppp
provider dsl-provider
What we're going to do is duplicate the block and replace the interface names with ppp0 and ppp1 for the international and local accounts respectively.
Simply replace the block with the following :
auto ppp0
iface ppp0 inet ppp
provider international
auto ppp1
iface ppp1 inet ppp
provider local
Make sure that the line pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf is at the bottom of the file!
The auto ppp* tells the system to start the connections at boot time.
Now if we want to control the connections we can use the ifup and ifdown commands (interface up and interface down).
Test the connections to make sure there are no problems.
sudo ifup ppp0
sudo ifup ppp1
ifconfig should list both interfaces
sudo ifdown ppp0
sudo ifdown ppp1
Don't use pon or poff from now on unless you want to create a mess - stick with ifup and ifdown. pon and poff don't worry about interface names so if you run pon three times for international you'll end up with ppp0, ppp1 and ppp2.
Static routing
Now the fun part where we actually get the traffic flowing.
We should have two interfaces configured and working.
ppp0 is the international interface and is the default route through which all traffic will flow.
ppp1 is our local interface and we need to tell the system to route all the South African traffic through the interface instead of the international interface.
We'll use static routing to do this and I'll do it in steps so as to not cause too much confusion.
Download Armin's list of local routes from http://alm.za.net/ip/localroutes4.txt
The list is updated every 24 hours and we'll use it instead of duplicating his work.
It contains all the network addresses that are specific to South Africa.
Place the file in /etc/ppp/ sudo mv localroutes4.txt /etc/ppp
We need to create a small script that tells the system to add the routes to the interface when if comes up.
Create a file in /etc/ppp/ip-up.d/ called "zanet".
sudo kedit /etc/ppp/ip-up.d/zanet
Paste the following in the file :
#!/bin/sh -e
# Called when a new interface comes up
# add custom routing for zanet (local South Africa) on ppp1 device
if [ "$PPP_IFACE" = "ppp1" ]
then
cat /etc/ppp/localroutes4.txt | sed s/'\$LOCAL'/$PPP_IFACE/ | while read localroute
do
# Change net to host for /32 addresses
# This is a bug workaround - Armin must fix his list script.
if [[ $localroute =~ "/32" ]]
then
localroute=`echo $localroute | sed s/net/host/`
$localroute
else
$localroute
fi
done
fi
# We need to route DNS lookups via ppp0 (SAIX) instead of ppp1 (IS)
# The static routing will cause the DNS lookups to be made through the local IS
# connection and the SAIX network will block the lookups because they don't originate
# from their network.
if [ "$PPP_IFACE" = "ppp0" ]
then
cat /etc/resolv.conf | sed s/nameserver// | sed s/' '// | while read nameserver
do
route add -host $nameserver $PPP_IFACE
done
fi
Static routing should now work unless you made a mistake or I forgot something.
Test it by starting ppp0 and then ppp1.
If run route -n you should see huge list of static routes for the ppp1 interface and only a few for ppp0.
Automatic localroute updates
You could get wget to retrieve a new list of local routes every so often manually or with a cronjob but I'll leave that up to you.
Automatic interface reconnection
If an interface drops the ppp daemon will try to reconnect it but eventually it will give up.
Below is a simple script that I run every 5 minutes from a user cron job that attempts to bring the interface up again.
Sometimes the interface is down but there seems to be some sort of dirty state in the pppoe library so I do an ifdown before an ifup which fixes the problem.
#!/bin/bash
PATH=$PATH:/sbin
# Make sure ppp0 is still up
if [ "`ifconfig | grep ppp0`" == '' ]
then
sudo ifdown ppp0
sudo ifup ppp0
fi
# Make sure ppp1 is still up
if [ "`ifconfig | grep ppp1`" == '' ]
then
sudo ifdown ppp1
sudo ifup ppp1
fi
The crontab syntax is :
*/5 * * * * sh /path-to-some-place/check_connections.sh
You'll first need to chmod +x the file of course.
You should now have a dual connection setup which will start automatically at boot time.
I set up Shorewall for some extra protection - if anyone wants to know how to configure it for dual connections I'll add it but it is explained in th docs quite well already.
I hope this information will be useful to someone.
Last edited: