Single Board Computer WiFi Hotspot - SkycoinProject/skywire GitHub Wiki

skywire logo

Use your Single Board Computer to create a WiFi-Hotspot

Introduction

This guide will teach you how to setup your Single Board Computer (SBC) in a way that it broadcasts a Wifi-signal. The guide was written to work with any SBC that runs Armbian or Raspbian.

Instructions for Raspbian may differ. Separate steps are being explained along the way but you are advised to be extra cautious when using this guide for Raspbian.

Main goal is to create a guide with detailed instructions to turn any SBC that runs Armbian or Raspbian into a wireless router with full security, that will allow you to use your home lan to route traffic to the internet.

This guide will work with onboard WiFi modules as well as with WiFi dongles.

Table of Contents


Requirements

You will need the following to complete this guide:

  • SBC (Single Board Computer) that supports Linux, Armbian or Raspbian.
    • Tested on Orange Pi Prime & Raspberry 3 B+ plus USB WiFi dongle.
  • micro SD card, at least 8 GB (class 10 recommended).
  • USB keyboard.
  • HDMI cable + monitor.
  • Power adapter for the SBC:
    • Adapter of 5.0 V @ 2.5A or more for the Orange Pi Prime.
    • USB cable and charger of 1A or more for the Raspberry Pi.
  • Ethernet cable + free LAN port on your home router which should have internet access.

This guide will assume that your home router runs a DHCP server (don't get confused, that's the normal state). This DHCP server will manage the WiFi users as well since we will bridge the LAN and WiFi networks (LAN & WiFi will function as a single network).

Setup

The following steps are necessary to active the WiFi hotspot.

Step 1: Get Armbian/Raspbian on your SBC

  • Download Armbian for your SBC from the official website. Select the non-desktop version as we do not require the desktop environment.
  • If you use a Raspberry go to the official website and download the Raspbian lite version (non-desktop version).

Download Etcher, it's an image flashing tool. Run Etcher as administrator, then select the image file (.img) while the Micro SD disk is connected, and click on ‘Flash’.

After the flashing process terminated successfully, eject the Micro SD and insert it into the SBC.

Step 2: Turn on your SBC

Make sure the micro SD card is inserted into the SBC. Then connect:

  • the LAN cable to your home router.
  • the monitor + the usb Keyboard.
  • last but not least, connect the power cable.

Step 2.1: [Armbian only:] Changing root Password

This is a Armbian only step. Raspbian user should continue with step 3.

After turning on your SBC, you will see the system boot and you will be presented with a login prompt, use the Armbian default credentials:

user: root
password: 1234

Once you're logged in for the first you will be requested to change the default root password, this is a sample output of the process:

