LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 10-28-2008, 07:52 AM   #1
Vectis
LQ Newbie
 
Registered: Jul 2004
Location: Isle of Wight - England
Distribution: Slackware 10.0
Posts: 5

Rep: Reputation: 0
simultaneous mobile (cell) phone internet over bluetooth connections


Hi,

I have for a few years now, been able to connect my phone to the internet using a bluetooth connection to my pc, but I can only connect one phone at a time, is it possible to have more than one connected together at the same time?. I have a Nokia 6680 (two actually) and this is setup using a program called 'gnubox'. My pc is running a version of 'Slax' OS and I use the following script on my pc to get this all working:

#!/bin/sh

PHONE_MAC=##:##:##:##:##:## # Phones MAC address
EXT_IF=eth0 # My externl interface (to the net)
INT_NET=192.168.1.0/24 # My internal subnet (eg. 192.168.1.0/24)
MY_IP=192.168.1.2 # This PCs internal IP address (eg. 192.168.1.1)
PHONE_IP=192.168.1.3 # The IP I give to my phone (eg. 192.168.1.10)
DNS_SERVER=62.69.62.6 # My ISPs DNS server

ANY=0.0.0.0/0
IPTABLES=/usr/sbin/iptables
MODPROBE=/sbin/modprobe

/usr/sbin/hcid
hciconfig hci0 up
/usr/sbin/sdpd
rfcomm bind /dev/rfcomm1 $PHONE_MAC 10
rfcomm bind /dev/rfcomm2 $PHONE_MAC 3
dund --nodetach --listen --channel 3 --msdun 30 noauth $MY_IP:$PHONE_IP crtscts 115200 ms-dns $DNS_SERVER lock &
sdptool add --channel=3 SP
sdptool add --channel=10 OPUSH

$MODPROBE ip_tables
$MODPROBE iptable_filter
$MODPROBE ip_nat_ftp
$MODPROBE ip_conntrack
$MODPROBE ip_conntrack_ftp
echo "1" > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
$IPTABLES -A FORWARD -i $EXT_IF -o ppp0 -s $ANY -d $INT_NET -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i ppp0 -d $ANY -j ACCEPT
$IPTABLES -A POSTROUTING -t nat -o $EXT_IF -j MASQUERADE

I guess I need to edit this somehow, to allow for additional connections, but i'm not sure how.

BTW, even though I have my phone mac in this script, I can connect either of my phones providing I enter the bluetooth pin.
 
Old 10-29-2008, 02:07 AM   #2
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
So at the moment you edit that script and connect to one phone or the other?

Your script will have to evolve to become considerably more complex; in particular you will have to create functions to call.

The first step is to create a script which can detect which phones are in range and automatically connect. The script must also be able to check if a phone is already connected (why connect twice). As you connect and so on, you need to identify what interfaces or device files are being created; you will need to pass that information onto the functions which you call so that you can create the correct iptables rules and so on. Also, it would be nice to control things to a degree so that each phone is always accessible by the same name or something (maybe always ppp8 and ppp9?). Have fun reading the manuals and poking around.
 
Old 10-29-2008, 04:18 PM   #3
Vectis
LQ Newbie
 
Registered: Jul 2004
Location: Isle of Wight - England
Distribution: Slackware 10.0
Posts: 5

Original Poster
Rep: Reputation: 0
I've changed the script somewhat, so as to include my second phone, and I have managed to get both phones connected at the same time, however I have only managed this once. Usually when connecting the second phone, the ip address given to it is the same as the first phone and so I cant access the internet on the second phone. Any ideas?

#!/bin/sh

PHONE_MAC=##:##:##:##:##:## # Phones MAC address
PHONE_MAC2=##:##:##:##:##:## #
EXT_IF=eth0 # My externl interface (to the net)
INT_NET=192.168.1.0/24 # My internal subnet (eg. 192.168.1.0/24)
MY_IP=192.168.1.102 # This PCs internal IP address (eg. 192.168.1.1)
PHONE_IP=192.168.1.3 # The IP I give to my phone (eg. 192.168.1.10)
PHONE2_IP=192.168.1.4
DNS_SERVER=62.69.62.6 # My ISPs DNS server

ANY=0.0.0.0/0
IPTABLES=/usr/sbin/iptables
MODPROBE=/sbin/modprobe

/usr/sbin/hcid
hciconfig hci0 up
/usr/sbin/sdpd
rfcomm bind /dev/rfcomm1 $PHONE_MAC 10
rfcomm bind /dev/rfcomm2 $PHONE_MAC 3
rfcomm bind /dev/rfcomm5 $PHONE2_MAC 10
rfcomm bind /dev/rfcomm6 $PHONE2_MAC 3

dund --nodetach --listen --channel 3 --msdun 30 noauth $MY_IP:$PHONE_IP crtscts 115200 ms-dns $DNS_SERVER lock &
dund --nodetach --listen --channel 7 --msdun 30 noauth $MY_IP:$PHONE2_IP crtscts 115200 ms-dns $DNS_SERVER lock &
sdptool add --channel=3 SP
sdptool add --channel=10 OPUSH

