[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BT Call Prices (This is a little long, but perhaps useful)



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8 Mar 00, at 16:47, Richard wrote:

> So, how do I get i4l to work with six different ISPs ?  With Kisdn at the
> same time ?

I can't tell you about kisdn - KDE looks/feels too much like Windows for 
my tastes.  So here is how I do it.  This is not (by any means) the only 
way, so keep an open mind.

Also, I built my Linux machine from scratch and from sources; it does 
not match any distribution, but that is what you get for being a UNIX 
bigot since Academic source edition 6...

Firstly, I configure the multiple accounts at boot time from an rc.isdn 
script like this (the xxx sequences are to avoid you knowing more than 
is healthy about me!)  I've chosen two examples here - one that gives 
me a fixed IP address, and another that negotiates.

#!/bin/bash
#
# /etc/rc.d/rc.isdn: Start up the ISDN system
#
declare -a ISPNameList=(demon uklinux ...)
declare -a ISPTelNoList=(08452120667 08456621398 ...)
declare -a MyTelNoList=(xxx xxx ...)
declare -a TimeoutList=(300 300)
declare -a MyIPList=(158.152.122.252 1.1.1.1)
declare -a MyMaskList=(255.255.0.0 255.255.0.0)
declare -a ISPIPList=(158.152.1.222 1.1.1.1)
declare -a DNS1List=(158.152.1.58 212.1.130.10)
declare -a DNS2List=(158.152.1.46 212.1.128.156)

/sbin/modprobe hisax type=18 protocol=2 id=line0
/sbin/modprobe isdn_bsdcomp

if [ -x /sbin/isdnctrl -a -x /sbin/ipppd ]
then
    /sbin/isdnctrl verbose 2
    /sbin/isdnctrl system on
    declare -i ifnum=0
    declare daemonParams=""
    while [ $ifnum -lt ${#ISPNameList[ [at] ]} ]
    do
	declare interface=ippp$ifnum
	declare isptelno=${ISPTelNoList[$ifnum]}
	declare mytelno=${MyTelNoList[$ifnum]}
	declare timeout=${TimeoutList[$ifnum]}
	declare myip=${MyIPList[$ifnum]}
	declare mask=${MyMaskList[$ifnum]}
	declare ispip=${ISPIPList[$ifnum]}
	declare DNS1=${DNS1List[$ifnum]}
	declare DNS2=${DNS2List[$ifnum]}
	declare ispname=${ISPNameList[$ifnum]}

	/sbin/isdnctrl addif $interface
	/sbin/isdnctrl addphone $interface out $isptelno
	/sbin/isdnctrl addphone $interface in $mytelno
	/sbin/isdnctrl addphone $interface in 0
	/sbin/isdnctrl eaz $interface $mytelno
	/sbin/isdnctrl huptimeout $interface $timeout
	/sbin/isdnctrl l2_prot $interface hdlc
	/sbin/isdnctrl l3_prot $interface trans
	/sbin/isdnctrl encap $interface syncppp
	/sbin/isdnctrl secure $interface on
	/sbin/isdnctrl pppbind $interface $ifnum
	/sbin/isdnctrl status $interface on

           /sbin/ifconfig $interface $myip pointopoint $ispip netmask $mask
           /sbin/route add $ispip $interface
	/sbin/ifconfig $interface -arp -broadcast

	/sbin/ipppd /dev/$interface file /etc/ppp/ioptions.$interface

	ifnum=$(($ifnum + 1))
    done
fi

Then you need ioptions.ipppN files in the /etc/ppp directory, like

# ioptions.ippp0
158.152.122.252:158.152.1.222
ipparam dummy:demon:158.152.1.58:158.152.1.46
defaultroute
name elsabio
user elsabio
lock
mru 1500
mtu 1500
#debug
#-detach
- -vjccomp
- -ac
- -pc
# -bsdcomp
- -vj

#ioptions.ippp1
noipdefault
ipparam dummy:uklinux:212.1.130.10:212.1.128.156
defaultroute
ipcp-accept-local
ipcp-accept-remote
name elsabio
user elsabio
lock
mru 1500
mtu 1500
# debug
#-detach
- -ac
- -pc
# -bsdcomp
# -vj
# -vjccomp

Then, you need the ip-up and ip-down scripts to work this lot through:

#!/usr/bin/bash
#
# This ip-up script is based upon one originally distributed with XISP
# by Dimitrios P. Bouras.
#
# The changes I have made have largely been to gereralise it so as to be
# able to support ISDN connections as well as Analogue modem 
dialups.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published 
by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty 
of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# 
############################################################
###############
# Mark J Hewitt.  August 1999
#
# 
############################################################
###############

# The following are modified automatically by 'make install'
#------------------------------------------------------------
NetGroup=uucp
XispID=/usr/local/bin/xispid

# Setup all variables passed on from [i]pppd
# We treat these as global within the funtions herein
#----------------------------------------------------
interface=$1
device=$2
speed=$3
localIP=$4
remoteIP=$5
ipparam=$6

echo `date` UP "interface=$1 device=$2 speed=$3 localIP=$4 
remoteIP=$5 ipparam=$6" >> /tmp/IP

# Bail out if no ipparam
#-----------------------
if [ "$ipparam"x = x ]
then
    exit 0
fi

# Parse the ipparam argument string
#----------------------------------
pipefname=`echo $ipparam | sed -e 's/\:.*$//'`
temp=`echo $ipparam | sed -e 's/^[^:]*\://'`
ISPname=`echo $temp | sed -e 's/\:.*$//'`
temp=`echo $temp | sed -e 's/^[^:]*\://'`
DNS1=`echo $temp | sed -e 's/\:.*$//'`
DNS2=`echo $temp | sed -e 's/^.*\://'`

# 
############################################################
###############
# Define some useful functions
#
#
# 
############################################################
###############
# AddDNS IP1 IP2
#   Add lines in /etc/resolv.conf for the DNS
#
AddDNS()
{
    DNS1=$1
    DNS2=$2

    if [ "$DNS1"x != x ]
    then
	echo "nameserver	$DNS1	# ++++ dialup added DNS ++++" 
>> /etc/resolv.conf
	echo "Primary DNS: $DNS1"
    fi
    if [ "$DNS2"x != x ]
    then
	echo "nameserver	$DNS2	# ++++ dialup added DNS ++++" 
>> /etc/resolv.conf
	echo "Secondary DNS: $DNS2"
    fi
}

# 
############################################################
##################
# ISDN_up
#
ISDN_up()
{
    AddDNS "$DNS1" "$DNS2"
}


# 
############################################################
###############
# Analogue_up
#
Analogue_up()
{

#   Make sure that the user who started pppd is indeed a member of 
$NetGroup
#   If not, then this is most probably a system security attack, so bail 
out
#   Also run xispid security checks on the named-pipe file name and 
modes
#----------------------------------------------------------------------------
    userOK=0
    for gname in `$XispID -rGn`
    do
	if [ "$gname" = "$NetGroup" ]
        then
	    userOK=1
	fi
    done

    if [ $userOK ]
    then
	if ! `$XispID -c $pipefname`
        then
	    exit 0
	fi
    else
	exit 0
    fi

#   The following command redirects all stdout/stderr output (from this
#   script or from any command run within it) to the xisp browser window
#-----------------------------------------------------------------------
    exec 1>>$pipefname 2>&1

#   Add lines in /etc/resolv.conf for the DNS entries
#----------------------------------------------------
    AddDNS "$DNS1" "$DNS2"


#   The ISPname variable can now be used to carry out global and/or
#   ISP-specific tasks like downloading mail and/or news. The folowing
#   statements are examples. Modify them to best suit your needs.
#---------------------------------------------------------------------

# echo "Interface $interface is now UP"
# echo "On $device at $speed Baud"
# echo "Local IP: $localIP"
# echo "Remote IP: $remoteIP"

    case $ISPname in

	'My First Provider')
		echo "Provider 1"
		;;

	'My Second Provider')
		echo "Provider 2"
		;;

	*)
		;;
    esac
}



