Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Wed, 21 Jul 2010

N900 connection sharing the hard way

My N900 has a SIM card with a flat-rate 3G data plan. My laptop hasn't. What do I do when I want to use the Internet on my laptop somewhere that doesn't have WiFi? Well, there are many options:

Option 1: N900 as a USB modem

Use the provided USB cable to connect the N900 to the laptop. Choose "PC Suite" mode on the N900 when you get the USB connection menu. The laptop now sees your N900 as a bog-standard USB 3G modem. Use Network Manager to connect to the internet.

Pros: no extra setup required. The N900 and the laptop can both access the Internet at the same time.

Cons: you have to use a USB cable (I hate cables). You cannot ssh into your N900 (and ssh is my primary file transfer protocol between the laptop and the M900).

Option 2: N900 as a Bluetooth DUN modem

Install Bluetooth DUN support from Maemo Extras. Then use it like you would any other phone that has Bluetooth DUN.

Pros: no cables.

Cons: Bluetooth is the worst technology ever. I never had it work reliably. Plus, Network Manager in Ubuntu 10.04 doesn't support Bluetooth DUN (it supports only Bluetooth PAN, as far as I know).

Option 3: N900 as a WiFi access point with Joikuspot

I haven't tried this.

Pros: simple (hopefully), no cables required.

Cons: Joikuspot is non-free. I'm not an absolute zealot, but I will avoid closed-source stuff when open-source alternatives are available.

Option 4: N900 as a WiFi access point with Mobilehotspot

I haven't tried this either.

Pros: it's an open-source app available from Maemo Extras. No cables required.

Cons: requires a non-standard kernel (or so I've heard). Way outside my comfort level.

Option 5: N900 as a WiFi access point with shell scripts

Here's the shell script I run on my N900: share-wifi. It sets up an ad-hoc WiFi network, and starts a DHCP and DNS server (dnsmasq). Sadly, it cannot set up connection sharing (NAT), so I rely on OpenSSH as a SOCKS5 proxy. The whole setup is like this:

  1. You want the latest firmware (PR 1.2) to avoid this bug.
  2. You need to have OpenSSH installed on the N900. Also, setting up key-based authentication makes it more convenient.
  3. The script assumes that you've set up sudo on the N900 so that you can run any command as root.
  4. You need to have wireless-tools installed. It's in the main SSU repository so you should be able to sudo apt-get install it (if it's not preinstalled; I don't remember).
  5. On the N900 run share-wifi in a terminal (optionally passing a WiFi channel number from 1 to 11, in case you need to avoid interference with nearby networks).
  6. On the laptop connect to the new n900 WLAN and run ssh -D 1080 user@n900. You will get a shell session; the SOCKS proxy will be active while it is open.
  7. Reconfigure your laptop to use a SOCKS5 proxy on localhost:1080. For GNOME systems I've a couple of shell scripts: proxy-on and proxy-off. For applications that do not use the GNOME proxy settings (such as Subversion access over SSH), use tsocks.
  8. When done, hit Ctrl-C on the N900 to terminate the sharing script.

Pros: no non-free software or custom kernel required. No cables.

Cons: complicated to set up. No WLAN power savings available for ad-hoc networks, so battery life is extremely poor (~2 hours). But, hey, no cables!

posted at 01:41 | tags: | permanent link to this entry | 16 comments
Option 1 does support ssh if you just activate the usb0 network interface on the N900:
~ # ifconfig usb0 up
You can also configure dnsmasq as DHCP server to make NetworkManager happy - just add a dhcp-range option and make it listen on usb0:
~ # echo "dhcp-range=,,,24h" >> /etc/dnsmasq.conf
~ # stop dnsmasq
~ # /usr/sbin/dnsmasq -k -2 lo -i usb0 -a -z
posted by Philipp Zabel at Wed Jul 21 09:03:08 2010
Re on option 2 - you should switch to Fedora 13, as Bluetooth DUN over Network Manager works out of the box there and is in fact the most convenient way to connect laptop to the internet via 3G@N900.
posted by Dawid Lorenz at Wed Jul 21 11:03:17 2010
To make option 2 work on Ubuntu, install blueman. works everytime!
posted by archebyte at Wed Jul 21 16:44:00 2010
I tried option 4, and you are right to be outside your comfort level. I kept getting random reboots and had to go through the somewhat frightening uninstall process.
posted by Zac at Wed Jul 21 18:48:31 2010
Having trouble getting option 5 to work , my netbook sees the n900 ad-hoc, but will not connect to it
posted by pronto at Wed Jul 21 21:09:37 2010
Option 3 is nice if you just want it to work and don't mind spending a few pounds for someone to update it and fix it when Nokia releases a new change every 3 to 6 months....  For me, it works well.  One click and I have wifi to share...
posted by Woody14619 at Wed Jul 21 22:41:41 2010
interesting article! i agree with you on all points except adding a few cons. joikuspot is very unstable and often causes your n900 to reboot for an unknown reason.

your script is a really nice idea but it has a huge con, you can't share the wireless with people without giving them access to your mobile. for personal use it's quite a nice idea though!
posted by nion at Wed Jul 21 23:33:04 2010
Option 4 works fine for me - didn't do any hardcore tweaks - just installed packages from the repo and it works.
posted by Rommi at Thu Jul 22 12:30:43 2010
Heh, I wouldn't say that flashing a custom kernel would be outside your comfort level, judging by the fact that you came up with your own custom solution.
posted by cb22 at Thu Jul 22 16:57:24 2010
I've a rule: never replace essential system components, as this makes upgrades difficult.
posted by Marius Gedminas at Thu Jul 22 16:59:14 2010
i dont advice to use option 4, i went thru hell to get the update to PR 1.2 and i almost end up with an useless device because of the customized kernel it installed
posted by rodrigo at Thu Jul 22 17:10:57 2010
Option 4 - Mobilehotspot + Kernel Linux Nokia-N900-51-1 #1 PREEMPT Wed May 26 00:24:03 EEST 2010 armv7l - work fine 4 me and I am very happy 4 now! :-)
posted by peterpunk at Fri Jul 23 11:06:25 2010
I found Joikuspot far too unreliable, the longest I could keep a connection up with it was about 2 minutes :(  However.. you do know DNSMasq can NAT, right?  In fact, the n900 has /everything/ you need for a proper 3g/wifi gateway /out of the box/ with just a little bit of config fiddling.
posted by Wes at Mon Jul 26 01:06:17 2010
How is NAT possible with just dnsmasq?  Inquiring minds want to know.  dnsmasq's manual page contains the letters NAT in only one place: INTERNATIONALISATION.
posted by Marius Gedminas at Mon Jul 26 12:31:41 2010
Just a quick note to say thanks - I didn't like the idea of installing a custom kernel either. (I don't trust my N900 much anyway, the last thing I need is another random change.) I had a few glitches (which I think were purely down to my laptop's picky wifi card) but this seems to work a treat. Nice one.
posted by Steve at Thu Sep 9 19:45:06 2010
I am using option 1 (via usb cable / pc suite 7.1) just wondering how secure this is as in can anyone who is near me jack into my connection? i set a username and password in pc suite when setup the connection but i dont have to do this on the phone and assume it is imbedded into my sim somehow?
posted by jasz74 at Thu Apr 7 12:35:10 2011

Name (required)

E-mail (will not be shown)


Comment (some HTML allowed)