RaspberryPi/Access Point: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
=Configure RPi As Wireless Access Point= | |||
these instructions will walk you through setting up raspberry pi as wireless access point. | |||
start by connecting to your pi via ssh. Install some software needed to turn the RPi into a router: | |||
<pre> | |||
$ apt-get install -y hostapd udhcpd iw | |||
</pre> | |||
Now pick out a wireless USB adapter that can act as an access point. | |||
<pre> | |||
$ iw list | grep "* AP" | |||
</pre> | |||
(If no results, try a different wireless card.) | |||
View the name server (DNS) address stored in <code>/etc/resolve.conf</code> | |||
Now let's configure the DHCP server, which is responsible for handing out leases. | |||
Edit <code>/etc/udhcpd.conf</code>, use sample file below: | |||
<pre> | |||
# Sample udhcpd configuration file (/etc/udhcpd.conf) | # Sample udhcpd configuration file (/etc/udhcpd.conf) | ||
# The start and end of the IP lease block | # The start and end of the IP lease block | ||
start 192.168.0.20 #default: 192.168.0.20 | start 192.168.0.20 #default: 192.168.0.20 | ||
end 192.168.0.254 #default: 192.168.0.254 | end 192.168.0.254 #default: 192.168.0.254 | ||
# The interface that udhcpd will use | # The interface that udhcpd will use | ||
interface eth0 #default: eth0 | interface eth0 #default: eth0 | ||
# Settings | |||
# | |||
opt dns 192.168.2.1 | opt dns 192.168.2.1 | ||
option subnet 255.255.255.0 | option subnet 255.255.255.0 | ||
| Line 93: | Line 39: | ||
option domain local | option domain local | ||
option lease 864000 | option lease 864000 | ||
</pre> | |||
This assumes that the resolve.conf file contained <code>192.168.2.1</code>. | |||
Now edit one more file: <code>/etc/default/udhcpd</code> | |||
<pre> | |||
# Comment the following line to enable | # Comment the following line to enable | ||
DHCPD_ENABLED="no" | DHCPD_ENABLED="no" | ||
| Line 107: | Line 55: | ||
DHCPD_OPTS="-S" | DHCPD_OPTS="-S" | ||
</pre> | |||
Now you're ready to enable DHCP server, simply by commenting out <code>DHCPD_ENABLED="no"</code> | |||
Change it to <code>#DHCPD_ENABLED="no"</code> and you'll be ready to go. | |||
#DHCPD_ENABLED="no" | |||
Configure the hostapd server by editing the file <code>/etc/hostapd/hostapd.conf</code> and adding the following contents: | |||
Configure the hostapd server | |||
<pre> | |||
interface=wlan0 | interface=wlan0 | ||
ssid= | ssid=CIA_Surveillance_Van | ||
wpa_passphrase= | wpa_passphrase=ITSASECRET | ||
driver=nl80211 | driver=nl80211 | ||
hw_mode=g | hw_mode=g | ||
| Line 131: | Line 77: | ||
wpa_pairwise=TKIP | wpa_pairwise=TKIP | ||
rsn_pairwise=CCMP | rsn_pairwise=CCMP | ||
</pre> | |||
Now enable the hostapd service by creating a default file in <pre>/etc/default/hostapd</code> | |||
<pre> | |||
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration | # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration | ||
# file and hostapd will be started during system boot. An example configuration | # file and hostapd will be started during system boot. An example configuration | ||
| Line 168: | Line 110: | ||
# See sysctl.conf (5) for information. | # See sysctl.conf (5) for information. | ||
# | # | ||
</pre> | |||
<!-- | |||
The vi editor opens the kernel parameters file (/etc/sysctl.conf). | |||
The vi editor opens the kernel parameters file (/etc/sysctl.conf). | |||
Uncomment the line beginning with net.ipv4.ip_forward by removing the # from the beginning of the line. | Uncomment the line beginning with net.ipv4.ip_forward by removing the # from the beginning of the line. | ||
# Uncomment the next line to enable packet forwarding for IPv4 | # Uncomment the next line to enable packet forwarding for IPv4 | ||
Revision as of 17:20, 17 March 2016
Configure RPi As Wireless Access Point
these instructions will walk you through setting up raspberry pi as wireless access point.
start by connecting to your pi via ssh. Install some software needed to turn the RPi into a router:
$ apt-get install -y hostapd udhcpd iw
Now pick out a wireless USB adapter that can act as an access point.
$ iw list | grep "* AP"
(If no results, try a different wireless card.)
View the name server (DNS) address stored in /etc/resolve.conf
Now let's configure the DHCP server, which is responsible for handing out leases.
Edit /etc/udhcpd.conf, use sample file below:
# Sample udhcpd configuration file (/etc/udhcpd.conf) # 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 # The interface that udhcpd will use interface eth0 #default: eth0 # Settings opt dns 192.168.2.1 option subnet 255.255.255.0 opt router 192.168.0.1 option domain local option lease 864000
This assumes that the resolve.conf file contained 192.168.2.1.
Now edit one more file: /etc/default/udhcpd
# Comment the following line to enable DHCPD_ENABLED="no" # Options to pass to busybox' udhcpd. # # -S Log to syslog # -f run in foreground DHCPD_OPTS="-S"
Now you're ready to enable DHCP server, simply by commenting out DHCPD_ENABLED="no"
Change it to #DHCPD_ENABLED="no" and you'll be ready to go.
Configure the hostapd server by editing the file /etc/hostapd/hostapd.conf and adding the following contents:
interface=wlan0 ssid=CIA_Surveillance_Van wpa_passphrase=ITSASECRET driver=nl80211 hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP
Now enable the hostapd service by creating a default file in
/etc/default/hostapd</code> <pre> # Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration # file and hostapd will be started during system boot. An example configuration # file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz # #DAEMON_CONF="" # Additional daemon options to be appended to hostapd command:- # -d show more debug messages (-dd for even more) # -K include key data in debug messages # -t include timestamps in some debug messages # # Note that -B (daemon mode) and -P (pidfile) options are automatically # configured by the init.d script and must not be added to DAEMON_OPTS. # #DAEMON_OPTS="" ~ "/etc/default/hostapd" 20 lines, 770 characters Replace the line beginning with #DAEMON_CONF with the line DAEMON_CONF="/etc/hostapd/hostapd.conf". DAEMON_CONF="/etc/hostapd/hostapd.conf" Save the file and exit the editor (:wq). Configure IP forwarding. Use the vi editor to enable IP forwarding by editing the kernel parameters file, /etc/sysctl.conf. pi@raspberrypi ~ $ sudo vi /etc/sysctl.conf The vi editor displays the contents of the configuration file. # # /etc/sysctl.conf - Configuration file for setting system variables # See /etc/sysctl.d/ for additonal system variables # See sysctl.conf (5) for information. #