Raspberry Pi: Creating A Wifi Access Point
by Clayton Lambert
Today we’re going to be setting up a WiFi Access Point with out Raspberry Pi with a DNS server to point all domains back to our local HTTP server.
- 1. Raspberry Pi Model B+
- 2. Edimax Wi-Fi USB Adapter
- 3. (Optional) Poweradd Pilot E2 12000mAh USB External Battery Power Bank
- (OR) Get The Full Kit: CanaKit Raspberry Pi B+ Ultimate Starter Kit
Setting Up Hostapd
Ideally, you should start with a fresh Raspbian image to make sure these settings does not conflict with your current settings. However, this tutorial should work just fine with any Raspbian image. If you use a fresh install, make sure to run apt-get update.
sudo apt-get update
Creating an access point with hostapd is fairly straight forward. Begin by installing hostapd with the following command.
sudo apt-get install hostapd
Now that hostapd is installed, we need to create a new configuration file in /etc/hostapd/. We’ll just name it “hostapd.conf”.
sudo nano /etc/hostapd/hostapd.conf
Inside this new file we are going to define a few settings for out access point. You can set the SSID and channel to whatever you like, as long as the channel is between 1 and 14.
interface=wlan0 driver=nl80211 ssid=Tutorial Access Point channel=1
Since we just created a new configuration file, we need to tell hostapd where to locate this file. We need to edit the configuration file location in /etc/init.d/hostapd with the following command.
sudo nano /etc/init.d/hostapd
Find the line “DAMEON_CONF=”, and add the path to our new configuration file.
Setting Up DNSMasq
It’s now time to install DNSMasq. We will configure DNSMasq to point all domains back to 10.0.0.1 to connect to our local server. Start off by installing the dnsmasq package.
sudo apt-get install dnsmasq
Once again we need to edit a configuration file, open dnsmaq.conf in /etc/.
sudo nano /etc/dnqmasq.conf
Move all the way to the bottom of the file, using CTRL + V to skip pages.
At the bottom of the file we need to add the following lines.
address=/#/10.0.0.1 interface=wlan0 dhcp-range=10.0.0.10,10.0.0.250,12h no-resolv
Editing Network Interfaces
Next we need to edit our network interfaces file.
sudo nano /etc/network/interfaces
The pi has more than likely already generated a configuration for wlan0. Begin by deleting everything related to wlan0. Assuming you don’t have any other network dongles attached, your file should look similar to the image below.
We are now going to replace the lines we just deleted with the following lines.
iface wlan0 inet static address 10.0.0.1 netmask 255.255.255.0 broadcast 255.0.0.0
Installing A HTTP Server
Now that our access point is pointing all HTTP traffic back to itself, we need to install a HTTP server to server up files when they’re requested. For such a small application with little to no worry about scaling we’ll install an Apache server.
sudo apt-get install apache2
When Apache has finished installing you are basically finished, you can now either edit the file apache serves up (var/www/index.html) or reboot the device to test your honeypot!