Rasppi-Wifi

From openmichigan

Jump to: navigation, search

Here's what was done to enable the Raspberry Pi (RPi) to use the Edimax WiFi USB adapter so the RPi could act as a wireless access point.  To perform these tasks, you need a "Terminal" window - either by plugging the HDMI monitor and USB keyboard to the RPi or by using "ssh" to the DHCP address assigned to the ethernet port.  Once you have a ssh connection to the RPi, enter and run the following commands:

sudo apt-get update              #### get updates for DNSMASQ install
sudo apt-get purge hostapd       #### in case old hostapd exists
sudo apt-get install usbmount    #### automatically mount USB device(s)

#### might be worth reading the notes from http://www.jenssegers.be

wget https://github.com/jenssegers/RTL8188-hostapd/archive/v1.1.tar.gz
tar -zxvf v1.1.tar.gz
cd RTL8188-hostapd-1.1/hostapd

sudo make; sudo make install
sudo apt-get install chkconfig
sudo chkconfig --add hostapd
sudo apt-get install dnsmasq


Now create or modify the following files to contain the following content (feel free to first back up these files before you change them!):


/etc/network/interfaces     Note: All entries must begin in the first column on each line!

    auto lo
    iface lo inet loopback
    iface eth0 inet dhcp
    # if you have a static IP address for ethernet
    # connection, it will look something like this
    # iface eth0 inet static
    # address 141.214.200.154
    # netmask 255.255.255.192
    # gateway 141.214.200.129
    # broadcast 141.214.200.191

    allow-hotplug wlan0
    iface wlan0 inet static
    address 192.168.42.1
    netmask 255.255.255.0


/etc/hostapd/hostapd.conf   Note: All entries must begin in the first column on each line!

    interface=wlan0
    ssid=UMMSPI       ''#### or whatever you want you WiFi SSID name to be''
    hw_mode=g
    channel=6
    auth_algs=1
    wmm_enabled=0


/etc/sysctl.conf     Un-comment the following "lines:

    # Uncomment the next line to enable packet forwarding for IPv4
    net.ipv4.ip_forward=1'''

    # Uncomment the next line to enable packet forwarding for IPv6
    # Enabling this option disables Stateless Address Autoconfiguration
    # based on Router Advertisements for this host
    net.ipv6.conf.all.forwarding=1'''


/etc/dnsmasq.conf

    interface=wlan0
    expand-hosts
    domain=local
    dhcp-range=192.168.42.10,192.168.42.200,24h
    dhcp-option=3,192.168.42.1'''

    #NOTE: If you are going to use this Access Point while connected to an ethernet uplink    ''
    # on the UMHS campus, you must add the following lines to the /etc/dnsmasq.conf file:''
    # use this only on the UMHS campus
    # otherwise, comment it out or our friends in Africa 
    # will be blocked from all *.med.umich.edu content!
    # address=/med.umich.edu/127.0.0.1'''
 


Append the following line to the /etc/hosts file:

    192.168.42.1 www.ummspi.net


Add the following "ping" command and the "forward" commands to /etc/init.d/rc.local file.  These will keep wifi adapter from going to "sleep" and will forward all non-local wifi traffic to the ethernet uplink, if it exists)

     case "$1" in
     start)
       do_start'''
           ping -i 15 192.168.42.200 &                    ### Add this line
           iptables -t nat -A POSTROUTING -j MASQUERADE   ### Add this line
       ;;
 

Reboot the RPi and you should know be able to connect to the RPi provided wireless network "UMMSPI". If there is a ethernet cable plugged into the RPi, the RPi will try to use the ethernet cable as the internet up-link for users connected to the "UMMSPI" network.

Personal tools