User Tools

Site Tools


stand-alone_wifi_ap_and_ssh

This is an old revision of the document!


Sometimes it is nice to have the Chumby serve as a wireless access point without routing anything to a back-haul network. An example might be where the Chumby is the communications hub in a robot – you want to easily connect to the robot, but the robot isn't actually routing any traffic for you and doesn't have a second network connection. Luckily, the Chumby already includes a script that enables it to act as a routing AP. Making a stand-alone AP is pretty much just a simple job of commenting out the parts that connect to the back-haul network, and you are done.

These instructions were written using a Chumby hacker board V1, as it shipped in January of 2011. They are based on this blog post by Eric Gregori.

First, make sure you have basic WiFi working as described in this tutorial: WiFi networking - Getting to the Internet via wireless 802.11b/g (in progress). Get up to the point where you see the RT73 reported as alive:

rt73usb 1-1.1:1.0: firmware: requesting rt73.bin
ADDRCONF(NETDEV_UP): wlan0: link is not ready

OK, got your basic WiFi working? Great. Now let's get it going as an AP.

The Chumby boot process looks for three user-supplied boot scripts: userhook0, userhook1, and userhook2. Each one is later in the boot process, depending on when you want to hook in. We want a late hook, so we'll edit userhook2.

Remount the file system with write access:

mount -oremount,rw /

Create the directory /psp/rfs1 if it does not already exist. This is where the boot scripts look for your scripts.

mkdir /psp/rfs1

Create your file userhook2, something like this:

chumby-:/psp/rfs1 # more userhook2 
# DBC 28-Jan-11
/bin/echo "**** Starting userhook2 ****"

# modified start_ap.sh is stand-alone AP
/psp/rfs1/start_ap.sh

/bin/echo "**** Ending userhook2 ****"

Don't forget to 'chmod 755' it. Now the Chumby boot scripts will execute userhook2 late in the boot process. We'll copy the regular start_ap.sh from /usr/chumby/scripts start_ap.sh and comment out some lines.

# Dave Curtis 28-Jan-11
# Staring with CHB V1 script, following mods by
# Eric Gregory 
#
# Set up Chumby to be a wireless AP, with no back-haul routing.
# Chumby will be 192.168.9.99
# Chumby will hand out DHCP addresses 192.168.9.1-9

# DBC - turn off external interface
#EXTIF=$(route -n | grep ^0.0.0.0 | awk '{print $8}')
#INTIF=$(ifconfig -a | egrep 'encap:(Ethernet|Point)' | awk '{print $1}' | grep -v ${EXTIF} | head -n 1)
INTIF=wlan0

# DBC - There won't ben an external inteface.
## Ensure we have an internal and an external interface.
#if [ "x${INTIF}" = "x" -o "x${INTIF}" = "x" ]
#then
#    echo "Only one interface detected.  Not starting router."
#    exit
#fi
       

At the top of the file, we'll comment out the EXTIF variable and the original setting for the INTIF variable, and point INTIF, the internal interface, at wlan0. Then, since there is no external interface, comment out all the code that insists on looking for one.

Now toward the bottom of the file, we'll fix up DHCP to give what we want. I wanted the Chumby to be 192.168.9.99, so I commented out the 10.x.x.x net address and added my own.

# Bring up the internal wifi interface.
#ifconfig ${INTIF} 10.0.50.1
ifconfig ${INTIF} 192.168.9.99

Next, this sets up DHCP so serve addresses in the 192.168.9.1 to 192.168.9.9 range:

# Run dnsmasq, which is a combination DNS relay and DHCP server.
mkdir -p /var/lib/misc      
#dnsmasq -i ${INTIF} -F 10.0.50.100,10.0.50.250,15000 -K
dnsmasq -i ${INTIF} -F 192.168.9.1,192.168.9.9 -K

Finally, comment out all that silly routing we don't want:

# DBC - We're not routing nothing to nobody
## Set up IP forwarding     
#iptables -t nat -F         
#iptables -t nat -A POSTROUTING -o ${EXTIF} -j MASQUERADE
#echo 1 > /proc/sys/net/ipv4/ip_forward

It's a good idea to 'chmod 644' the original /usr/chumby/scritps/start_ap.sh so that it doesn't get executed when you aren't expecting it. Reboot! At this point you should be able to get a DHCP address from your Chumby. It sure would be nice if we could ssh into it now. Update userhook2 to look list this:

# DBC 28-Jan-11
/bin/echo "**** Starting userhook2 ****"

# modified start_ap.sh is stand-alone AP
/psp/rfs1/start_ap.sh

# start sshd
service_control sshd start

/bin/echo "**** Ending userhook2 ****"

After reboot, you should be able to ssh into port 22. If you want to change the port number, you should be aware that /etc/sshd_config is just a decoy – the real file that is honored by sshd is in /user/local/etc/sshd_config. You can change to a different port number by editing the 'Port' line:

chumby-:/psp/rfs1 # more /usr/local/etc/sshd_config 
..snip..
Port 222
..snip..

At this point, you will be running a wide-open wireless AP on a box with no root password. Now might be a good time to add a root password.

/home/ladyada/public_html/wiki/data/attic/stand-alone_wifi_ap_and_ssh.1296436192.txt.gz · Last modified: 2016/01/28 18:05 (external edit)