maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC) (https://talk.maemo.org/showthread.php?t=58570)

anapospastos 2011-02-10 14:30

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

&

bnep0 Link encap:Ethernet HWaddr C0:38:F9:18:40:FF
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:161 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37112 (36.2 KiB) TX bytes:0 (0.0 B)

9000 2011-02-10 16:16

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Let see if you can ping to your 850. In your N900:
Code:

ping 192.168.1.2

anapospastos 2011-02-10 17:00

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
No it doesn't answer. Something is wrong with the N900 I think. I tried with proxy enabled on k850 but again no luck.

9000 2011-02-10 17:21

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I just notice that there isn't any IP address in the 'ifconfig bnep0' output, and your iptables queue is empty, which means the script isn't even run properly. It's required in section 4.3.3 that you must have root privilege to run the script.

Do you have rootsh installed? If so, please enter run and run the script again to see if the IP address has been setup correctly.

anapospastos 2011-02-10 18:54

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Ok now the script is working but ip tables are still empty. "ifconfig bnep0" output is

Code:

bnep0    Link encap:Ethernet  HWaddr C0:38:F9:18:40:FF 
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::c238:f9ff:fe18:40ff/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1822 (1.7 KiB)  TX bytes:766 (766.0 B)

The k850 should get a new ip or it shares this from N900?

9000 2011-02-10 23:18

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by anapospastos (Post 941180)
Ok now the script is working but ip tables are still empty. "ifconfig bnep0" output is

Code:

bnep0    Link encap:Ethernet  HWaddr C0:38:F9:18:40:FF 
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::c238:f9ff:fe18:40ff/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1822 (1.7 KiB)  TX bytes:766 (766.0 B)

The k850 should get a new ip or it shares this from N900?

The script has not (yet) handle dhcp, so you must setup the IP address on your k850 manually.

anapospastos 2011-02-11 09:15

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I 've set manually the ip as also dns, gateway etc but it refusing to connect.

9000 2011-02-11 11:46

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
no ping to peer side? Is there any way to check whether the PAN has successfully establish on your 850 side? Have you tried to pair up PAN with you N900 to other device like a PC?

Just to make sure, are you sure you setup the IP of the correct interface on your 850? In N900 it is bnep0, which is setup by my script.

eezo 2011-02-11 20:01

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Thanks for the tutorial, it works for me with Gentoo on my notebook.

However, although I'm not "afraid" to use the terminal, there still is a huge drawback in comparison to tethering via DUN: I can't seem to get it working without running something in the terminal. I understand that bnep0 is created dynamically on the N900 when I'm establishing the connection, but bnep0 doesn't have an IP after the connection is established. Digging through some Debian documentation, I set the IP address and up script in /etc/network/interfaces, but neither is applied. Following the bluez PAN documentation, there's the --devup option for pand, but setting Script under [PANU Role] in /etc/bluetooth/main.conf on the N900 to your setup script doesn't do a thing.
Is anyone deep enough into the N900/Debian side of things to have the final clue for me?

9000 2011-02-12 05:52

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by eezo (Post 943113)
Thanks for the tutorial, it works for me with Gentoo on my notebook.

However, although I'm not "afraid" to use the terminal, there still is a huge drawback in comparison to tethering via DUN: I can't seem to get it working without running something in the terminal. I understand that bnep0 is created dynamically on the N900 when I'm establishing the connection, but bnep0 doesn't have an IP after the connection is established. Digging through some Debian documentation, I set the IP address and up script in /etc/network/interfaces, but neither is applied. Following the bluez PAN documentation, there's the --devup option for pand, but setting Script under [PANU Role] in /etc/bluetooth/main.conf on the N900 to your setup script doesn't do a thing.
Is anyone deep enough into the N900/Debian side of things to have the final clue for me?

NP, what you're working on interested me too. Let's make it work.

What my script does is very simple: setup the IP on bnep0 and create the forwarding for internet access.

If you've seen the bnep0, N900 is pretty much done everything it has to do. You're using Gentoo I'm sure you understand what I mean, and you must see there's nothing in N900 that blocks your way in this case.

That's why I'd like you to check whether there's anything blocked on 850 size. I'm not going to blame 850 for anything poorly written, but there's still a lot of things that can go wrong in 850 if you can't open the terminal and look at the interface directly.

Say, if you've setup the IP on the wrong interface on 850, of course it won't work.

Also, it's chance that there's a startup sequence in 850 that when the PAN is establish it'd automatically do something that is not your intent, and drop the PAN entirely if that sequence failed. That's what we want to find out.

Sorry about the terminal things, but actually I don't go to the terminal to trigger that script everytime when I am using it (daily in fact). I trigger the script through Queen Beecon Widget once I got the PAN established.

eezo 2011-02-13 20:51

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Finally got it working... Not the Debian way, but the udev way of things...

Quote:

# cat /etc/udev/rules.d/96-bnep0.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="bnep0", PROGRAM="/root/bnep0"

# cat /root/bnep0
#!/bin/sh

run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:'Setting up...'

ifconfig bnep0 >/dev/null || exit 1

modprobe ipt_MASQUERADE

iptables -F
iptables -t nat -F

iptables -t nat -A POSTROUTING -o gprs0 -j MASQUERADE

echo 1 > /proc/sys/net/ipv4/ip_forward

ifconfig bnep0 192.168.1.1/24 up

run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:'Bluetooth PAN NATting set up - Enjoy!'

JadeH 2011-03-12 21:21

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I have no bnep0 device no matter what I do and I tried what's in this thread, how do I make it appear? (I tried with bluetooth on, etc, but your script always says there is no bnep0, and when i do ifconfig bnep0 it says it doesn't exist)

