Difference between revisions of "LeapFrog Pollux Platform: Internet Access"

From eLinux.org
Jump to: navigation, search
(Hardware Needed)
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page includes steps that describe how to use routing on your host to enable your Didj to access to the wider Internet via the USB connection.
+
== Summary ==
 +
There are two methods of accessing the internet from your [[LeapFrog_Pollux_Platform| LeapFrog Pollux Platform]] device. While both require hooking up to a host PC, you can either using routing, or bridging to make the connection. Either way nets you the same goal. Some differences are Bridging deals with Layer 2 of the [http://en.wikipedia.org/wiki/OSI_model| OSI model] and and allow DHCP broadcasts, while Routing involves Layer 3.
  
They have been tested in Ubuntu 8.04 Hardy Heron (2.6.24-26 kernel), and are based on similar instructions for other handheld devices.
+
== Prerequisites ==
 +
A Linux host PC
  
'''Prerequisites'''
+
For the Didj, it requires you [[Didj_Enable_Networking| Enable Networking]]
  
[[Didj_Enable_Networking| Enable Networking]]
+
Interface Name
  
'''Configuring the Host'''
+
* The label you're host PC gave your device's interface, ex, usb0 (as used in this tutorial) run dmesg after plugging in to find what your interface name is, ex. eth1, eth2, usb1, usb2, etc, and replace references to usb0, with that.
  
In this example, we assume that the host has an ethernet connection on ''eth0''. (your own config may be different; for example, you may be using a Wifi adapter. In theory, aside from your LAN specific configuration, the steps outlined below should still work.)
+
== Hardware Needed ==
 +
[[LeapFrog_Pollux_Platform:_Console_Access| Console Access]]
  
For this example we establish the following assumptions:
+
== Routing Method ==
 +
''' Configuring the Host '''
  
The gateway between the local network and the Internet is 192.168.0.1
+
For this tutorial we'll use these IP address.
 +
* Host 10.0.0.1
  
The host is connected to the gateway as 192.168.0.116 (assigned by DHCP on eth0)
+
* Device 10.0.0.2
  
The host is connected to the Didj as 192.168.2.1 (assigned statically to usb0 on host)
+
Configure the host machine's /etc/network/interfaces file as follows as root.
 
+
The Didj is connected to the host as 192.168.2.100 (assigned statically to usb0 on Didj)
+
 
+
Configure the host machine's /etc/network/interfaces file as follows:
+
  
 
<code>
 
<code>
Line 30: Line 31:
 
  auto usb0
 
  auto usb0
 
  iface usb0 inet static
 
  iface usb0 inet static
         address 192.168.2.1
+
         address 10.0.0.1
 
         netmask 255.255.255.0
 
         netmask 255.255.255.0
         up route add -net 192.168.2.0 netmask 255.255.255.0 dev usb0
+
         up route add -net 10.0.0.0 netmask 255.255.255.0 dev usb0
 
         up echo 1 > /proc/sys/net/ipv4/ip_forward
 
         up echo 1 > /proc/sys/net/ipv4/ip_forward
 
         up iptables -P FORWARD ACCEPT
 
         up iptables -P FORWARD ACCEPT
         up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.2.100
+
         up iptables -A POSTROUTING -t nat -j MASQUERADE -s 10.0.0.2
         down route del -net 192.168.2.0 netmask 255.255.255.0
+
         down route del -net 10.0.0.0 netmask 255.255.255.0
 
         down echo 0 > /proc/sys/net/ipv4/ip_forward
 
         down echo 0 > /proc/sys/net/ipv4/ip_forward
 
         down iptables -t nat -F POSTROUTING
 
         down iptables -t nat -F POSTROUTING
Line 43: Line 44:
 
To apply these new settings:
 
To apply these new settings:
  
On the Host:
+
'' On Host ''
<code>
+
  $ sudo /etc/init.d/networking restart
  sudo /etc/init.d/networking restart
+
</code>
+
(of course, rebooting the host will also work)
+
  
 +
Now you can proceed to configuring your device
  
'''Configuring the Didj'''
+
== Bridging/Routing Method ==
 +
This is a hybrid method using Bridging and Routing.
 +
''' Configuring the Host '''
  
If you are using a standard Didj configuration and you have not yet done so, rmmod the g_file_storage kernel module and insmod the g_ether/ko module.
+
This will require you have bridge-utils installed
(see http://elinux.org/Didj_Networking_HOWTO#Installing_g_ether.ko)
+
  
With the USB cable connected to your host, configure an IP address on a different subnet from the rest of your LAN
+
'' On Host ''
 +
$ sudo apt-get install bridge-utils
 +
 
 +
You will need to edit a couple configuration files, be sure to make a back up copy first.
 +
 
 +
Edit /etc/network/interfaces by pasting this in at the end of the file.
  
On the Didj:
 
 
<code>
 
<code>
ifconfig usb0 192.168.2.100 netmask 255.255.255.0
+
auto br0
 +
    iface br0 inet static
 +
    address 10.0.0.1
 +
    netmask 255.255.255.0
 +
    pre-up brctl addbr br0
 +
    post-down brctl delbr br0
 +
 
 +
allow-hotplug usb0
 +
    iface usb0 inet manual
 +
    pre-up ifconfig usb0 down
 +
    pre-up brctl addif br0 usb0
 +
    pre-up ifconfig usb0 up
 +
    post-down ifconfig usb0 down
 +
    post-down brctl delif br0 usb0
 
</code>
 
</code>
 +
 +
Edit /etc/rc.local and paste this in just before "exit 0"
 +
 +
echo 1 > /proc/sys/net/ipv4/ip_forward
 +
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 +
/sbin/iptables -A FORWARD -i eth0 -o br0 -m state --state RELATED,ESTABLISHED -j ACCEPT
 +
/sbin/iptables -A FORWARD -i br0 -o eth0 -j ACCEPT
 +
 +
 +
'' On Host ''
 +
$ sudo ifup br0
 +
$ sudo /etc/rc.local
 +
 +
You can now proceed to configuring the device.
 +
 +
== Configuring the Device ==
 +
If you're using a Didj make you have [[Didj_Enable_Networking| Enabled Networking]]
 +
 +
With the USB cable connected to your host, configure an IP address on a different subnet from the rest of your LAN
 +
 +
'' On Device ''
 +
# ifconfig usb0 10.0.0.2 netmask 255.255.255.0
  
 
Next, add a route from your Didj to the host (making it the gateway) using the ip address of the host's usb0 device.
 
Next, add a route from your Didj to the host (making it the gateway) using the ip address of the host's usb0 device.
  
On the Didj:
+
'' On Device ''
<code>
+
  # route add default gw 10.0.0.1 usb0
  route add default gw 192.168.2.1 usb0
+
</code>
+
  
 
Finally, add nameservers to your Didj's /etc/resolv.conf file (you can add the lines from this example which uses the OpenDNS servers)
 
Finally, add nameservers to your Didj's /etc/resolv.conf file (you can add the lines from this example which uses the OpenDNS servers)
<code>
 
 
  nameserver 208.67.222.222
 
  nameserver 208.67.222.222
 
  nameserver 208.61.220.220
 
  nameserver 208.61.220.220
</code>
 
 
  
 
At this point, your Didj is connected to the outside world - and a ping or a wget to yahoo or google should work.
 
At this point, your Didj is connected to the outside world - and a ping or a wget to yahoo or google should work.
Line 83: Line 117:
 
Routing packets from the gateway to the Didj.
 
Routing packets from the gateway to the Didj.
  
 
'''References'''
 
 
http://wiki.openmoko.org/wiki/USB_Networking
 
 
http://wiki.openzaurus.org/HowTos/USB_Networking_Without_Bridging
 
 
'''Acknowledgments'''
 
 
Thanks to losinggeneration for useful input on this!
 
 
[[Category:Didj]]
 
[[Category:Didj]]
 +
[[Category:Leapster Explorer]]
 +
[[Category:LeapPad Explorer]]
 +
[[Category:LeapFrog Pollux Platform]]

Latest revision as of 09:18, 14 July 2011

Summary

There are two methods of accessing the internet from your LeapFrog Pollux Platform device. While both require hooking up to a host PC, you can either using routing, or bridging to make the connection. Either way nets you the same goal. Some differences are Bridging deals with Layer 2 of the OSI model and and allow DHCP broadcasts, while Routing involves Layer 3.

Prerequisites

A Linux host PC

For the Didj, it requires you Enable Networking

Interface Name

  • The label you're host PC gave your device's interface, ex, usb0 (as used in this tutorial) run dmesg after plugging in to find what your interface name is, ex. eth1, eth2, usb1, usb2, etc, and replace references to usb0, with that.

Hardware Needed

Console Access

Routing Method

Configuring the Host

For this tutorial we'll use these IP address.

  • Host 10.0.0.1
  • Device 10.0.0.2

Configure the host machine's /etc/network/interfaces file as follows as root.

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto usb0
iface usb0 inet static
       address 10.0.0.1
       netmask 255.255.255.0
       up route add -net 10.0.0.0 netmask 255.255.255.0 dev usb0
       up echo 1 > /proc/sys/net/ipv4/ip_forward
       up iptables -P FORWARD ACCEPT
       up iptables -A POSTROUTING -t nat -j MASQUERADE -s 10.0.0.2
       down route del -net 10.0.0.0 netmask 255.255.255.0
       down echo 0 > /proc/sys/net/ipv4/ip_forward
       down iptables -t nat -F POSTROUTING

To apply these new settings:

On Host

$ sudo /etc/init.d/networking restart

Now you can proceed to configuring your device

Bridging/Routing Method

This is a hybrid method using Bridging and Routing. Configuring the Host

This will require you have bridge-utils installed

On Host

$ sudo apt-get install bridge-utils

You will need to edit a couple configuration files, be sure to make a back up copy first.

Edit /etc/network/interfaces by pasting this in at the end of the file.

auto br0

   iface br0 inet static
   address 10.0.0.1
   netmask 255.255.255.0
   pre-up brctl addbr br0
   post-down brctl delbr br0

allow-hotplug usb0

   iface usb0 inet manual
   pre-up ifconfig usb0 down
   pre-up brctl addif br0 usb0
   pre-up ifconfig usb0 up
   post-down ifconfig usb0 down
   post-down brctl delif br0 usb0

Edit /etc/rc.local and paste this in just before "exit 0"

echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth0 -o br0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i br0 -o eth0 -j ACCEPT


On Host

$ sudo ifup br0
$ sudo /etc/rc.local

You can now proceed to configuring the device.

Configuring the Device

If you're using a Didj make you have Enabled Networking

With the USB cable connected to your host, configure an IP address on a different subnet from the rest of your LAN

On Device

# ifconfig usb0 10.0.0.2 netmask 255.255.255.0

Next, add a route from your Didj to the host (making it the gateway) using the ip address of the host's usb0 device.

On Device

# route add default gw 10.0.0.1 usb0

Finally, add nameservers to your Didj's /etc/resolv.conf file (you can add the lines from this example which uses the OpenDNS servers)

nameserver 208.67.222.222
nameserver 208.61.220.220

At this point, your Didj is connected to the outside world - and a ping or a wget to yahoo or google should work.


Todo

Routing packets from the gateway to the Didj.