[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.
         Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.

Debian GNU/Linux 9 orangepiprime ttyS0

orangepiprime login: root
Password: 
You are required to change your password immediately (root enforced)
Changing password for root.
(current) UNIX password: 
Enter new UNIX password: 
Retype new UNIX password: 
  ___                               ____  _   ____       _                
 / _ \ _ __ __ _ _ __   __ _  ___  |  _ \(_) |  _ \ _ __(_)_ __ ___   ___ 
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | |_) | '__| | '_ ` _ \ / _ \
| |_| | | | (_| | | | | (_| |  __/ |  __/| | |  __/| |  | | | | | | |  __/
 \___/|_|  \__,_|_| |_|\__, |\___| |_|   |_| |_|   |_|  |_|_| |_| |_|\___|
                       |___/                                              

Welcome to ARMBIAN 5.65 stable Debian GNU/Linux 9 (stretch) 4.14.78-sunxi64
System load:   0.29 0.16 0.06   Up time:       1 min
Memory usage:  3 % of 2002MB    IP:            192.168.100.23
CPU temp:      22°C
Usage of /:    8% of 15G

[ General system configuration (beta): armbian-config ]

New to Armbian? Check the documentation first: https://docs.armbian.com


Thank you for choosing Armbian! Support: www.armbian.com

Creating a new user account. Press <Ctrl-C> to abort

Please provide a username (eg. your forename): 

This is a prompt to create a new user, do it so if you like but please notice that you can abort it by hitting Ctrl+C and simply continue with using the root account.

This guide assumes you are using the root user.

You will to login again after changing the root user password whether you created another user account or not.

Note: Please observe that the network manager has already configured your eth0 interface, see the sample output above.

You are ready to go, continue with step 3.

Step 2.2: [Raspbian only:] Change pi password

This is a Raspbian only step. Armbian user should continue with step 3.

Log into the system, the default user credentials are:

user: pi
password: raspbian

Once you're logged in, to change the password of user pi, just type in the console:

sudo passwd pi
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Warning: From this point forward users of Raspbian must make a sudo bash to switch to root and run all following commands as root.

Step 3: Get necessary files

We will start tinkering with the network now, in the process we may lose connectivity so we will get all needed files prior to that. You can either:

  • create the files which are necessary by copy pasting them.
  • cloning a git repository.

3.1 Manual File Creation

Change to the root user directory via cd /root, now you need to create three files hostapd, hostapd.conf and interfaces.

hostapd

Create the hostapd file via nano hostapd and then paste the following content. Save via ctrl+x and yes.

# Defaults for hostapd initscript                                               
#                                                                               
# See /usr/share/doc/hostapd/README.Debian for information about alternative    
# methods of managing hostapd.                                                  
#                                                                               
# 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="/etc/hostapd/hostapd.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=""

hostapd.conf

Create the hostapd.conf file via nano hostapd.conf and then paste the following content. Save via ctrl+x and yes.

interface=wlan0
bridge=br0
ssid=OPP-hotspot
country_code=ES
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=123password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_group_rekey=86400
ieee80211n=1
wme_enabled=1

interfaces

Create the interfaces file via nano interfaces and then paste the following content. Save via ctrl+x and yes.

# loopback interface
auto lo
iface lo inet loopback

# wireless wlan0
allow-hotplug wlan0
iface wlan0 inet manual

# eth0 connected to the ISP router
allow-hotplug eth0
iface eth0 inet manual

# Setup bridge
allow-hotplug br0
iface br0 inet dhcp
bridge_ports wlan0 eth0

3.2 Download the Files

cd /root
git clone http://github.com/stdevPavelmc/armbian-hostpot-bridge.git

At the end you will have a folder named armbian-hostpot-bridge in your /root folder with all the data you will need.

[Raspbian only:] Install Dependencies

Raspbian users need to install some additional packages:

apt update
apt install hostapd bridge-utils -y

Step 4: [Armbian only:] Remove Network Manager

This is a Armbian only step. Raspbian user should continue with step 5.

By default all interfaces in Armbian are managed by the Network Manager. For the simple bridge we would like to setup we don't need it. Thus, we will disable the Network Manager and remove it from the system. Execute the following commands as root:

systemctl stop network-manager
systemctl disable network-manager
systemctl disable NetworkManager-wait-online
apt purge network-manager -y

These commands are disabling & removing the services and purging the Network Manager.

At this point your network connection may not work!

Step 5: Setting up the network bridge [eth0 + wlan0/wlan1]

Just copy the template file you have either created manually or downloaded:

  • Manually created

cd /root
cp -f interfaces /etc/network/interfaces
  • Downloaded

cd /root/armbian-hostpot-bridge
cp -f interfaces /etc/network/interfaces

If you use the default WiFi on the Orange Pi Prime (Or other with onboard WiFi) you are set and there is no need to edit the file, but if you like to use a USB dongle, you have to tweak some things.

Execute the following to get the name of your new USB WiFi dongle:

ifconfig -a

The output will be something like this:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 02:01:55:da:4c:95  txqueuelen 1000  (Ethernet)
        RX packets 1536  bytes 146188 (142.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 283  bytes 29946 (29.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 25  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::e8c:24ff:fe2c:50be  prefixlen 64  scopeid 0x20<link>
        ether 0c:8c:24:2c:50:be  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 442  bytes 57130 (55.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan1: flags=56163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 12af::a105:eff:feaa:5011e  prefixlen 64  scopeid 0x20<link>
        ether 80:e1:00:16:e1:92  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 642  bytes 157130 (155.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

There you can spot wlan0 and wlan1 devices (this is for a Orange Pi Prime + USB WiFi dongle). wlan0 is the onboard WiFi module and wlan1 is the USB dongle.

Now use nano to setup your WiFi device as wlan1. Execute:

nano /etc/network/interfaces

An editor will open with content of the interfacesfile. Sweep trough it and change any occurence of wlan0 to wlan1. Save it via ctrl+x and yes. (Hint: there are four (4) occurences that need to be changed, one of them is a comment).

If everything went fine you can now active the bridge and test the connection:

ifup br0

If all worked you just enabled the ethernet connectivity again. Try to ping a host in your home network or the a website on the internet to verify it.

ping google.com

Step 6: Configure your hostapd service (Wifi Hotspot)

Just copy the template file you have either created manually or downloaded:

  • Manually created

cd /root
cp -f hostapd /etc/default/
cp -f hostapd.conf /etc/hostapd/
  • Downloaded

cd /root/armbian-hostpot-bridge
cp -f hostapd /etc/default/
cp -f hostapd.conf /etc/hostapd/

Now we need to edit the WiFi hotspot details. Execute:

nano /etc/hostapd/hostapd.conf

This command opens an editor. You need to change just three (3) lines:

  • Wireless device interface=wlan0
  • Wireless SSID ssid=OPP-hotspot
  • Wireless password wpa_passphrase=123password

The interface option refers to the device you identified, if it's a SBC with onboard WiFi like the Orange Pi Prime you don't have to change anything. If your SBC has no onboard Wifi or you are using a USB dongle you need to use the same wlan interface as in step 5.

The SSID is the name of the wireless network, in this case "OOP-hotspot" and "123passwd" is the password.

Do not forget to change the SSID and the password of your WiFi hotspot!
Warning: You can't use any spaces in this file, i.e. no spaces for or after the equal sign.

Step 7

That's it, you're done. Good job! Please power cycle the SBC and enjoy your new WiFi hotspot!


Bonus

If you care about the RF spectrum usage and good links, you can move the WiFi channel by editing the [channel=6].

Some curious ones may spot also the option of the WiFi network type hw_mode=g. If your device supports other modes you can play with that, for example the 5GHz WiFi (802.11a). You can switch the hw_mode to hw_mode=a to enable 5GHz, or force mode 802.11b for old devices via hw_mode=b.

Some types of network may need tweaks on other options to make it work, take a peek on hostapd tutorials online for some guidelines.

⚠️ **GitHub.com Fallback** ⚠️