eezo 2011-03-12 21:23

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
bnep0 is created automatically on the N900 when you connect from your PC. Does the Bluetooth icon gurn blue when you establish the connection?

JadeH 2011-03-13 15:10

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
yeah it turns blue, I use the bluetooth DUN script fine for tethering, but I wanted to give this bluetooth PAN thing a try.

I can't find a bnep0 device no matter what I do though :/ not sure why

9000 2011-03-13 15:12

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by JadeH (Post 966870)
yeah it turns blue, I use the bluetooth DUN script fine for tethering, but I wanted to give this bluetooth PAN thing a try.

I can't find a bnep0 device no matter what I do though :/ not sure why

Thank you for giving it a try. Let's work it out together.

Regarding the bnep0, have you installed connectivity manager?

JadeH 2011-03-13 15:30

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
yes, I have it installed

9000 2011-03-14 01:04

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by JadeH (Post 966882)
yes, I have it installed

I might have missed this one in the instruction: bluez

Please install it and try again. ^^

JadeH 2011-03-18 00:36

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Hi, sorry my n900 broke due to the usb port falling off, I just got my replacement today, and same problem as my old one! no bnep0. I'm going to try to see if i have bluez installed and tell you what happens

9000 2011-03-18 02:25

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by mauron85 (Post 929290)
For DHCP and Auto DNS configuration, you can inspire from:
http://wiki.maemo.org/N900_USB_router

Just add before stand-alone command:

Code:

dnsmasq -I lo -z -a 192.168.1.1 -F 192.168.1.64,192.168.1.127

PS: tested and it works with Windows 7, but probably you'll have to renew dns lease:
Code:

ipconfig /renew "Name of PAN Adapter"

Per your suggestion the main script in 4.3.1 is modified accordingly such that IP and DNS can be assigned to client automatically once PAN is established.

Thank you very much for your kind help.

JadeH 2011-03-18 05:11

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
apparently i already had bluez installed, what do i do now

i tried hciconfig and it shows hci0 and when there's bluetooth activity the TX and RX increase in number, is it related to bluetooth?

9000 2011-03-18 06:06

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
What do you get when you run the following as root?

Code:

ifconfig bnep0 up
ifconfig bnep0


JadeH 2011-03-18 08:19

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
error: no such device

9000 2011-03-18 08:29

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by JadeH (Post 970128)
error: no such device

then...how about:

Code:

lsmod | grep bnep

JadeH 2011-03-19 01:06

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I got it working! I had to reinstall something related to libicd, but now I see bnep0, thanks for your help

9000 2011-03-19 05:47

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by JadeH (Post 970689)
I got it working! I had to reinstall something related to libicd, but now I see bnep0, thanks for your help

Thanks for your feedback too! I'll take note on that.

jschan 2011-03-31 06:30

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Thanks for this thread. I already had Bluetooth DUN on my laptop, but also just configured Bluetooth PAN just to understand it better. The script and worked like a charm except I just went ahead and used manual IP configuration on my laptop (including setting up Google's DNS rather than changing resolv settings on the n900).

Now that I'm all up and running with PAN tethering on my laptop, I thought I'd give it a go on my shiny new WiFi XOOM. I've gotten to the point where I can tell the XOOM to tether to the n900. However, I can't get any routing working (not even pings). The XOOM keeps reporting no IPv4 values (0.0.0.0), and I haven't figured out how to manually set the values without rooting it. Anyone have any thoughts about how I can do that on an unrooted WiFi ZOOM?

Note: Not being able to tether the XOOM to the n900 will likely result in a returned XOOM, so I'd rather not root it. Also, WiFi tethering is out since the n900 currently only support ad-hoc mode and Android will only connect to WiFi networks in infrastructure mode.

9000 2011-03-31 11:41

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 978945)
Thanks for this thread. I already had Bluetooth DUN on my laptop, but also just configured Bluetooth PAN just to understand it better. The script and worked like a charm except I just went ahead and used manual IP configuration on my laptop (including setting up Google's DNS rather than changing resolv settings on the n900).

Now that I'm all up and running with PAN tethering on my laptop, I thought I'd give it a go on my shiny new WiFi XOOM. I've gotten to the point where I can tell the XOOM to tether to the n900. However, I can't get any routing working (not even pings). The XOOM keeps reporting no IPv4 values (0.0.0.0), and I haven't figured out how to manually set the values without rooting it. Anyone have any thoughts about how I can do that on an unrooted WiFi ZOOM?

Note: Not being able to tether the XOOM to the n900 will likely result in a returned XOOM, so I'd rather not root it. Also, WiFi tethering is out since the n900 currently only support ad-hoc mode and Android will only connect to WiFi networks in infrastructure mode.

I don't have XOOM but from what you described it is probably a DNS problem.

Have you try pinging a pingable external IP address like 67.195.160.76?

jschan 2011-04-01 05:06

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Thanks for the response, 9k.

I'm not sure it's a DNS problem as I can't ping the n900 by ip address from the XOOM. It looks like the N900 gets setup with both an IPv4 and an IPv6 address on the bnep0 interface, but the XOOM only ever gets an IPv6 address.

I'm not currently setup with IPv6 via gprs and don't know enough about the subject yet to know what my options are at this point to get everything talking. Spending my time just reading up at the moment while hoping someone can help direct me down the right path. There's a long thread about IPv6 and some links to bluetooth pan tethering on IPv6 that I'm hoping leads to an epiphany for me.

9000 2011-04-01 06:24

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 979648)
Thanks for the response, 9k.

I'm not sure it's a DNS problem as I can't ping the n900 by ip address from the XOOM. It looks like the N900 gets setup with both an IPv4 and an IPv6 address on the bnep0 interface, but the XOOM only ever gets an IPv6 address.

I'm not currently setup with IPv6 via gprs and don't know enough about the subject yet to know what my options are at this point to get everything talking. Spending my time just reading up at the moment while hoping someone can help direct me down the right path. There's a long thread about IPv6 and some links to bluetooth pan tethering on IPv6 that I'm hoping leads to an epiphany for me.

You cannot ping N900 by its IP address as it does not respond to icmp request by default. You'd have to change its behavior by setting the flag:

Code:

echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
Besides the IP address assignment, I'm not sure if N900's PAN supports IPv6. However, if you'd like to have the iptables accept ipv6 payload, you might have to specify it:

Code:

iptables -t nat -A POSTROUTING -o gprs0 -p ipv6 -j MASQUERADE
or it might _not_ need a specific flag for ipv6 routing, anyway, please test and feedback. Thank you! ^^

jschan 2011-04-01 07:19

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I changed the ping setting, but I'm getting a new "network is unreachable" error now. It looks like the XOOM is neither getting an IPv4 nor an IPv6 address now, but even after reverting the recent changes, it doesn't seem to be helping. :S

9000 2011-04-01 07:56

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 979683)
I changed the ping setting, but I'm getting a new "network is unreachable" error now. It looks like the XOOM is neither getting an IPv4 nor an IPv6 address now, but even after reverting the recent changes, it doesn't seem to be helping. :S

You need to setup an ipv6 network on both N900 and XOOM manually in this case.

