Linux bluetooth development
 help / color / mirror / Atom feed
* [Bluez-users] DUND pre-pppd script
@ 2008-05-29  3:04 arasv
  2008-05-29 11:01 ` Raymond Ingles
  2008-05-29 12:39 ` Brad Midgley
  0 siblings, 2 replies; 7+ messages in thread
From: arasv @ 2008-05-29  3:04 UTC (permalink / raw)
  To: bluez-users

Hi,

I need to determine my ppp IP address pair before I run pppd.

The reason is that I have several network interfaces running at once on my
system so I need to choose an IP address in a subnet that is not already
taken.

Would you recommend that I add a pre-ppp-up mechanism to dund to do this?

If someone knows how to get pppd to run a script *before* it reads its
configuration file then I would rather do that instead.

Aras


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bluez-users] DUND pre-pppd script
  2008-05-29  3:04 [Bluez-users] DUND pre-pppd script arasv
@ 2008-05-29 11:01 ` Raymond Ingles
  2008-05-29 23:36   ` Aras Vaichas
  2008-05-29 12:39 ` Brad Midgley
  1 sibling, 1 reply; 7+ messages in thread
From: Raymond Ingles @ 2008-05-29 11:01 UTC (permalink / raw)
  To: BlueZ users

On Wed, May 28, 2008 at 11:04 PM,  <arasv@magtech.com.au> wrote:
> Hi,
>
> I need to determine my ppp IP address pair before I run pppd.
>
> The reason is that I have several network interfaces running at once on my
> system so I need to choose an IP address in a subnet that is not already
> taken.

 There are three private network ranges:
http://en.wikipedia.org/wiki/Private_network

 Almost always, you can find a range that's not going to be used by
any other NIC in the system. If my home network is on a 10.x subnet,
for example, and I'm letting people dial up via modem to a 192.168.x
range, I could use a 172.16.x address range for DUN.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bluez-users] DUND pre-pppd script
  2008-05-29  3:04 [Bluez-users] DUND pre-pppd script arasv
  2008-05-29 11:01 ` Raymond Ingles
@ 2008-05-29 12:39 ` Brad Midgley
  2008-06-04  7:08   ` Aras Vaichas
  1 sibling, 1 reply; 7+ messages in thread
From: Brad Midgley @ 2008-05-29 12:39 UTC (permalink / raw)
  To: BlueZ users

Aras

> I need to determine my ppp IP address pair before I run pppd.

I ran into this when setting up a bluetooth AP for use with a couple
of nokia devices. They are using dun not pan, and I wanted to assign
different addresses to each device. I had to hardcode the ip addresses
in the nokias' dialup config which wasn't very satisfying.

-- 
Brad

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bluez-users] DUND pre-pppd script
  2008-05-29 11:01 ` Raymond Ingles
@ 2008-05-29 23:36   ` Aras Vaichas
  2008-05-30  2:10     ` Brad Midgley
  0 siblings, 1 reply; 7+ messages in thread
From: Aras Vaichas @ 2008-05-29 23:36 UTC (permalink / raw)
  To: BlueZ users

Raymond Ingles wrote:
> On Wed, May 28, 2008 at 11:04 PM,  <arasv@magtech.com.au> wrote:
>   
>> Hi,
>>
>> I need to determine my ppp IP address pair before I run pppd.
>>
>> The reason is that I have several network interfaces running at once on my
>> system so I need to choose an IP address in a subnet that is not already
>> taken.
>>     
>
>  There are three private network ranges:
> http://en.wikipedia.org/wiki/Private_network
>
>  Almost always, you can find a range that's not going to be used by
> any other NIC in the system. If my home network is on a 10.x subnet,
> for example, and I'm letting people dial up via modem to a 192.168.x
> range, I could use a 172.16.x address range for DUN.
>   
Thanks, I should have been more explicit in my original email.

My device has eth0, usb0, ppp0 and possibly wlan0.

eth0 can be static, link-local or dhcp.
wlan0 can be static, link-local or dhcp.
usb0 is chosen to be on a private network range at connection time that
doesn't conflict with any of the above.
ppp0 is chosen to be on a private network range at connection time that
doesn't conflict with any of the above.

So you see that I have to choose an unused subnet dynamically in order
to keep everything happy and working. The problem is that pppd doesn't
seem to allow for choosing the IP address via a script.

To choose the free subnet I've written a script in Python that searches
all three 3 private network spaces against the existing connections and
then outputs a suitable range in various formats like ifconfig, pppd,
dhcpd.conf.

I think that I can solve this problem by configuring dund to call a pppd
wrapper which calculates the correct, non-colliding, subnet and then
passed on the arguments to pppd.

Aras



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bluez-users] DUND pre-pppd script
  2008-05-29 23:36   ` Aras Vaichas
