Hi to all:

I got a second Nanonote this week, just in case my first one breaks 
down.  I spent several hours experimenting on how to connect more than 
one Nanonote to a single computer.  There were quite a few dead ends, 
confusions, and foggy moments but I finally got something to work.  I 
am no expert in the rather arcane world of gateways, routes, and more 
that come into play.  I followed what worked for one Nanonote and 
tried various adjustments to get it working for two Nanonotes.  

Important: All of my desktop or servers run Debian.  I am now on 
Debian Wheezy on my desktops.  I suspect there will be some 
differences with other distributions.  Also all work is done
as root on the host machine.  sudo would also work, I suspect,
if its config file is setup properly.

I have two nanonotes.  One will have the host name of: "nn" and the 
other the host name of "nm".  Also, I always work from Micro SD cards 
so that the host name really goes with the SD card:) 


1.  After some trial and error I discovered that each Nanonote is 
assigned a unique usb designation when it is connected to the 
host computer.  The first Nanonote to be connected 
to the host computer will get: usb0, the next will get: usb1.  I 
assume, but cannot test, that the third Nanonote would get: usb2.  
Thus with two Nanonotes connected to a computer, a review of the end 
of /var/log/kern.log, would show both usb0 and usb1 being active.  

Note: I have sometimes had the second connection fail.  So it is 
useful to run 

tail -f -n 30 /var/log/kern.log 

to see what the kernel "thinks" about the connection.  If it fails, 
unplug the usb cable and then plug it in again.  I'm not sure why this 
happens but it has happened more than once so far.  

2.  Decide what private network will apply to each of the nanonotes.  
They must differ.  Of course private networks are cheap:)  I tried 
various ways to use one private network but could not get it to work.  
Here is what I did.  

  Nanonote          gateway ip address   nanonote ip address

    nn               192.168.254.100      192.168.254.101
    nm               192.168.253.100      192.168.253.101

On the host computer, that is the one to which the Nanonotes are 
connected via usb cables: 

  2.1  Edit /etc/hosts and add both ip addresses for the Nanonotes

       192.168.254.101   nn
       192.168.253.101   nm
  
       This just makes it easier to refer to them. 


  2.2 Add the following to the .bashrc file, or the equivalent 
      for other shells:

      export nn=192.168.254
      export nm=192.168.253

      These environmental variables will be used to make 
      connecting a bit more convenient.  There is no conflict
      between "nn" as a host name and "nn" as an environmental 
      variable. 

3.  Construct a script on the host machine that contains the 
following: 

#!/bin/sh
echo usb$1  $2
ifconfig  usb$1 $2.100 
iptables -A POSTROUTING -t nat -j MASQUERADE -s $2.0/24
sysctl -w net.ipv4.ip_forward=1
route add -host $2.101 usb$1

In my case the file name of the script was: nano_connect

This script has two command line arguments.  The first argument is the 
number of the usb device assigned to that nanonote.  The second 
argument will be the environmental variable that gives all but the 
last field of the static UP address of the Nanonote being connected.  

To connect Nanonote nn to the host, execute 


nano_connect 0  $nn


Connecting Nanonote nm to the host after connecting Nanonote nn 
requires 

nano_connect 1 $nm

We can connect the Nanonotes in any order or just connect one and the 
proper choice of arguments to the nano_connect script makes it all 
work.  

4.  Before this works we have to add some information to the 
/etc/config/network file on each Nanonote.  

For Nanonote nn, the network file looks like this: 

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname   usb0
        option proto    static
        option ipaddr   192.168.254.101
        option netmask  255.255.255.0
        option gateway  192.168.254.100
        option 'dns'      '208.201.224.xx 208.201.224.xx 192.168.1.1'

The last line defines the DNS's to use.  I use the servers from my ISP 
followed by the DNS for my LAN.  Note that the IP address for the LAN 
must be the last entry in the list for this to work.  In some earlier 
versions of OpenWRT, the local LAN entry had to be first:) The default 
contents of the network file are the same as this, as I recall, except 
for the DNS option line.  

For Nanonote nm, the network file is almost the same.

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname   usb0
        option proto    static
        option ipaddr   192.168.253.101
        option netmask  255.255.255.0
        option gateway  192.168.253.100
        option 'dns'      '208.201.224.xx 208.201.224.xx 192.168.1.1'

The only difference is that the .254.  becomes .253.

Notice that the "option ifname" is usb0 because there is only one 
interface from each Nanonote.  There are two interfaces for the host 
computer.  This confused me at first.  I thought that the second 
Nanonote should have usb1 to match the usb1 on the host.  This turned 
out to be faulty thinking.  The USB designations are local to each 
machine and only depend on the number of connections being made on 
each machine.  The critical part is that the IP addresses match.  

5. To finally make the connection complete, run 

/etc/init.d/network restart

to restart the networking software on each Nanonote connected to the 
host machine.  To save typing on the Nanonote keyboard, I create a 
script called "connect" that contains: 

#!/bin/sh
/etc/init.d/network restart


6. The final item needed is to enable access to the Nanonotes
from machines, other than the host machine, on my LAN.  To do 
that create a script called "nano_add"

#!/bin/sh
#Delete old route-ip address may have changed
route del -net $1.0/24
#Add a route to ac to access nanonotes
route add -net $1.0 netmask 255.255.255.0 gw $2 eth0

This script has two arguments:  The first is the environmental variable
for each nanonote and the second is the machine name of the host for 
the Nanonotes.  For example, I have a netbook, called "ac" that is 
used to interface to the Nanonotes.  Then on another machine, say,
i7, my main desktop, I would execute

nano_add $nn  ac

so that I could access Nanonote nn from i7.  To access Nanonote
nm

nano_add $nm ac

There is probably a more streamlined method than this one but for now, 
what I have works, and is flexible enough that I can connect one or 
two Nanonotes in any order and on any machine in my LAN so long as I 
carefully define the contents of the /etc/hosts file as well as the 
environmental variables for the Nanonotes.  


Thanks to Xiangfu Liu for the original scripts that worked for connecting
one Nanonote.  I just modified those in various ways to get something 
going for two Nanonotes.

Hope this helps someone else.

               Delbert



_______________________________________________
Qi Hardware Discussion List
Mail to list (members only): [email protected]
Subscribe or Unsubscribe: 
http://lists.en.qi-hardware.com/mailman/listinfo/discussion

Reply via email to