Raspberry Pi Wifi Router/Repeater Howto

Definition

The Broadcom bcm2835, onboard Raspberry Pi 3, can be configured as an access point, wifi client, and router, comprising a wifi router or repeater.

Objective

To apply this procedure to configure a Raspberry Pi 3 as a wifi router or repeaer.


Elements (chrononological) (uc)

  1. Verify hardware support
  2. Install hostapd, dnsmasq, and udhcpd
  3. For safety, it is wise to move-copy-edit-diff complicated files, lest you accidently render your image unbootable. If you make a mistake simply move the .orig file back in place and try again.
  4. Configure access point.
    	  cat <<EOF | sudo tee /etc/hostapd/hostapd.conf
    	  interface=wlan0
    	  driver=nl80211
    	  ssid=WIFINAME
    	  hw_mode=g
    	  channel=6             # 1, 6, or 12
    	  macaddr_acl=0
    	  auth_algs=1
    	  ignore_broadcast_ssid=0
    	  wpa=2
    	  wpa_passphrase=PASSWORD
    	  wpa_key_mgmt=WPA-PSK
    	  #wpa_pairwise=TKIP	# You better do not use this weak encryption (only used by old client devices)
    	  rsn_pairwise=CCMP
    
    	  # The following are peculiar to Raspberry Pi
    	  ieee80211n=1          # 802.11n support
    	  wmm_enabled=1         # QoS support
    	  ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
    	  EOF
          
  5. Configure dns server.
    	  cat <<EOF | sudo tee /etc/dnsmasq.conf
    	  interface=wlan0
    	  driver=nl80211
    	  ssid=WIFINAME
    	  hw_mode=g
    	  channel=6             # 1, 6, or 12
    	  macaddr_acl=0
    	  auth_algs=1
    	  ignore_broadcast_ssid=0
    	  wpa=2
    	  wpa_passphrase=PASSWORD
    	  wpa_key_mgmt=WPA-PSK
    	  #wpa_pairwise=TKIP	# You better do not use this weak encryption (only used by old client devices)
    	  rsn_pairwise=CCMP
    
    	  # The following are peculiar to Raspberry Pi
    	  ieee80211n=1          # 802.11n support
    	  wmm_enabled=1         # QoS support
    	  ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
    	  EOF
          
  6. Add LAN hosts otherwise misreported by /etc/hosts
    	  cat <<EOF | sudo tee /etc/hosts.dnsmasq
    	  ...
    	  192.168.7.1         raspberrypi-or-myhostnam raspberrypi-or-myhostnam.mydomain
    	  ...
    	  EOF
          
  7. Configure dhcpd.
    	  sudo mv /etc/udhcpcd.conf{,.orig}
    	  sudo cp /etc/udhcpcd.conf{.orig,}
    	  sudo vi /etc/udhcpd.conf
    	  diff /etc/udhcpcd.conf{.orig,}
    	  ...
    	    # The start and end of the IP lease block
    	  - start           192.168.0.20    #default: 192.168.0.20
    	  - end             192.168.0.254   #default: 192.168.0.254
    	  + start           192.168.3.192   #default: 192.168.0.20
    	  + end             192.168.3.253   #default: 192.168.0.254
    	  ...
    	    # The interface that udhcpd will use
    	  - interface       eth0            #default: eth0
    	  + interface       wlan0           #default: eth0
    	  ...
    	  - opt     dns     192.168.10.2 192.168.10.10
    	    option  subnet  255.255.255.0
    	  - opt     router  192.168.10.2
    	  - opt     wins    192.168.10.10
    	  - option  dns     129.219.13.81   # appened to above DNS servers for a total of 3
    	  - option  domain  local
    	  + opt     dns     192.168.3.1
    	  + opt     router  192.168.3.1
    	  + option  domain  localnet
    	  ...
    
    	  sudo mv /etc/default/udhcpd{,.orig}
    	  sudo cp /etc/default/udhcpd{.orig,}
    	  sudo vi /etc/default/udhcpd
    	  diff /etc/default/udhcpd{.orig,}
    	    ...
    	    # Comment the following line to enable
    	  - DHCPD_ENABLED="no"
    	  + # DHCPD_ENABLED="no"
    	    ...
          
  8. configure wifi interface
  9. If desired, remove internet access
    	  sudo /sbin/route del default gw 192.168.1.254
          

Equipment

Schedule (uc)


Errors (uc)

Instructor Actions (uc)

Student Actions (uc)


Completion Standards (uc)

Bibliography (uc)

(gcc)
pub by Free Software Foundation, Inc.
http://www.gnu.org/software/gcc/