Introduction: Raspberry Pi Wifi Router Prank


Do your neighbors leech off your wifi?

Got a raspberry pi?

We're going to build a wifi router that redirects users to a website of our choice regardless of what URL they request. In our case, we're going to redirrect users to People of Walmart . This instructable is loosely based on Adafruit's Raspberry Pi wifi router howto and this tutorial on using iptables to prank wifi users.

Step 1: Materials:

For this instructable you will need:

1. Raspberry pi. I used a Pi 2 model B but any model should be fine.

2. USB WIFI adapter.

3. SD card with Raspbian. If you've never installed Raspbian before, this howto will show you how to get started.

4. A wired internet connection.

5. A monitor and keyboard for the pi. When doing networking stuff it's best to work from the Pi's console.

Step 2: Boot Up and Install Packages

After you boot up your pi and log in to the console, we're going to install a DHCP server package and an access point package.

sudo apt-get update
sudo apt-get install hostpad
sudo apt-get install isc-dhcp-server<br>

Step 3: Set Up the Wireless Interface

Next we'll give our wireless interface a static ip address. I used 10.0.50.* as my block of addresses but you can use any non publicly routed subnet you'd like.

Open up the interfaces file

sudo nano /etc/network/interfaces<br>

At the bottom of the file add this:

iface wlan0 inet static

Now save the file and exit. After you've exited reboot the pi by pressing alt-ctrl-delete

Step 4: Set Up Dhcp

Now we'll set up the DHCP server to assign IP addresses when users connect to the pi.

We're going to back up the existing dhcpd.conf file and create our own.

sudo mv /etc/dhcp/dhcp.conf /etc/dhcp/dhcp.conf.old
sudo nano /etc/dhcp/dhcpd.conf

Type the following into the file


subnet netmask {
	option broadcast-address;
	option routers;
	default-lease-time 600;
	max-lease-time 7200;
	option domain-name "local";
	option domain-name-servers,;

Next we'll tell the dhcp server to listen on our wireless interface by opening this file:

sudo nano /etc/default/isc-dhcp-server

Find this line:


and change it to


Save then close the file.

Step 5: Set Up Hostapd

Hostapd let's your Pi act as a wifi access point. We'll configure it by creating a new configuration file.

sudo nano /etc/hostapd/hostapd.conf

Enter this into the configuration file. Substitute "MyPrankWIFI" with whatever you want to name your access point


Open up the defaults file for hostapd

sudo nano /etc/default/hostapd

Find this line


and change it to


When you're done editing, save and exit.

Step 6: Set Up Routing and Redirects

First we'll configure ip forwarding in the following file

sudo nano /etc/sysctl.conf

Add this to the bottom of the file


Now reboot by pressing alt-ctrl-del to activate ip forwarding.

Next we'll set up routing

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

Now here's the fun part. I found out the IP address for is I'm going to create a forwarding rule that sends all wifi traffic to that address.

sudo iptables -A PREROUTING -s -p tcp -j DNAT --to-destination

Lets save the routing information

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Next lets open up the network interfaces file

sudo nano /etc/network/interfaces

and add this line to the bottom

up iptables-restore < /etc/iptables.ipv4.nat

Step 7: Upgrade Hostapd

Hostapd did not support my wireless usb dongle by default so I had to download and replace it with a new version from Adafruit's website.

Download the new version and unzip it



Now replace the old version with the new one and set it's permissions

sudo mv hostapd /usr/sbin

sudo chmod 755 /usr/sbin/hostapd

Last we'll set up hostapd to run on startup

sudo service hostapd start

sudo service isc-dhcp-server start

Step 8: Reboot and Test

Reboot the pi using alt-ctrl-del

Now test the access point from another computer. If everything works correctly, every site you go to will be redirected to