You'd need to manually configure ipv6 address on both side and enable the ipv6 forwarding instead of ipv4:

Code:

echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
Of course you need the ipv6 prefix to setup the ipv6 of the bnep0. Please install iproute run the following command to see if your ISP is really providing ipv6 adderss:

Code:

/sbin/ip -6 addr show scope global dev gprs0

jschan 2011-04-01 10:02

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
So I should have probably read the script messages better. As it turns out, initializing a bluetooth connection from the XOOM to the N900 wasn't actually bringing up the bnep0 interface on the n900 so the dnsmasq was failing since it couldn't bind to the interface properly. Once I moved the interface setup commands in your script prior to the dnsmasq, I started getting IPv4 ip addresses just fine on the XOOM.

Once I got to that point, I was able to successfully ping my n900's bnep0 ip. However, I'm still unable to successfully ping any other IP yet. Getting close... Thanks for all your suggestions, 9k.

jschan 2011-04-01 10:57

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
it looks like most of it is working now in actually reverting some of the testing changes i made before realizing that the dnsmasq just wasn't working properly.

i can hit google via ip address tethering through either wlan or grps, but i can't seem to get the dns working with it. i haven't done much more than adding google's dns servers to the n900's resolv config.

9000 2011-04-01 11:00

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 979743)
So I should have probably read the script messages better. As it turns out, initializing a bluetooth connection from the XOOM to the N900 wasn't actually bringing up the bnep0 interface on the n900 so the dnsmasq was failing since it couldn't bind to the interface properly. Once I moved the interface setup commands in your script prior to the dnsmasq, I started getting IPv4 ip addresses just fine on the XOOM.

Once I got to that point, I was able to successfully ping my n900's bnep0 ip. However, I'm still unable to successfully ping any other IP yet. Getting close... Thanks for all your suggestions, 9k.

Then you are 99 percent done. Check the following:

1) cat /proc/sys/net/ipv4/ip_forward to see if it is 1 (enable)
2) run iptables -t nat -A POSTROUTING -o gprs0 -j MASQUERADE
alone as root to see if it returns any error
3) Failing that, you might need run 'route' as root to check if there is any other default route (0.0.0.0) getting in the way.

jschan 2011-04-01 11:15

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
1) ipv4 fowarding is on
2) no error reported
3) routing looks okay:

Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.2.0 * 255.255.255.0 U 0 0 0 bnep0
default 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0

jschan 2011-04-01 11:40

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
It's all up and working now. Rather than add the DNS entries in the resolv.conf, I'm sending it straight to the client using the dhcp-option:

--dhcp-option=6,8.8.8.8,8.8.4.4

Thanks again for all your help, 9k!

Have you looked into trying to put something together using dbus scripts rather than the widget? http://wiki.maemo.org/DbusScripts

It looks interesting. I tried running it in debug mode to take a look at events that the xoom might trigger when connecting to the n900, but I didn't see anything pop up in my initial testing.

9000 2011-04-01 17:41

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
That's great. Glad to know one more device that can work with N900. ^^

dbus-scripts could be risky. For those people who are not heavily relying on dbus triggering, they can use my script. Manual triggering of PAN tethering is not that much hassle anyway. Risk asides, dbus could be very convenient. Tell me how it goes after you tried ;)

jschan 2011-04-01 18:36

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
I did find creating a start/stop script was useful to clean up dnsmasq for clean restarts.

9000 2011-04-01 18:39

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Quote:

Originally Posted by jschan (Post 980011)
I did find creating a start/stop script was useful to clean up dnsmasq for clean restarts.

I haven't encountered any problem with unclean dnsmasq restart. Would you share your experience?

jschan 2011-04-02 03:28

Re: [HOWTO] N900 Bluetooth-PAN Tethering (N900 supplies Internet Access for PC)
 
Sure. I did a lot of testing around switching from wlan to gprs and back without actually disconnecting the bluetooth connection. Dnsmasq stayed up between calls and would cause failure messages when trying to run the start script again with the interface change. I haven't had the time to add it yet, but I'd like to pass the ext interface in as a script param so that I can reuse for lots of different scenarios (e.g. aliases, queen bee widgets, dbus scripts, etc.).


All times are GMT. The time now is 04:08.

vBulletin® Version 3.8.8