# 
############################################################
###############
#
# 
############################################################
###############

# Determine if this is an ISDN or Analogue connection, and
# behave appropriateley.  We switch on the device name here
# for Linux.  Other systems may have to change this area
#
case $device in
  /dev/ippp* ) ISDN_up ;;
  * )         Analogue_up
esac

exit 0


#!/usr/bin/bash
#
# This ip-down script is based upon one originally distributed with XISP
# by Dimitrios P. Bouras.
#
# The changes I have made have largely been to gereralise it so as to be
# able to support ISDN connections as well as Analogue modem 
dialups.
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published 
by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty 
of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# 
############################################################
###############
# Mark J Hewitt.  August 1999
#
# 
############################################################
###############

# The following are modified automatically by 'make install'
#------------------------------------------------------------
NetGroup=uucp
XispID=/usr/local/bin/xispid

# Setup all variables passed on from [i]pppd
# We treat these as global within the funtions herein
#----------------------------------------------------
interface=$1
device=$2
speed=$3
localIP=$4
remoteIP=$5
ipparam=$6

echo `date` DOWN "interface=$1 device=$2 speed=$3 localIP=$4 
remoteIP=$5 ipparam=$6" >> /tmp/IP

# Bail out if no ipparam
#------------------------
if [ "$ipparam"x = x ]
then
    exit 0
fi

# Parse the ipparam argument string
#----------------------------------
pipefname=`echo $ipparam | sed -e 's/\:.*$//'`
temp=`echo $ipparam | sed -e 's/^[^:]*\://'`
ISPname=`echo $temp | sed -e 's/\:.*$//'`
temp=`echo $temp | sed -e 's/^[^:]*\://'`
DNS1=`echo $temp | sed -e 's/\:.*$//'`
DNS2=`echo $temp | sed -e 's/^.*\://'`
 # 
############################################################
###############
# Define some useful functions
#
#
# 
############################################################
###############
# RemoveDNS
#   Remove those lines previously added to /etc/resolv.conf for the DNS
#
RemoveDNS()
{
    umask 022
    if [ "$DNS1"x != x ]
    then
	grep -v "++++ dialup added DNS ++++" /etc/resolv.conf > 
/etc/resolv.conf.new
	mv -f /etc/resolv.conf.new /etc/resolv.conf
	echo "DNS entries removed"
    fi
}


# 
############################################################
##################
# ISDN_down
#
ISDN_down()
{
    RemoveDNS
}

# 
############################################################
###############
# Analogue_down
#
Analogue_down()
{

#   Make sure that the user who started pppd is indeed a member of 
$NetGroup
#   If not, then this is most probably a system security attack, so bail 
out
#   Also run xispid security checks on the named-pipe file name and 
modes
#--------------------------------------------------------------------------
    userOK=0
    for gname in `$XispID -rGn`
    do
	if [ "$gname" = "$NetGroup" ]
        then
	    userOK=1
	fi
    done

    if [ $userOK ]
    then
	if ! `$XispID -c $pipefname`
        then
	    exit 0
	fi
    else
	exit 0
    fi

#   The following command redirects all stdout/stderr output (from this
#   script or from any command run within it) to the xisp browser window
#----------------------------------------------------------------------
    exec 1>>$pipefname 2>&1

#   Remove lines in /etc/resolv.conf for the DNS entries
#-------------------------------------------------------
    RemoveDNS

#   The ISPname variable can now be used to carry out global and/or
#   ISP-specific tasks like downloading mail and/or news. The folowing
#   statements are examples. Modify them to best suit your needs.
#--------------------------------------------------------------------

# echo "Interface $interface is now DOWN"
# echo "On $device at $speed Baud"
# echo "Local IP: $localIP"
# echo "Remote IP: $remoteIP"

    case $ISPname in

	'My First Provider')
		echo "Provider 1"
		;;

	'My Second Provider')
		echo "Provider 2"
		;;

	*)
		;;
    esac
}



# 
############################################################
###############
#
# 
############################################################
###############

# Determine if this is an ISDN or Analogue connection, and
# behave appropriateley.  We switch on the device name here
# for Linux.  Other systems may have to change this area
#
case $device in
  /dev/ippp* ) ISDN_down ;;
  * )         Analogue_down
esac

exit 0


Then you sort out you pap/chap secrets etc, peers, and other niceties, 
and away you go with each ISP on an ipppN device, which you can dial 
with isdnctrl dial ippp0, etc.

All pretty straightforward, and could asily be tidied further if you have the 
time (which I don't!).

HTH.  Sorry for length of this message.



























-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2 -- QDPGP 2.60 
Comment: PGP Signature

iQA/AwUBOMbFSho3dDZB8V9VEQJhhQCdEVnpG7lSMWL2wLReU0G+mc1Ei2QAnj+6
xTiCDd5R8f/OB9gyVpjC6jBl
=nrSx
-----END PGP SIGNATURE-----
-- 
Mark J. Hewitt      at home           mjh [at] elsabio.demon.co.uk
"As for the best leaders, the people do not notice their existence.
 The next best leaders, the people admire.  The next, the people
 fear, and the next the people hate.  But when the best leader's
 work is done, the people say, "We did it ourselves."
 Lao Tzu, 6th Century BC.
---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word 
 "unsubscribe" in the body of the message. 

  GNU the choice of a complete generation.