$MODPROBE ip_tables
$MODPROBE iptable_filter
$MODPROBE ip_nat_ftp
$MODPROBE ip_conntrack
$MODPROBE ip_conntrack_ftp
echo "1" > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
$IPTABLES -A FORWARD -i $EXT_IF -o ppp0 -s $ANY -d $INT_NET -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i $EXT_IF -o ppp1 -s $ANY -d $INT_NET -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A FORWARD -i ppp0 -d $ANY -j ACCEPT
$IPTABLES -A FORWARD -i ppp1 -d $ANY -j ACCEPT
$IPTABLES -A POSTROUTING -t nat -o $EXT_IF -j MASQUERADE
 
Old 10-29-2008, 08:39 PM   #4
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Could some of the problem be that you have:

PHONE_MAC2

and later you use the undefined:

PHONE2_MAC
 
Old 10-30-2008, 02:31 AM   #5
Vectis
LQ Newbie
 
Registered: Jul 2004
Location: Isle of Wight - England
Distribution: Slackware 10.0
Posts: 5

Original Poster
Rep: Reputation: 0
Sorry, thats a typo. my script does actually read:

PHONE2_MAC

rfcomm gives me this output:

rfcomm0: ##:##:##:##:##:F1 -> ##:##:##:##:##:19 channel 3 connected [reuse-dlc release-on-hup tty-attached]
rfcomm1: ##:##:##:##:##:19 channel 10 clean
rfcomm2: ##:##:##:##:##:19 channel 3 clean
rfcomm3: ##:##:##:##:##:F1 -> ##:##:##:##:##:67 channel 3 connected [reuse-dlc release-on-hup tty-attached]
rfcomm5: ##:##:##:##:##:67 channel 10 clean
rfcomm6: ##:##:##:##:##:67 channel 3 clean

I guess this is the problem, its trying to connect on the same channel and give phone2 the same ip.

When I had them both connected the output was:

rfcomm0: ##:##:##:##:##:F1 -> ##:##:##:##:##:19 channel 7 connected [reuse-dlc release-on-hup tty-attached]
rfcomm1: ##:##:##:##:##:19 channel 10 clean
rfcomm2: ##:##:##:##:##:19 channel 3 clean
rfcomm3: ##:##:##:##:##:F1 -> ##:##:##:##:##:67 channel 3 connected [reuse-dlc release-on-hup tty-attached]
rfcomm5: ##:##:##:##:##:67 channel 10 clean
rfcomm6: ##:##:##:##:##:67 channel 3 clean

I think I will update the Bluez stack (mine is a bit old), and try again.
 
Old 10-30-2008, 04:14 AM   #6
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
Are you running the script multiple times or just once? If there is some way to get information from the phones before you finalize the connection, it should be possible to make your script more robust and explicitly connect each phone to a fixed channel and so on.
 
Old 10-30-2008, 07:15 AM   #7
Vectis
LQ Newbie
 
Registered: Jul 2004
Location: Isle of Wight - England
Distribution: Slackware 10.0
Posts: 5

Original Poster
Rep: Reputation: 0
The script is called once from /etc/rc.d/rc.local at boot.

I don't think I have any means of getting info from the phones
 
Old 10-30-2008, 08:16 AM   #8
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
I can't see why rfcomm isn't binding just the device you specify. Have a look at the Gentoo guide - maybe you'll find something useful:

http://www.gentoo.org/doc/en/bluetooth-guide.xml

The official documentation of the tools is just plain awful. I wonder if I should dare read through the protocol specs and the source ...
 
Old 10-31-2008, 07:08 AM   #9
pinniped
Senior Member
 
Registered: May 2008
Location: planet earth
Distribution: Debian
Posts: 1,732

Rep: Reputation: 50
One thing I don't see in your scripts is the 'connect' - where are you doing the RFCOMM connect between the devices? For example:

rfcomm connect 0 BT_ADDR_OF_PHONE_1 1
(connect rfcomm0 to the device with the given bluetooth hardware address using channel 1)

Sorry - it's late - bind/connect - what's the difference. It's just that 'bind' doesn't means quite the same thing in socket programming.

Last edited by pinniped; 10-31-2008 at 07:10 AM.
 
Old 11-02-2008, 05:33 AM   #10
Vectis
LQ Newbie
 
Registered: Jul 2004
Location: Isle of Wight - England
Distribution: Slackware 10.0
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for your continued help.

Do you mean this:

#
# RFCOMM configuration file.
#

rfcomm0 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device
device ##:##:##:##:##:67;

# RFCOMM channel for the connection
channel 1;

# Description of the connection
comment "Example Bluetooth device";
}

rfcomm3 {
# Automatically bind the device at startup
bind yes;

# Bluetooth address of the device
device ##:##:##:##:##:19;

# RFCOMM channel for the connection
channel 1;

# Description of the connection
comment "Phone_2";
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mobile/Cell phone iInternet collieman Linux - Networking 1 07-18-2008 02:51 AM
Handsfree cell phone using PC via Bluetooth? Doug52392 Linux - Hardware 1 12-21-2007 08:09 PM
accessing internet + Mandrake10.0+ with cell phone + bluetooth eboy98 Linux - Newbie 1 10-24-2007 06:39 PM
Bluetooth transfer between PC and cell phone ed_homeLinux Linux - Hardware 3 07-21-2007 07:33 AM
linux support for internet over bluetooth to cell phone? edman007 Linux - Hardware 3 09-08-2005 02:08 PM


All times are GMT -5. The time now is 11:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration