Raspberry Pi As Completely Wireless Router

Published

Introduction: Raspberry Pi As Completely Wireless Router

This instructable is to create a wireless router from a raspberry pi and a wireless adapter, None of this work is original just pieced together after several fails I hope this helps. My sources are:

https://howtoraspberrypi.com/create-a-wi-fi-hotspo...

https://github.com/billz/raspap-webgui

https://github.com/billz/raspap-webgui/issues/141 contributor Caxton1

For this project I used a raspberry pi zero w but any raspberry pi may be used and a edimax wifi adapter.

https://www.amazon.com/gp/product/B003MTTJOY/

If the raspberry pi does not have an onboard wifi two adapters should be able to accommodate they must have access point capabilities. I am using a fresh version of jessie with pixel. I am unsure about other versions.

I will be using the adapter as my connection to the external wifi and the onboard wifi as my access point or point other devices can connect to. internet-->wlan1-->wlan0-->device

Step 1: Prepairing the Additional Wifi Adapter

With the raspberry pi on and connected insert the wifi adapter into the raspberry usb

Verify in the pixel desktop that both wireless connections are present and one is connected to a external wifi router

Update the pi with:

sudo apt-get update && sudo apt-get upgrade -y

Then move the wifi credentials to another location with

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.sav

sudo cp /dev/null /etc/wpa_supplicant/wpa_supplicant.conf

Step 2: Install the Workhorse and Web Gui

Now install the web gui that will do most of the work

sudo wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap

Wait for the next prompt

Type "y" to continue

Type "y" to install

Type "y" to reboot

Your raspberry will not have internet access for the next step

Step 3: Re-enable Internet Access and Correct Configuration File

To re-enable internet access we need put the wifi credentials file back in place with

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf.sav /etc/wpa_supplicant/wpa_supplicant.conf

Then reboot again

sudo reboot

Once rebooted in the pixel desktop verify that one connection is associated with your wifi ssid and the other is with an ssid "raspi-webgui"

Open a terminal, edit the /etc/network/interfaces with sudo nano /etc/network/interfaces file in my case I will delete "wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf" from the wlan0 section and in the wlan1 section change the line "iface wlan1 inet manual" to "iface wlan1 inet dhcp"

My file looks like this

# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d

auto lo iface lo inet loopback

iface eth0 inet manual

#wlan0 as access point

allow-hotplug wlan0

iface wlan0 inet manual

#wlan1 connects with external wifi

allow-hotplug wlan1

iface wlan1 inet dhcp

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Once closed restart the raspberry

sudo reboot

Step 4: Getting a the Wifis to Talk to Each Other

After the reboot the internet will be accessible now the wlan1 and wlan0 have to be told to talk to each other, In the terminal:

sudo apt-get install iptables-persistent -y
select yes to save current IPV4 rules

select yes to save current IPV6 rules

sudo nano /etc/hostapd/hostapd.conf

Comment out the driver #driver=nl80211

sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF="" and change it to DAEMON_CONF="/etc/hostapd/hostapd.conf"

sudo nano /etc/init.d/hostapd

Find the line DAEMON_CONF= and change it to DAEMON_CONF=/etc/hostapd/hostapd.conf

sudo nano /etc/sysctl.conf

uncomment the line #net.ipv4.ip_forward=1 so that it becomes net.ipv4.ip_forward=1

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE

sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT

sudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT

sudo sh -c "iptables-save > /etc/iptables/rules.v4"

sudo reboot

Step 5: Connect to and Configure Your Wi-Fi Hotspot

When your raspberry pi restarts, and you should see a “raspi-webgui” network in the list of accessible networks.

Once the network is visible, all you have to do is connect to it, the default password is ChangeMe.

You can change this password, network name, and many other things by connecting to the admin interface of your raspberry hotspot via your web browser, by default the address should be 10.3.141.1.

login:admin

password:secret

I hope this helps

Share

    Recommendations

    • Make it Move Contest

      Make it Move Contest
    • Clocks Contest

      Clocks Contest
    • Planter Challenge

      Planter Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    Hi, trying for a couple of days now to get this working but there seem to be major differences in Raspbian-Stretch that are not reflected in any howto I found so far.

    When I just copy the wpa_supplicant back it causes wlan0 to connect to the internet, wich seems to me actually quite logic

    iwconfig says:

    wlan0 IEEE 802.11 ESSID:"TeliaGatewayxx-xx-xx-xx-xx-xx"
    Mode:Managed Frequency:2.412 GHz Access Point: xx:xx:xx:xx:xx:xx
    [...]

    the "rasp-gui" hotspot is from now on not available anymore while wlan1 (actually wlx00c0ca82xxxx on my pi with predictable interfeces turned on) remains unassociated.

    Has anyone been able to archive this setup with stretch?

    6 Comments

    Ok, solved:

    first:
    sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE

    Second:
    sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT

    Now the problem is:
    STEP 1: OK
    STEP 2: Country no selected wlan1
    STEP 3: internet wlan1, no internet wlan0 (no ip, can´t access to: 10.3.141.1.)
    STEP 4: no wireless interface found (icon show red cross) internet wlan1, no internet, no ip, show "raspi-webgui" but can´t access to 10.3.141.1 in wlan0)

    Raspberry Pi 3 b+
    Raspbian Noobs
    Dongle wifi: Edimax EW-7811UN

    Regards

    0.jpg
    3 replies

    Lets start with number 2 is the country code set in the /etc/wpa_supplicant/wpa_supplicant.conf file example my file contains a line country=GB

    OK, solved step2, but on the step3, in my /etc/network/interfaces only show this:

    # interfaces(5) file used by ifup(8) and ifdown(8)

    # Please note that this file is written to be used with dhcpcd
    # For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

    # Include files from /etc/network/interfaces.d:
    source-directory /etc/network/interfaces.d

    nothing more....

    Regards!!

    Unplug the ext wifi, reboot, than plug it in again. If you dont use predictable interfeace names wlan0 and wlan1 seem to quite randomly swap at boot when both are connected on startup.

    Hi,

    when copy:

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

    show:

    Bad argument `sudo'
    Try `iptables -h' or 'iptables --help' for more information.

    1 reply

    Ok sorry for the editing the site clumped these together into one line this should be two lines

    sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE

    sudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT