Friday, April 27, 2007

Nokia N800 / Linux Laptop Ad-Hoc Connection Howto

OK, so I just got a Nokia N800 Internet tablet. I figured, I could use it as a laptop replacement in some cases when I don't feel like lugging around the big machine. To make a long story short (this is a tech post after all... so let's not get carried away...;-), the device , in its default config , does not help much without an internet connection. The N800's primary method of "hooking up" is Wifi. So I ran into this situation where Wifi internet connections were unavailable but I had my Linux laptop that used a wired connection to the internet. The laptop also has its Wifi option, which in this case was unused... Doh!

For reasons I don't want to disclose (;-) I really wanted to get on the Net with my N800. I could have used my mobile phone as a modem and pay Cingular generously for that. But I didn't find so attractive. What I really wanted to do, was to connect the N800 to my laptop through wifi ad-hoc mode and use the laptop as a gateway for the N800 to get on the Net via the laptops wired connection. Got that? (Note: the same scenario applies on many other situations including making your own access point at home using a desktop PC that has Wifi capabilities).

So here is how...

1. Configure laptop Wifi for ad-hoc mode

I have tried this with two laptops, an Lenovo/IBM T60 and an HP DV2000 both running openSuse Linux 10.2. The instructions below should be the same for pretty much any distribution but there is a possibility that some hardware configurations (read: Wifi chip-sets) might have trouble doing this under Linux...

Also... on the DV2000 I used the Windows drivers for the Broadcom Wifi chip-set through ndiswrapper.

So where was I...? Ad-hoc mode... Right. So, assuming wlan0 is the wifi interface, get a terminal and do:

linux> su -
linux# iwconfig wlan0 essid ADHOCNET mode ad-hoc
linux# iwconfig wlan0 key "s:0123456789abc"

Substitute "ADHOCNET" for your desired ESSID. I am also setting this up for 128-bit WEP encryption... we don't want to leave our machine vulnerable right? So substitute "s:0123456789abc" for your ASCII encryption key of choice. (Note: the key string as used here must be exactly 13 characters. If that seems weird, check out the iwconfig man page).

2. Configure Routing, NAT and MAC Address Filtering

The deal here is the following: the laptop needs to be told what to do with packets coming from the N800 and how to get packets back to it. At the same time, we don't want anyone just connecting to this ad-hoc network and gaining internet access that way... if it's not secured, this little ad-hoc network could be a loop hole to a corporate or home LAN. Generally we don't want that...

The commands below assume that there is currently no firewall of any kind running on the system. Additionally, the "iptables" tool and corresponding kernel modules need to be available. Most distributions will install these but in case there are any errors when the commands below are executed, make sure these requirements are fulfilled. So Again, in a terminal window on the laptop:

linux> su -
linux# echo 1 > /proc/sys/net/ipv4/ip_forward
linux# iptables -t filter -A INPUT --match state --state RELATED,ESTABLISHED -j ACCEPT
linux# iptables -t filter -P INPUT DROP
linux# iptables -t nat -A POSTROUTING --out-interface eth0 -j MASQUERADE
linux# iptables -N macfilter
linux# iptables -A macfilter -m mac --mac-source 00:19:4F:AB:CD:EF -j RETURN
linux# iptables -A macfilter -j REJECT
linux# iptables -A FORWARD -m state --state NEW -j macfilter
linux# ifconfig wlan0 10.10.0.1 netmask 255.255.255.0 up
I don't want to go over every line here. Freely consult the iptables man page as necessary ;-). Couple of things though: "--out-interface" must be set to what ever interface corresponds to the wired interface. The "--mac-source" parameter should be set to the MAC address of the N800.

Note: this is a minimal security configuration, designed to protect the wired network. Depending on environment, it would be recommended to generate a more complete firewall and add the NAT and MAC filter to that.

3. Configure the N800

Fire up the N800 and open "Tools > Control Panel". Select "Connectivity > Connections". Tap "New" to start the connection wizard. Give the connection a name... be creative... and select WLAN.

You'll be asked whether you would like to scan for a network. You can do that and if you do, select
"ADHOCNET" or whatever ESSID you used above in step 1. After selecting the network you want to connect to make sure that "Network mode" is "ad-hoc" and that "Security method" is "WEP". When asked, enter the WEP key you specified above in step 1.

When the "Connection setup complete" screen is displayed, tap "Advanced > IP Addresses". Un-ckeck "Auto-retrieve IP address" and enter:
IP address: 10.10.0.2
Subnet mask: 255.255.255.0
Router: 10.10.0.1

Scroll down and set at least the "Primary DNS address". I used the DNS from the laptop and you can get that by typing "cat /etc/resolv.conf" from a terminal.

Select "OK", "Finish", "Done" and "OK" and you should be OK, finished, done and OK.

Hope this might actually help someone. Otherwise I typed this all for nothing... ah well...


14 comments:

virens said...

Thank a lot for this post - it`s really great! I played around a lot of time to do this net with N800. Don`t shutdown you blog, it`s really useful!

Could you write something about you soft, that you using on tablet?

Thanks once again!

Anonymous said...

Thanks for this useful post (particulary for n800 users who don't have an access point) !

Anonymous said...

Thanks a lot for the post - I got my N800 setup and browsing the web with ASUS WL-167G USB2.0 WLAN Adapter in no time.

Anonymous said...

when i set wlan0 to ad-hoc it says device or resource busy, then i type

ifconfig wlan0 down

after that i am able to set wlan0 to ad-hoc but typing

ifconfig wlan0 up

it says operation not supported?

Anonymous said...

Good words.

Anonymous said...

thanks for a good howto :)
well, i tried it often, it never worked, then i replaced wicd-connection-manager with the original. seems like wicd blocks manual network configuration.
the only thing that doesn't work is encryption. wep is weak but it'd be better than nothing. when i try wep-encryption, i couldn't get in the internet with my n800, without wep, no prob (?) :)

Anonymous said...

Can anyone recommend the top performing Remote Management utility for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central performance reporting
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!

Anonymous said...

Cool post as for me. It would be great to read a bit more concerning this topic. The only thing this blog misses is a few photos of any devices.
David Karver
Phone jammers

Anonymous said...

I just added your blog site to my blogroll, I pray you would give some thought to doing the same.

herve leger dress said...

Thanks for sharing!

Anonymous said...

some multitude regular [url=http://www.tasty-onlinecasino.co.uk/]online casinos[/url] http://www.onlinecasinotaste.co.uk/ Hi, I'm Andy the webmaster of this online slots site, please see our forum can Own Accession to assorted types of machines with diversified games for the players. http://www.onlinecasinotaste.co.uk/

Anonymous said...

net helps you to uncover and compare guaranteed riskly personal loans and give free helpful high risk unsecured loans like You can fill up be simple application form online from the comfort of your home or business office

Anonymous said...

The technology changes very quickly and with this quick change the techniques also need to be updated and not only techniques,
even the websites needs to keep themselves changing and editing their contents
and their looks. When choosing an SEO service,
the first thing for small businesses to consider is the costs factor.

These social marketing websites are used for finding opinion and selling a brand.



my web blog Referencement au maroc

buydollqian said...

muñecas sexuales