Mobile Internet over Bluetooth Part 2
Following on from configuring your mobile phone for Internet over bluetooth...
Once you have your device configured, the next thing you need is to connect over bluetooth to some machine to route your traffic for you. I have a laptop with built-in bluetooth and I'm running Redhat Enterprise Linux version 5. You need to configure and setup bluetooth, a ppp bluetooth daemon, and some simple routing to get your phone on the Internet. First off you need to pair your laptop with your phone, there's plenty of info on how to do this around the web and it's simple enough I'll assume you now have a GnuBox configured phone paired with your laptop.
First off you need to set up Internet Connection Sharing (in windows speak) or IP Masquerading (to anybody who know's what they're talking about), on Linux this is done with iptables. Insert the following rules:
Enable IP forwarding:
Start your web browser on your phone and tell it to connect using the Bt access point you have already configured. On the command line on your laptop you should see something similar to:
As I said, I run Red Hat, which provides for several handy interfaces to help with the setup of Internet over bluetooth from my phone. Here are some further instructions specific, but not limited to, how I've done things on my machine so I everything happens neatly during boot and I don't need to run any commands to set up the connection...
Once you have your device configured, the next thing you need is to connect over bluetooth to some machine to route your traffic for you. I have a laptop with built-in bluetooth and I'm running Redhat Enterprise Linux version 5. You need to configure and setup bluetooth, a ppp bluetooth daemon, and some simple routing to get your phone on the Internet. First off you need to pair your laptop with your phone, there's plenty of info on how to do this around the web and it's simple enough I'll assume you now have a GnuBox configured phone paired with your laptop.
First off you need to set up Internet Connection Sharing (in windows speak) or IP Masquerading (to anybody who know's what they're talking about), on Linux this is done with iptables. Insert the following rules:
- iptables -A FORWARD -i ppp0 -j ACCEPT
- iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
- iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Enable IP forwarding:
- echo 1 > /proc/sys/net/ipv4/ip_forward
- sdptool add SP
- dund -n --listen --msdun noauth 192.168.1.1:192.168.1.2 crtscts 115200 ms-dns
lock
Start your web browser on your phone and tell it to connect using the Bt access point you have already configured. On the command line on your laptop you should see something similar to:
Using interface ppp0This shows your phone and your laptop are now connected through a ppp serial type connection over bluetooth using the /dev/rfcomm1 device, your phone will have the IP address 192.168.1.2 and your laptop ppp0 device will have the ipaddress 192.168.1.1. Your phone should have 192.168.1.1 set as the gateway automatically by GnuBox and the DNS address will be passed when dund sets up the ppp connection as per your command line options. Once connected, you should be able to browse the web on your phone for free through your laptop!
Connect: ppp0 <--> /dev/rfcomm1
local IP address 192.168.1.1
remote IP address 192.168.1.2
As I said, I run Red Hat, which provides for several handy interfaces to help with the setup of Internet over bluetooth from my phone. Here are some further instructions specific, but not limited to, how I've done things on my machine so I everything happens neatly during boot and I don't need to run any commands to set up the connection...
- You'll want your iptables rules in place when you boot, you can append rules to /etc/iptables.d/ to do this:
- Add the following lines to a file in /etc/iptables.d/filter/FORWARD/
- -A FORWARD -i ppp0 -j ACCEPT
- -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
- -A FORWARD -i ppp0 -j ACCEPT
- Add the following lines to a file in /etc/iptables.d/nat/POSTROUTING/
- -A POSTROUTING -o eth0 -j MASQUERADE
- -A POSTROUTING -o ath0 -j MASQUERADE
- -A POSTROUTING -o eth0 -j MASQUERADE
- Add the following lines to a file in /etc/iptables.d/filter/FORWARD/
- Use sysctl to configure IP forwarding at boot time
- Add (or change) the following definition in /etc/sysctl.conf
- net.ipv4.ip_forward = 1
- Add (or change) the following definition in /etc/sysctl.conf
- Register the serial protocol at boot time for your SDP server
- Add the following line to the start definition after SDP is started in /etc/init.d/bluetooth
- sdptool add SP
- Add the following line to the start definition after SDP is started in /etc/init.d/bluetooth
- Start the dund daemon at boot time with the correct configuration options
- chkconfig dund on (to start the service at boot time)
- Create a file called /etc/ppp/peers/dun with the following contents
- noauth
- 192.168.1.1:192.168.1.2
- crtscts 115200
- ms-dns
- lock
- noauth
- Edit the file /etc/sysconfig/dund so you have the following configuration
- DUNDARGS='--listen --msdun call dun'
- chkconfig dund on (to start the service at boot time)