@ 2008-05-30  2:10     ` Brad Midgley
  2008-05-30 15:51       ` Brad Midgley
  0 siblings, 1 reply; 7+ messages in thread
From: Brad Midgley @ 2008-05-30  2:10 UTC (permalink / raw)
  To: BlueZ users

Aras

> I think that I can solve this problem by configuring dund to call a pppd
> wrapper which calculates the correct, non-colliding, subnet and then
> passed on the arguments to pppd.

although there is no way to coax dund to pass the remote btaddr
address on to a wrapper script, we should be able to figure it out.

tell dund to use the wrapper:
dund --pppd=mypppd ...

in the mypppd wrapper:
#!/bin/sh
BTADDR=`rfcomm show $2 | cut -d ' ' -f2`
# set LOCAL, REMOTE based on the BTADDR
pppd LOCAL:REMOTE $*

if dund were changed then the tty might no longer be on $2.
in my scenario at least, LOCAL would always be 0.0.0.0 and something
like /etc/ppp/ip-up.d/bridge would bridge pppX:

#!/bin/sh
# $2 is the ppp interface name
brctl addif pan0 $2

should be fun to see if any of this works :)

-- 
Brad

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bluez-users] DUND pre-pppd script
  2008-05-30  2:10     ` Brad Midgley
@ 2008-05-30 15:51       ` Brad Midgley
  0 siblings, 0 replies; 7+ messages in thread
From: Brad Midgley @ 2008-05-30 15:51 UTC (permalink / raw)
  To: BlueZ users

fwiw,

this does work with some mods since linux won't bridge ppp. you still
have to ipmasq the 192.168.42.0 subnet in this example... but the
mypppd script can be simplified to a sort of poor man's dhcp server.
(trim the leases if you ever really connect 255 devices over the
lifetime of the server :)

#!/bin/sh
LEASES=/var/run/mypppd.leases
grep -q $DUN_BDADDR $LEASES || echo $DUN_BDADDR >>$LEASES
LOCAL=192.168.32.10
REMOTE=192.168.42.`grep -n $DUN_BDADDR $LEASES | cut -d : -f1`
pppd $LOCAL:$REMOTE $*

-- 
Brad

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Bluez-users] DUND pre-pppd script
  2008-05-29 12:39 ` Brad Midgley
@ 2008-06-04  7:08   ` Aras Vaichas
  0 siblings, 0 replies; 7+ messages in thread
From: Aras Vaichas @ 2008-06-04  7:08 UTC (permalink / raw)
  To: BlueZ users

Brad Midgley wrote:
> Aras
>
>   
>> I need to determine my ppp IP address pair before I run pppd.
>>     
>
> I ran into this when setting up a bluetooth AP for use with a couple
> of nokia devices. They are using dun not pan, and I wanted to assign
> different addresses to each device. I had to hardcode the ip addresses
> in the nokias' dialup config which wasn't very satisfying.
>
>   

Thanks for the replies and ideas. What I've done is this:

#!/bin/sh
IP_PAIR=`safeip -p`
pppd $1 $2 ${IP_PAIR} $3 $4 $5 $6 $7 $8 $9


safeip is a Python script I wrote which finds a private subnet of size 2
that is not in use anywhere on the system. Option -p returns the data
like so: IP1:IP2

I just pass this IP pair on to pppd as well as all the other information
that dund passes on from itself and the /etc/default/bluetooth file.

Works quite well regardless of the state of (almost) any other possible
network configuration. I can also connect from multiple devices and it
just dishes out a new IP pair every time.

my /etc/default/bluetooth file has:
DUND_OPTIONS="--listen --persist --channel 3 --msdun --pppd pppd_pre.sh
crtscts 115200 ms-dns 10.0.0.1

I haven't fixed the ms-dns entry yet, but that is easily done

Aras

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Bluez-users mailing list
Bluez-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-users

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-06-04  7:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-29  3:04 [Bluez-users] DUND pre-pppd script arasv
2008-05-29 11:01 ` Raymond Ingles
2008-05-29 23:36   ` Aras Vaichas
2008-05-30  2:10     ` Brad Midgley
2008-05-30 15:51       ` Brad Midgley
2008-05-29 12:39 ` Brad Midgley
2008-06-04  7:08   ` Aras Vaichas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox