*

Welcome, Guest. Please login or register.

Get your own OLPC - Buy an XO laptop on eBay!
Pages: [1]
Print
Author Topic: XO Internet Sharing  (Read 9000 times)

XO Internet Sharing

anna
Master Contributor
***
Posts: 326


February 28, 2010, 03:45:21 PM

Have you ever wished you could have the awesome XO wifi on another computer?  Say your connection goes down and a friendly neighbor lets you borrow a cup of internet.  Unfortunately, you can only connect if you perch next to the window in the freezing utility room.  Wouldn't it be nice to set the XO up there and run a cable inside so you can use your "big boy" laptop on the warm, cozy couch?

You can if you have a compatible USB ethernet adapter and a spare ethernet cable.

Since I wanted to install something on the nand rather than external media, I tested this with the Gnome version of debxo found here:  http://lunge.mit.edu/~dilinger/debxo-latest/images/jffs2/ These instructions should probably work on other Debian based distros. ***Edit:  The instructions for Teapot's Ubuntu are slightly different!***

The XOs native wifi is eth0 and the USB ethernet adapter is eth1.  We're using iptables to send packets between eth0 and eth1, and setting up a simple DHCP server so other computers can pull dynamic IPs from eth1 without having to fool with client-side configuration.

Be root for all the setup steps.

First, enable IP forwarding between the two gateways.

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

Add these two lines to the bottom of /etc/sysctl.conf

Code:
net.ipv4.conf.default.forwarding=1
net.ipv4.conf.all.forwarding=1

Install dnsmasq (this will be your DHCP server)

Code:
aptitude install dnsmasq

Stop the server

Code:
/etc/init.d/dnsmasq stop

Backup the existing dnsmasq.conf file

Code:
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak

Create a new /etc/dnsmasq.conf file with just these two lines:

Code:
interface=eth1
dhcp-range=172.18.0.100,172.18.0.150,24h

Put this in /etc/network/interfaces (See the additional instructions below if you have Teapot's Ubuntu)

Code:
auto eth1
iface eth1 inet static
address 172.18.0.1
netmask 255.255.0.0

*** Note - do not do this for Teapot's Ubuntu.  See special instructions below. ***

Put this in /etc/rc.local before "exit 0"

Code:
iptables -A FORWARD -i eth0 -o eth1 -s 172.18.0.0/24 -m conntrack --ctstate NEW -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

_____________________________________________________________

For Teapot's Ubuntu, do this:


Enter into your Terminal:

Code:
iptables -A FORWARD -i eth0 -o eth1 -s 172.18.0.0/24 -m state --state NEW -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE
iptables-save > /etc/iptables.rules

Now append the above entry for /etc/network/interfaces for eth1 with this at the bottom.

Code:
pre-up iptables-restore < /etc/iptables.rules
_____________________________________________________________

Insert your USB ethernet adapter and reboot.  Connect your XO to the internet however you usually do.  Now you can plug the other end of the ethernet cable into another computer's network card and get your internetz from the XO's wifi connection.  I haven't done any speed testing, but it's been quite sufficient for web browsing.

UPDATE:  I've been watching Hulu, YouTube, and looking at LOLCats on my desktop, and I honestly had to doublecheck to make sure I was actually getting my internet connection from the XO.  Yep, sure was.  There's absolutely no load on the XO from this, either.
« Last Edit: February 28, 2010, 09:55:13 PM by anna » Logged

#1 Re: XO Internet Sharing

KalSeth
Contributor
*
Posts: 44


February 28, 2010, 05:46:21 PM

Thanks for that!

Will the XO still be able to use the connection at the same time? 
I can see this being very helpful.

 Smiley
Logged

#2 Re: XO Internet Sharing

anna
Master Contributor
***
Posts: 326


February 28, 2010, 05:52:37 PM

Will the XO still be able to use the connection at the same time? 

Yes, the XO can still use the internet connection.  If the user doesn't mind a USB ethernet dongle and a cable hanging off the side.
Logged

#3 Re Sharing Internet XO

Dinky
Senior Contributor
**
Posts: 238


February 28, 2010, 06:09:24 PM

It appears the reverse direction is possible??

The Internetless neighbor XO ( or all the neighbood XO's) can connect to the Internet via my XO USB to wired Internet.

Just reverse the eth0 and eth1 in the code, aye ?

Now, if they could only daisy chain out a mile or so instead of all directly connecting to my XO, then the end of the street could join the party.
« Last Edit: February 28, 2010, 06:15:38 PM by Dinky » Logged

#4 Re: Re Sharing Internet XO

anna
Master Contributor
***
Posts: 326


February 28, 2010, 06:22:15 PM

It appears the reverse direction is possible??

The Internetless neighbor XO ( or all the neighbood XO's) can connect to the Internet via my XO USB to wired Internet.

Just reverse the eth0 and eth1 in the code, aye ?


There's a bit more to it to create a "MPP" (Mesh Portal Point).  If you're looking to use an XO to broadcast internet to a bunch of XOs from a wired ethernet connection, look into the XS on XO.  http://wiki.laptop.org/go/XS-on-XO  That requires an SD card, though.

The XO's native wifi device creates a school mesh portal automagically.
Logged

#5 Re:Sharing Internet XO

Dinky
Senior Contributor
**
Posts: 238


February 28, 2010, 06:33:52 PM

No need for expanded MPP here, just to get one neighbor XO lad on internet.  The principle seems the same :  set up xo with forwarding as above.  I'll see if I can hack your code.
Logged

#6 Re:Sharing Internet XO

anna
Master Contributor
***
Posts: 326


February 28, 2010, 06:41:47 PM

No need for expanded MPP here, just to get one neighbor XO lad on internet.  The principle seems the same :  set up xo with forwarding as above.  I'll see if I can hack your code.

The XO's native wifi doesn't support Master mode, so it can't broadcast an essid.  You can't just turn the devices around.  For another XO to be able to connect wirelessly, you'll have to hook up an AP or create a MPP.

Edit:  I haven't tested this, but here's a link:  http://wiki.laptop.org/go/Test_Config_Notes#Turn_on_MPP_Capability
« Last Edit: February 28, 2010, 06:48:25 PM by anna » Logged

#7 Re: XO Internet Sharing

anna
Master Contributor
***
Posts: 326


February 28, 2010, 10:08:09 PM

If you want to try this on Teapot's Ubuntu, I just made some edits to the original post.  Seems that kernel didn't want to support some of the iptables options.  No worries, though.  Just follow the special "Teapot Ubuntu" instructions and it works just fine.

I'm posting from my desktop with an internet connection from an XO running Teapot's Ubuntu.

BTW, you can see dhcp leases like so:

Code:
root@OLPC:~# cat /var/lib/misc/dnsmasq.leases
1267509479 00:80:c6:ea:10:2e 172.18.0.130 anna-desktop *
Logged

#8 Re: XO Internet Sharing

KalSeth
Contributor
*
Posts: 44


March 09, 2010, 01:15:58 AM

If I do this can I still use my USB ethernet dongle to get the XO connected in spots where there is only wired ethernet or will this mess up the settings for that?

I love the word dongle.

Thanks again Anna.
Logged

#9 Re: XO Internet Sharing

anna
Master Contributor
***
Posts: 326


March 09, 2010, 05:15:09 PM

If I do this can I still use my USB ethernet dongle to get the XO connected in spots where there is only wired ethernet or will this mess up the settings for that?

If anyone has a more elegant solution than this, please share.  That said, we can use udev to rename the dongle (I love that word, too) depending on what we want.

Put this in /etc/network/interfaces

Code:
auto eth2
iface eth2 inet dhcp

Now to switch between sharing your connection and getting it from the USB adapter, you can edit /etc/udev/rules.d/70-persistent-net.rules and change eth1 to eth2 and vice versa.  Remove the dongle, reinsert it, then

Code:
/etc/init.d/networking restart

So when we call the dongle eth1, it's sharing the XO's internet connection.  When we call it eth2, it's a traditional wired connection.
Logged

#10 Re: XO Internet Sharing via MPP

Dinky
Senior Contributor
**
Posts: 238


April 29, 2010, 09:45:46 PM

anna:

Finally got arround to trying your link for daisy chaining XO's via Mesh down the street to a single Internet connection.

http://wiki.laptop.org/go/Test_Config_Notes#Turn_on_MPP_Capability

with the accompanying:

http://wiki.laptop.org/go/XO_with_USB_Cellular_Modem

Works great.  

The mpp.py file is already present as mpp-DISABLE.py  .  In the instructions for the modem, eth1 is substituted for ppp0  in the command.

One XO is connected to the Internet via a USB to Ethernet adapter.  The other XO's mesh connect to it.  All can use the internet at the same time (within limits).  The articles say that the XO at the Internet connection can not share activities, but they appear to share well via a Jabber server (at least for the simple tests with Maze Activity).

Thanks for the link.
Logged

#11 Re: XO Internet Sharing

Avasz
Commenter

Posts: 5


February 28, 2011, 09:44:52 PM

I followed your tutorial about XO internet Sharing, and instead of connecting the other end of the ethernet cable to another machine, I connected it to an AP. And when I connect to that AP from other devices, I can't browse internet. I have disabled dhcp in the AP.
Is there something else I need to do to make it work?
Logged

#12 Re: XO Internet Sharing

Avasz
Commenter

Posts: 5


February 28, 2011, 09:58:25 PM

I followed your tutorial about XO internet Sharing, and instead of connecting the other end of the ethernet cable to another machine, I connected it to an AP. And when I connect to that AP from other devices, I can't browse internet. I have disabled dhcp in the AP.
Is there something else I need to do to make it work?
Ok made it work. Found that there was something wrong with AP's configuration. Sorry.
And Thanks.
Logged
Pages: [1]
Print
Jump to:  

Members
Total Members: 2406
Latest: sembik
Stats
Total Posts: 31943
Total Topics: 3843
Online Today: 25
Online Ever: 238
(April 18, 2011, 09:48:50 PM)
Users Online
Users: 0
Guests: 13
Total: 13