Thursday, 16 November 2017 21:25

Raspberry Pi - Hotspot/Access Point dhcpcd method

Written by 
Raspberry Pi Static WiFi Access Point Hotspot Raspberry Pi Static WiFi Access Point Hotspot raspberryconnect.com
  • Author Type: Individual

There are many guides for creating a Raspberry Pi Access Point but from Raspbian 9 Stretch the network setup has changed, which means a lot of guides are out of date. So this guide is about setting up a Raspberry Pi Hotspot for Raspbian 9 Stretch onwards, it also works for Raspbian 8 Jessie.

I have two other guides on how to set up an automatic Raspberry Pi Access Point, which connects to your home network when you are at home and generates a hotspot when you are out.

For the Autohotspot guide to setup an internet routed hotspot suitable for RPi3, RPi2 & Rpi: Click Here
For the Autohotspot guide to setup a non internet routed hotspot suitable for RPi ZeroW and RPi Zero: Click Here

Aim:

  • This guide will go through how to set up a permanent hotspot for both internet routed, for RPi's with network ports, and non internet routed hotspots for Pi Zero/W 

 Requirements:

This has been tested on Raspbian Jessie and Raspbian Stretch. To see which version you have enter the command lsb_release -a

  • Raspberry Pi 3
  • Raspberry Pi 1,2 with a Wifi Dongle*,
  • Raspberry Pi Zero W and Zero with WiFi Dongle* (internet hotspot not useable as it has no ethernet port.

 

*some WiFi dongles don't work in adhoc mode or don't work with with the nl80211 driver used in this guide for RPi 3 & zero W inbuilt wifi, so you may want to check this first before starting.

To see if your usb WiFi dongle can be used as an access point enter the command; iw dev ,scroll to section "Supported interface modes:" and look for * AP

 

Note:

Dnsmasq bug: in versions below 2.77 there is a recent bug that may cause the hotspot not to start for some users. This can be resolved by removing the dns-root-data. It may be benificial to do this before you start the rest of the installation as it has been reported that doing it after installation for effected users does not work but you won't know if it is an issue until after the installation is complete.

check your version with : dpkg -s dnsmasq

versions 2.77 and above are ok. If not then try the command:

sudo apt-get purge dns-root-data

thanks to danny for highlighting this.

 

Note about Raspbian Stretch Network Device Names

For Raspbian Stretch there has been changes to how the network drivers are named, called Predictable Network Interface Names,  and may be different for the usual wlan0 and wlan1 for wifi and eth0 for ethernet connections. Though the official Foundation version of Raspbian Stretch seems to be keeping to the old standard names, at least at the time of writing,  this may not always be the case. For this guide I will use wlan0 as the device that is used.  

To check the device name for your setup enter the commmand iw dev and take a note of the "Interface" name. For wifi it should start with wl , replace your device name with any reference to wlan0 in the article, scripts and config files.

 

Step 1:

To start with hostapd hotspot client and dnsmasq lightweight dns server need to be installed.

Open a Terminal session.

Update Raspbian with the latest updates by entering the commands:

sudo apt-get update
sudo apt-get upgrade

 To install hostapd enter the command:

sudo apt-get install hostapd

enter Y when prompted.

To install dnsmasq enter the command:

sudo apt-get install dnsmasq

enter Y when prompted

The installers will have set up the programme so they run when the pi is started and activated them. While we set the hotspot we should stop them running. This is done with the following commands:

sudo systemctl stop hostapd
sudo systemctl stop dnsmasq

Now the hostspot configuration file can be setup. This contains the name of the WiFi signal you will need to connect to (SSID) and the security password.

To edit the configuration files I will be using the nano text editor but if you prefer an editor with an point and click interface then replace nano with leafpad in the following instructions.

Hostapd Configuration

Using a text editor edit the hostapd configuration file. This file won't exist at this stage so will be blank.

sudo nano /etc/hostapd/hostapd.conf

download file here:

interface=wlan0
driver=nl80211
ssid=RPiHotSpot
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

  • The interface will be wlan0
  • The driver nl80211 works with the Raspberry Pi 3 & Zero W onboard WiFi but you will need to check that your wifi dongle is compatable and can use Access Point mode.

For more information on wifi dongles see elinux.org/RPi_USB_Wi-Fi_Adapters

  • The SSID is the name of the WiFi signal broadcast from the RPi, which you will connect to with your Tablet or phones WiFi settings.
  • Channel can be set between 1 and 13. If you are having trouble connection because of to many wifi signals in your area are using channel 6 then try another channel.
  • Wpa_passphrase is the password you will need to enter when you first connect a device to your Raspberry Pi's hotspot. This should be at least 8 characters and a bit more difficult to guess than my example.

To save the config file press ctrl & o and to exit nano press Ctrl & x

Now the defaults file needs to be updated to point to where the config file is stored.
In terminal enter the command

sudo nano /etc/default/hostapd

Change:
#DAEMON_CONF=""
to
DAEMON_CONF="/etc/hostapd/hostapd.conf"

Check the DAEMON_OPTS="" is preceded by a #, so is #DAEMON_OPTS=""

And save.

DNSmasq configuration

Next we need to update the DNSmasq.conf file. There are two setups depending if you need internet access or not.

DNSmasq Config 1 - No Internet

Open the dnsmasq.conf file with

sudo nano /etc/dnsmasq.conf

Go to the bottom of the file and add the following lines (download here)

 


#RPiHotspot config - No Intenet
interface=wlan0
domain-needed
bogus-priv
dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h

and the save (ctl & o) and exit (ctrl & x)

DNSmasq Config 2 - Internet Routed

Open the dnsmasq.conf file with

sudo nano /etc/dnsmasq.conf

Go to the bottom of the file and add the following lines (download here)


#RPiHotspot config - Internet
interface=wlan0
bind-dynamic 
domain-needed
bogus-priv
dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h

and the save (ctl & o) and exit (ctrl & x)

 

Step 2:

Now that hostapd and dnsmasq are configured we now need to make some changes to the interfaces file, the dhcpcd.conf file, setup ip_forwarding.

Interfaces File

The interfaces file is not required and should be empty of any network config. Depending which version of Raspbian you have this file may still contain network config.

Enter

sudo nano /etc/network/interfaces

If your file shows more than the standard top 5 lines 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

then make a copy of your file and then remove any excess lines from the interfaces file.

To make a backup of your interfaces file first, use the command

sudo cp /etc/network/interfaces /etc/network/interfaces-backup

DHCPCD.conf

Next we need to update the dhcpcd.conf file. Open the file with

sudo nano /etc/dhcpcd.conf

then scroll to the bottom of the file and add the line (Download here)

nohook wpa_supplicant
interface wlan0
static ip_address=192.168.50.10/24
static routers=192.168.50.1

If you are setting up the Internet routed hotspot then also include

static domain_name_servers=8.8.8.8

now save (ctrl & o) and exit (ctrl & x)

The line 'nohooks wpa_supplicant' will stop the network wifi from starting if you have an entry in /etc/wpa_supplicant/wpa_supplicant.conf . If this is not done then network wifi will override the hotspot.

This next bit is only if you would like devices to have internet access. If not skip to "Testing the Hotspot".

 ip forwarding

For the internet to be available when an Ethernet cable is attached, IP forwarding needs to be activated. To do this enter

sudo nano /etc/sysctl.conf

look for the line

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

and remove the # so it is

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

now save (ctrl & o) and exit (ctrl & x)

Next the rules need to be added that will allow any device connected to the access point to be able to use the internet. This is done with IP Table rules which will need to be loaded every time the Raspberry Pi starts up. So a service file can be setup to do this.

There is a program called netfilter-persistent that can do this but I didn't have much luck with it and it is simple to setup a custom service instead.

First create the file for the ip table rules.

sudo nano /etc/iptables-hs

add the lines below or download from here

#!/bin/bash
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

now save (ctrl & o) and exit (ctrl & x)

Update the permissions so it can be run with

sudo chmod +x /etc/iptables-hs

Now the service file can be created which will activate the ip tables each time the Raspberry Pi starts up

Create the following file

sudo nano /etc/systemd/system/hs-iptables.service

Then add the lines below of download from here


[Unit]
Description=Activate IPtables for Hotspot
After=network-pre.target
Before=network-online.target

[Service]
Type=simple
ExecStart=/etc/iptables-hs

[Install]
WantedBy=multi-user.target

now save (ctrl & o) and exit (ctrl & x)

To activate the service file, so it starts at every boot up, enter the command

sudo systemctl enable hs-iptables

 

Testing the Hotspot

The hotspot setup is now complete. To test that the setup is ok reboot the RPi.

 Once the RPi is up and running the wifi icon near the clock should now be two arrows facing opposite directions Raspbian Pixel AP mode icon This means it is an access point. On a Tablet, phone or Laptop scan for wifi signals. You should see one for RPiHotSpot.

Select this as the wifi signal to connect to. The password is what you setup in the hostapd.conf file. From my example it is 1234567890

android wifi in range list

Local wifi signals in range on Android. You will see RPiHotSpot and not RPiHotN

For SSH and VNC the connection ip is 192.168.50.10 also if you have setup the RPi as a webserver use the same ip to see the webpage.

For ssh use ssh This email address is being protected from spambots. You need JavaScript enabled to view it.

For vnc use 192.168.50.10::5900

If you have setup the Internet routed configuration. Connect an ethernet cable to the Raspbery Pi and your router and wait a few seconds. The hotspot will now allow connected wifi devices to use the internet as well as the Raspberry Pi

 Once you are happy the setup is working ok then your done.

 

Script Removal

If you don't wish to continue using the Hotspot then the Raspberry Pi can be revered back to a standard wifi setup with the following steps.

Stop the Hostapd and dnsmasq services with the commands

sudo systemctl disable dnsmasq

sudo systemctl disable hostapd

In the /etc/dhcpcd.conf file remove the lines added at the bottom of the file.

#Static Hotspot
nohook wpa_supplicant
interface wlan0
static ip_address=192.168.50.10/24
static routers=192.168.50.1
static domain_name_servers=8.8.8.8

If you had previous config in your interfaces file and made a backup you can restore your original interfaces file with the command

sudo mv /etc/network/interfaces-backup /etc/network/interfaces

If you didn't setup an internet routed hotspot then your done, after a reboot your RPi will not longer be an Access Point. For Internet routed Hotspots you also need to do the following;

Disable the hs-iptables service with the command

sudo systemctl disable hs-iptables

Then disable ip forwarding

sudo nano /etc/sysctl.conf

look for the entry

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

and add a # as follows

# Uncomment the next line to enable packet forwarding for IPv4
# net.ipv4.ip_forward=1

Then reboot and the Raspberry Pi will be back to the standard wifi setup.

 

 Trouble Shooting

  • If you get no wifi connection or no hotspot and have this icon Network Downthen it is most likley there is an error in one of the configuration files.
  • If you don't get an internet connection when an ethernet cable has been attached, with the Internet routed setup, then you can check the ip table rules have been activated with the command sudo iptables -S If you don't see any rules but just get
    -P INPUT ACCEPT
    -P FORWARD ACCEPT
    -P OUTPUT ACCEPT
    

    then make sure the service was enabled with the command sudo systemctl enable hs-iptables and the iptables file has the correct prmissions with sud chmod +x /etc/iptables-hs
  • You can connect to the hotspot via an Android Phone but you can't get a ssh connection. Some users have found this issue where Android uses there data connection rather than the wifi. Disabeling data has allowed them to use ssh.  
Last modified on Sunday, 19 November 2017 11:31
Google
roboberry

RapberryConnect.com SuperUser.  Contactable via the site admin e-mail in the Contact Us link.

Website: www.raspberryconnect.com

Leave a comment

Comments for Guest and account owners. Account owners will need to login to use registered e-mail address.

50 comments

  • Comment Link roboberry Saturday, 07 July 2018 21:32 posted by roboberry

    Hi Alvaro G, Your settings look fine to my config. Though your issue is with dnsmasq:
    jul 04 17:40:32 Opal dnsmasq[496]: advertencia: interfase wlan0 no existe actual

    wlan0 is not available to dnsmasq for some reason, i'm not getting this issue.

    I'm using a PI3 with a usb wifi dongle. With this setup wlan0 goes to the usb dongle and wlan1 goes to the internal wifi.

    If you look at ip addr
    wlan0 has ip 192.168.50.10 (hotspot)
    wlan1 has ip 192.168.0.# which is internet through the router

    but if the usb wifi dongle is removed and you scan for the hotspot it is not available.
    so wlan0 is the usb wifi dongle.

    If your usb wifi is not able to be used as an access point then that may be why it's not working.

    You can try the other suggestion I made to keith which will make the internal wifi a hotspot instead.

    Change your /etc/dhcpcd.conf file to
    nohook wpa_supplicant
    interface wlan0
    static ip_address=192.168.50.10/24
    static routers=192.168.50.1
    static domain_name_servers=8.8.8.8

    then you need to start wpa_supplicant on wlan1 yourself, you can do this manually with
    sudo wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf

    You will need to run it at start up which can be done by adding it to the bottom of the /etc/iptables-hs script
    wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1


    I Hope this helps, let me know if not

    Report
  • Comment Link Alvaro G Wednesday, 04 July 2018 16:58 posted by Alvaro G

    Hi Roboberry,

    My wlan0 says "Not associated".
    wlan0 is the onboard Pi's wifi. I want wlan0 to be the hostpot and wlan1 (USB dongle) be the internet connection.

    My /etc/dhcpcd.conf file looks like:
    interface wlan0
    denyinterface wlan0
    nohook wpa_supplicant
    static ip_address=192.168.50.10/24
    static routers=192.168.50.1
    static domain_name_servers=8.8.8.8

    My /etc/iptables-hs file looks like:
    #!/bin/bash
    iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
    iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j A$
    iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT

    I have tried:
    sudo systemctl status hostapd, all ok
    etc/dnsmasq.conf and /etc/dhcpcd.conf all start with 192.168.50
    wpa_cli -i wlan0 status, is not running
    sudo systemctl status dnsmasq, it displays an error here, I copy the promt window:
    dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
    Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset:
    Active: active (running) since Wed 2018-07-04 17:40:33 CEST; 14min ago
    Process: 497 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=
    Process: 484 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0
    Process: 458 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCC
    Main PID: 496 (dnsmasq)
    CGroup: /system.slice/dnsmasq.service
    └─496 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /ru

    jul 04 17:40:32 Opal dnsmasq[496]: advertencia: interfase wlan0 no existe actual
    jul 04 17:40:32 Opal dnsmasq-dhcp[496]: DHCP, IP range 192.168.50.150 -- 192.168
    jul 04 17:40:32 Opal dnsmasq[496]: direcciónes /etc/hosts - 5 leídas
    jul 04 17:40:33 Opal dnsmasq[496]: no servers found in /run/dnsmasq/resolv.conf,
    jul 04 17:40:33 Opal dnsmasq[497]: Too few arguments.
    jul 04 17:40:33 Opal dnsmasq[497]: Too few arguments.
    jul 04 17:40:33 Opal systemd[1]: Started dnsmasq - A lightweight DHCP and cachin
    jul 04 17:40:37 Opal dnsmasq[496]: leyendo /run/dnsmasq/resolv.conf
    jul 04 17:40:37 Opal dnsmasq[496]: usando nombre de servidor 80.58.61.250#53
    jul 04 17:40:37 Opal dnsmasq[496]: usando nombre de servidor 80.58.61.254#53
    lines 1-20/20 (END)...skipping...

    What should I do?

    Thanks in advance man!

    Report
  • Comment Link Keith Saturday, 23 June 2018 18:03 posted by Keith

    Hi Roboberry,

    After some further 'tinkling' I have managed to get it to work, but not with just iptables statements below. Here are the changes (just for reference to others and if you think I have done something wrong/unstable).

    1. dhcpcd.conf - I needed to comment out the router, domain_name_server and denyinterfaces statements as below. Otherwise I found that the DNS did not work correctly. When logging into the Pi (using xrdp) and using the browser, even though I was connected to the wifi it did not correctly resolve the addresses. I found this when I disabled the wlan0 interface using sudo ifconfig wlan0 down. Once I had done this (even though it was not the solution) I could access the internet using wlan1 so it seems the packets were being routed to the AP?

    #denyinterface wlan0

    interface wlan0
    nohook wpa_supplicant
    static ip_address=172.24.1.1/24
    #static routers=172.24.1.1
    #static domain_name_servers=8.8.8.8

    2. iptables-hs was updated as below. Nearly what you had but the extra line I needed to do when I configured the same in Jessie. Not sure what it actually does but it seems to make a difference.

    iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
    iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
    iptables -t nat -A POSTROUTING -s 172.24.1.1/24 ! -d 172.24.1.1/24 -j MASQUERADE

    Note: wlan0 (the AP) is configured with the IP Address 172.24.1.1. (not 172.24.1.50 as per your example).

    Anyway, traffic does appear to be routing through now. So hopefully all is good. Happy that the eth0 port cannot route through.

    Many thanks for your time and help.

    Regards

    Keith.

    Report
  • Comment Link Roboberry Saturday, 23 June 2018 10:09 posted by Roboberry

    Hi Keith

    Sorry I presumed you wanted wlan0 and wlan1 going through eth0 which I think you need more setup for.
    For me it seems the devices get swapped about with the changes to dhcpcd.conf. wlan0 is now my usb wifi dongle (hotspot) and wlan1 is the internal wifi (internet).
    So you just need to swap the entries in the ip table
    sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
    sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
    sudo iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT

    So all traffic from the hotspot will go through the wifi repeater. Internet from Eth0 will not be available to any device connected to the hotspot.

    If you need your internal wifi as the hotspot then swap the iptables back and use the second suggestion of wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf

    let me know if you have issues.

    Report
  • Comment Link Keith Thursday, 21 June 2018 21:38 posted by Keith

    Hi Roboberry,

    Many thanks for the response. I have now moved the nohook wpa_supplicant into the interface specification.

    Yes it does re-enable the wifi for wlan1 (and yes this is connected to the router).

    You are correct that connections connected to wlan0 loose internet when the ethernet is removed. However, I do want traffic routed from the AP to the Wireless connection (creating a wifi repeater) so when connected to the AP I can still access the internet but also use ssh etc on the AP.

    I have tried using different iptables commands to re-route from wlan0 to wlan1 but to no avail.

    The commands tried are

    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

    Do you have any suggestions?

    Many thanks for the help.

    Keith

    Report
  • Comment Link roboberry Tuesday, 19 June 2018 21:09 posted by roboberry

    Hi Keith, Your welcome,

    The nohook line does stop dhcpcd from starting wpa_supplicant for all interfaces but if you add deny interface to dhcpcd then wpa_supplicant is started but not for wlan0

    open /etc/dhcpcd.conf

    change the options to the below, note nohook should be after the interface line

    interface wlan0
    denyinterface wlan0
    nohook wpa_supplicant
    static ip_address=192.168.50.10/24
    static routers=192.168.50.1
    static domain_name_servers=8.8.8.8


    All connected devices to the wlan0 hotspot will have internet via eth0.
    The Pi itself will have internet via eth0 or wlan1 (presuming wlan1 is going to a router)
    If eth0 is removed all connected devices to the wlan0 hotspot will loose the internet.
    but if you are using ssh, vnc or a display on the PI it will itself still have internet via wlan1.

    Alternately you can start wpa_supplicant on wlan1 yourself with
    sudo wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf

    this will need to be run at start up but you could add it to the bottom of the /etc/iptables-hs script
    wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf >/dev/null 2>&1

    hope this helps

    Report
  • Comment Link Keith Monday, 18 June 2018 21:42 posted by Keith

    Hi Roboberry,

    Great article. Having tried so many others, good to see one which works on Stretch.

    Good news, managed to get it all working with the Ethernet port and connecting through to the internet on my RP3 using the internal Wifi as a hotspot.

    However, I also have an additional WIFI dongle (Edimax) and would like to be able to configure this to another WIFI hotspot and hence use as a WIFI repeater with routing.

    But now using the GUI it states no interfaces found so I cannot configure using the GUI.
    I also note you have use nohook wpa_supplicant which I assumes disables this file for both WIFI adapters.

    Any idea how I can get the other WIFI adaptor configured?

    Apologies if this has been asked before.

    Regards

    Keith

    Report
  • Comment Link roboberry Monday, 11 June 2018 20:21 posted by roboberry

    Hi Sukantra, the issue will most probably be with permissions or a spelling error.
    The iptables-hs service is probably not running at boot time. You can check to see if there is an error by entering
    sudo systemctl status hs-iptables

    if there is an error it may highlight it. Otherwise redo the permissions and setup of the ip tables.


    Your iptables commands should be in the file at /etc/iptables-hs make sure the first line contains #!/bin/bash

    then redo the permissions with
    sudo chmod +x /etc/iptables-hs

    next double check the service file is in the correct location and has the right file name
    sudo nano /etc/systemd/system/hs-iptables.service

    this should contain the command to run the script with ExecStart=/etc/iptables-hs

    finally enable the service so it starts at boot with
    sudo systemctl enable hs-iptables

    Now it should automatically start at the next boot.

    Let me know if you have further issues and I will look into it further.

    Report
  • Comment Link Sukanta Saturday, 09 June 2018 14:27 posted by Sukanta

    I got my error. With the command sudo iptables -S, I got the output as
    -P INPUT ACCEPT
    -P FORWARD ACCEPT
    -P OUTPUT ACCEPT
    but when I run the rule
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

    problem solved. Now how do I make it autorun? while restart I need to run the rule every time, it's not autostarting after reboot.

    Report
  • Comment Link roboberry Friday, 08 June 2018 20:28 posted by roboberry

    Hi Pete, For most home users the net available option would be used but the Raspberry pi is used in lots of different ways and due to it's portability the pi may be running sensors, a remote camera, be part of an array of PI's connected to a master server pi through the hotspot, in the field science projects. So connected devices don't always require internet access. The hotspot in these cases are used to access the Pi via ssh/vnc to mod software and settings. So the guide gives the user the option not to include network access to connected devices. It still can be connected to the Net via an Ethernet cable and software updated via that route. The related guides for autohotspot scripts come in an internet and non internet version and they are both equally used.

    Report
  • Comment Link pete Friday, 08 June 2018 18:50 posted by pete

    "This next bit is only if you would like devices to have internet access."

    I have no idea what this means!

    The whole point of a hotspot is to provide internet access.

    Report
  • Comment Link roboberry Wednesday, 09 May 2018 20:16 posted by roboberry

    Hi PramSatria, thats good your updates have made progress. In the /etc/hostapd/hostapd.conf file have you either removed the line driver=nl80211 or replaced nl80211 with your wifi driver? If not it is probably trying to use the wrong driver.

    If the ip tables are setup fine, are you able to use ssh or vnc just to check there is a valid connection?

    my email is admin@ this site,

    Report
  • Comment Link PramSatria Wednesday, 09 May 2018 03:49 posted by PramSatria

    Hi roboberry, new update :

    i finally can configure my problem by running installing driver script from here : https://www.raspberrypi.org/forums/viewtopic.php?t=62371

    and then installing hostapd using https://github.com/jenssegers/RTL8188-hostapd

    and then just continue from your guide. Finally it showed up, wifi ssid RpiHotspot

    BUT, when i connect it from my phone it can't be used for browsing or internet. any suggestion? I have done the troubleshooting guide from you and iptables are showing rules

    Report
  • Comment Link PramSatria Wednesday, 09 May 2018 03:03 posted by PramSatria

    Hi roboberry, thanks for answering my earlier question. so i just need to install hostapd from https://github.com/jenssegers/RTL8188-hostapd and then continue the installation procedure based from your guide yes?

    i'm sorry i'm still new in this kind of thing :( do you have email address/twitter where i could reach you out easily other than this website?

    thanks, PramSatria

    Report
  • Comment Link roboberry Tuesday, 08 May 2018 21:33 posted by roboberry

    Hi PramSatria, It looks like you have set up the hotspot ok but look at https://wikidevi.com/wiki/TP-LINK_TL-WN722N it seems your wifi adapter uses the Realtek RTL8188EUS chipset which is not compatible with hostapd and the nl80211 drivers the raspberry pi uses.

    There is an alternative version that is available on github that you can try, in theory it should be fine but it is not tested with this setup. Search for hostapd with RTL8188 , https://github.com/jenssegers/RTL8188-hostapd

    Just to check, in terminal enter; sudo systemctl status hostapd
    there should be green text that says running(active) if it says inactive or exited then hostapd has failed which is why you can't find the hotspot. The messages may give you a clue to the issue.

    do the same with dnsmasq; sudo systemctl status dnsmasq
    this should also say it it running(active)
    if both say active then let me know and I will look into it further.
    If you can also try borrowing a compatible wifi adapter to check that it is your adapter and not the setup issue.

    Report
  • Comment Link PramSatria Tuesday, 08 May 2018 01:55 posted by PramSatria

    Hi, i did everything exactly the same as the above. but it seems that i can't found the hotspot name RpiHotspot.
    here is my condition :
    -Raspi 1 b+ version 1.2
    -TL - WN722N v3 (tplink)
    -I have rebooted it once (after the configuration of the hotspot)
    -The logo near clock are two arrows facing opposite directions (and it's blue)
    -My main internet connection are from Laptop using ethernet cable, and it can still be used.
    -Before i reboot my rpi1, i can still see nearby wifi connection in raspi desktop. But after i reboot it, there aren't any wifi nearby shown.

    So i think i've set it up as a router but not as an access point (hotspot). how to troubleshoot this? I'm sorry if my english is bad, and please help.. thankyou.

    Report
  • Comment Link roboberry Sunday, 06 May 2018 12:50 posted by roboberry

    Hi Alvaro, I take it you can connect to the hotspot ok, have you tried SSH and seen if that works ok.
    There shouldn't be an issue with Real VNC as it will use the same ip of 192.168.50.10. On the PI using the Desktop; when you open the VNC window with the icon by the clock, does it suggest the same ip? below that is option to show other connection settings, this also should only say the Hotspot ip, if there is a different ip then the setup is not right.

    If your Wifi Icon is not the up and down arrows then it maybe that wpa_supplicant is still running along with the hotspot which will cause issues.
    Just check the /etc/network/interfaces file doesn't have any config and /etc/dhcpcd.conf contains the line: nohook wpa_supplicant

    If you still have issues, let me know what info you get and I will look into it futrther.

    Report
  • Comment Link roboberry Sunday, 06 May 2018 12:39 posted by roboberry

    Hi Mirac, Hi I haven't looked into adding a host name but as it is a static hotspot you could try adding the ip and the hostname to /etc/hosts

    Otherwise the /etc/dnsmasq.conf file should have a feature to allow the hostname.

    Report
  • Comment Link Alvaro Thursday, 03 May 2018 18:38 posted by Alvaro

    Thank you so much! I've been struggling a lot doing this by myself and with other tutorials and none of them worked. Finally this one works, however I'm trying to access my pi via vnc again and can't do it anymore.

    I'm using the no internet configuration. I could access before with a vnc viewer, but now I cant't.... How do I fix this?

    Report
  • Comment Link Mirac Tuesday, 01 May 2018 21:26 posted by Mirac

    Hi, this is the first tut that really worked for me -- many thanks! Now, how can I setup a name (with a domain or otherwise) to use in the browser's url box instead of the IP address? Many thanks!

    Report
  • Comment Link roboberry Tuesday, 01 May 2018 19:47 posted by roboberry

    Hi Brian, It is normal to get the Kernel driver error so your output of hostapd is fine.
    As you are getting the wifi symbol rather than the arrows, this means wpa_supplicant is still running, which will override the hotspot even if it is active.
    There is two places that can be started, check the /etc/dhcpcd.conf has the line; nohook wpa_supplicant

    The other place is /etc/network/interfaces
    This should only have the top 5 lines in it for stretch;
    # 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

    if it also has a line containing wpa_supplicant then the interfaces file needs backing up and anything other than the top 5 lines as above removed.

    The wifi setup for Jessie did seem a bit easier, Stretch was a bit fiddler to work out but it does work.

    to check if wpa_supplicant is running enter
    wpa_cli -i wlan0 status
    if it comes up with anything other than "Failed to connect....." then it is still running and the hotspot will not work.

    let me know if you have further issues and I will have a closer look.

    Report
  • Comment Link Brian Sunday, 29 April 2018 10:17 posted by Brian

    Hi, I have faithfully followed your tutorial on my Raspi3, but it doesn't work! My Windows laptop can see my AP, but on connecting, it says Buccaneer secured no internet. O the Pi's bar in the desktop, the symbol is the wifi wave and not the 2 arrows you mention. If I stop the hostapd service and then use hostapd -B /etc/hostapd/hostapd.conf, I get:
    pi@CaravanPi:~$ sudo hostapd -B /etc/hostapd/hostapd.conf
    Configuration file: /etc/hostapd/hostapd.conf
    Failed to create interface mon.wlan0: -95 (Operation not supported)
    wlan0: Could not connect to kernel driver
    Using interface wlan0 with hwaddr b8:27:eb:d7:dc:41 and ssid "Buccaneer"
    wlan0: interface state UNINITIALIZED->ENABLED
    wlan0: AP-ENABLED

    I am happy to ignore the mon.wlan0 error as Broadcom don't support monitor, but I don't like the "could not connect to kernel driver". This sounds nasty. Do you get the same?

    If it isn't the AP, then it must be the routing. Is there any way to check this?
    All worked fine under jessie but I am tearing my hair out with stretch!!
    Any help would be most appreciated.
    Brian

    Report
  • Comment Link roboberry Wednesday, 25 April 2018 19:28 posted by roboberry

    Hi Chris, I have not used the Tor network so i'm unable to help with that. Another user had the same issue and believes it is a ip conflict with what the Tor software expects.
    My only suggestion is to change the config in dnsmasq and dhcpcd.conf so the first 3 parts of the ip ###.###.##.10 match the ip your software is using, but I don't know if that will help.
    I don't know what TOR requires different to other services as streaming, vnc, ssh etc work fine. Sorry i can't help further.

    Report
  • Comment Link Chris Monday, 23 April 2018 22:55 posted by Chris

    Hi, how can I setup "Tor" on this access point so that all my connected device go through tor network.
    Please help. Thank you

    Report
  • Comment Link roboberry Saturday, 21 April 2018 10:28 posted by roboberry

    Hi Dave

    The guide you used to install with is old, its was for debian 6 you are probably using 9 (Stretch) though most of it is probably still valid. The entery for wpa.conf should be in /etc/wpa_supplicant/wpa_supplicant.conf and is most probably already there as you have had network working. Also the entry in /etc/network/interfaces is not used in stretch either. But as long as you cleared that out while following the guide then thats fine.

    I presume the USB Wifi is capable of using and access point, confirm with entering in a terminal window; iw dev and you should see a line with "Supported interface modes:" and look for * AP.

    I think the issue is the TP-Link_TL-WN722N uses the RTL8188EUS chipset which unfortunately is not compatible with hostapd which manages the hotspot. There is an alternative version that is available on github that you can try, in theory it should be fine but it is not tested. Search for hostapd with RTL8188 , https://github.com/jenssegers/RTL8188-hostapd

    Otherwise you will need to use the internal wifi for the access point.

    Report
  • Comment Link Dave Thursday, 19 April 2018 18:55 posted by Dave

    Hi and thanks for your guide. I'm a newbie in Raspberry world. I followed your steps and all is working fine with Pi's internal wifi board, but I disabled it (adding dtoverlay=pi3-disable-wifi at /boot/config.txt file) for use a wifi adapter TP-WN722N instead.

    I installed the adapter following this guide https://elinux.org/RPi_Peripherals#Wireless:_TP-Link_TL-WN722N_USB_wireless_adapter_.28Debian_6.29 and eventually I was able to use it for connect to my home-wifi; so I think installed correctly.

    Then, I followed your steps for use this TP-WN722N as AP but eventually I can't see my RPiHotspot when scanning wifi networks from my mobile or notebook.

    Where I'm wrong? Can you help please?

    Thank you!

    Report
  • Comment Link roboberry Tuesday, 10 April 2018 21:05 posted by roboberry

    Hi Sukanta, for your ip tables issue have you followed the trouble shooting guide at the bottom of the article?
    Check redo permissions: sudo chmod +x /etc/iptables-hs
    also check the ip rules service had no errors:
    sudo systemctl status hs-iptables

    also check the status of hostapd with
    sudo systemctl status hostapd
    is should say running.
    you can also run it manually and see if any clues in it's output. First stop it running if it is
    sudo systemctl stop hotsapd
    then run it manually and try to connect with
    sudo hostapd /etc/hostapd/hostapd.conf

    hopefully you can spot why it dosn't work, if not then you can email me the details.

    Report
  • Comment Link roboberry Tuesday, 10 April 2018 20:51 posted by roboberry

    Hi Arnaud TIGER; thanks for the info to get the pi working on wifi on first use. Wpa_supplicant needs to have the top 3 config lines for your country to work. I haven't shown that on this guide as it is not used in the hotspot but both the hotspot switch scripts show the correct wpa_supplicant setup.

    Report
  • Comment Link Sukanta Monday, 09 April 2018 17:47 posted by Sukanta

    Hi there, I have same problem as by Elias.
    Is there any solution of it?

    Report
  • Comment Link Sukanta Monday, 09 April 2018 13:42 posted by Sukanta

    Hi,
    I follow the all steps, I didn't get any WiFi-AP in my mobiles.
    WIFI icon is ok, but I didn't found any rules but just get just get
    -P INPUT ACCEPT
    -P FORWARD ACCEPT
    -P OUTPUT ACCEPT.
    Later I did as per ur guide, but still no Improve.
    PLs help

    Report
  • Comment Link Arnaud TIGER Saturday, 07 April 2018 17:23 posted by Arnaud TIGER

    Thanks a lot for you tuorial, the only works on last Raspberry 3 version, the B+

    And to help all people who have the same version as me, because I lost few days of this problem.
    By default wlan0 is "Soft blocked" on boot, you can see it with command
    rfkill list

    To allow wifi at boot you need, it's mandatory , to setup file /etc/wpa_supplicant/wpa_supplicant.conf with country code

    Example for me in France

    cat /etc/wpa_supplicant/wpa_supplicant.conf
    country=FR
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1

    Report
  • Comment Link roboberry Monday, 02 April 2018 19:48 posted by roboberry

    Hi racetouareg, I don't believe this is an issue with the hotspot setup, if it is reporting the incorrect user name then the hostpot and ssh is working and it doesn't like the user name pi or password, it is a permissions thing with ssh. There would be connection errors if your device was unable to connect to ssh or the hotspot. Looking on google most issues are around the ssh.config file not set right but that wouldn't have been touched so that's doesn't seem to be the issue. Someone suggest ip changes so you could just check the ip addresses in dhcpcd.conf and dnsmasq.conf are ok. If you can access the PI's desktop try changing the password , reboot and have another go. If you have recently changed your password, check your old password incase it didn't change. sorry I can't help further.

    Report
  • Comment Link racetouareg Saturday, 31 March 2018 17:15 posted by racetouareg

    Hi, everything looks working fine, but it's not possible to connect via SSH.
    From other devices it's always "invalid username/password".
    But it's definitiv the right one.

    Report
  • Comment Link Vandan Kumbhat Monday, 19 March 2018 18:50 posted by Vandan Kumbhat

    A advice to all- Whenever you guys search for online tutorials or any process do add a time range in your google search to prevent waste of time. I wasted days for this one.
    Thanks a lot man, your note on clearing dns-root-data saved me probably. I have repeated these kinds of tutorials roughly a dozen times failing in a different manner every time. Bingo !

    Report
  • Comment Link Vandan Kumbhat Monday, 19 March 2018 10:42 posted by Vandan Kumbhat

    Hey there, Thanks for the tutorial. I have a request, if you could please append a section at end of tutorial that tells how to revert in case this fails. Reason being, I have followed at least 5 tutorials and there is no way to revert, evverytime I end up reinstalling raspbian or whatever the os. In case you do this, please mail me at (removed)

    Report
  • Comment Link roboberry Monday, 12 March 2018 20:58 posted by roboberry

    Hi Elias, sorry the command should have been sudo systemctl -i status hostapd,

    From your last log it seems dnsmasq is not finding wlan0 so didn't start the wifi but found eth0. so we need to find what config is causing an issue so wlan0 is not available.

    If wlan0 is not starting up then there also could be an issue in /etc/dhcpcd.conf.
    Double check the line; interface wlan0 is correct and ends in a zero not the letter O

    Can you do the output of sudo systemctl -i status hostapd and sudo systemctl -i status dnsmasq again please and also sudo systemctl -i status dhcpcd Could you paste them into the "Leave a comment" box, the Report link you have used makes a mess of the text so it is not very readable, thanks :)

    Also manually start dnsmasq and hostapd and see what happens,
    enter: sudo systemctl restart dnsmasq then sudo systemctl restart hostapd
    and see if there is any issues with the commands sudo systemctl -i status hostapd and sudo systemctl -i status dnsmasq

    if you can't see the issue you are welcome to send me you config file to admin@ this site
    /etc/dhcpcd.conf
    /etc/dnsmasq.conf
    /etc/hostapd/hostapd.conf
    /etc/default/hostapd
    /etc/network/interfaces
    /etc/iptables-hs

    and I will check it out on my pi.

    Report
  • Comment Link Elias Monday, 12 March 2018 20:35 posted by Elias

    Hi Roboberry, Thank you for your help. The command sudo systemctl -i hostapd, it doesn't work for me pi@raspberrypi:~ $ sudo systemctl -i hostapd Unknown operation hostapd. Here is the output of sudo systemctl status hostapd (which is different from yesterday - but still doesn't work)

    pi@raspberrypi:~ $ sudo systemctl status hostapd ● hostapd.service - LSB: Advanced IEEE 802.11 management daemon Loaded: loaded (/etc/init.d/hostapd; generated; vendor preset: enabled) Active: active (exited) since Fri 2018-03-09 19:48:39 UTC; 2min 47s ago Docs: man:systemd-sysv-generator(8) Process: 451 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS) CGroup: /system.slice/hostapd.service
    Mar 09 19:48:39 raspberrypi systemd[1]: Starting LSB: Advanced IEEE 802.11 management daemon...
    Mar 09 19:48:39 raspberrypi hostapd[451]: Starting advanced IEEE 802.11 management: hostapd failed!

    Mar 09 19:48:39 raspberrypi systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon. Output of sudo systemctl status dnsmasq pi@raspberrypi:~ $

    sudo systemctl status dnsmasq ● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2018-03-09 19:48:40 UTC; 3min 13s ago
    Process: 501 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS) Process: 487 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
    Process: 456 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
    Main PID: 500 (dnsmasq) CGroup: /system.slice/dnsmasq.service └─500 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.d
    Mar 09 19:48:39 raspberrypi dnsmasq[500]: warning: interface wlan0 does not currently exist
    Mar 09 19:48:39 raspberrypi dnsmasq-dhcp[500]: DHCP, IP range 192.168.50.150 -- 192.168.50.200, lease time 1d
    Mar 09 19:48:39 raspberrypi dnsmasq[500]: read /etc/hosts - 5 addresses
    Mar 09 19:48:39 raspberrypi dnsmasq[500]: no servers found in /run/dnsmasq/resolv.conf, will retry
    Mar 09 19:48:39 raspberrypi dnsmasq[501]: Too few arguments.

    Mar 09 19:48:40 raspberrypi dnsmasq[501]: Too few arguments.
    Mar 09 19:48:40 raspberrypi systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
    Mar 09 19:48:44 raspberrypi dnsmasq-dhcp[500]: DHCP packet received on eth0 which has no address
    Mar 09 19:48:48 raspberrypi dnsmasq[500]: reading /run/dnsmasq/resolv.conf
    Mar 09 19:48:48 raspberrypi dnsmasq[500]: using nameserver 192.168.100.1#53

    Report
  • Comment Link roboberry Friday, 09 March 2018 17:44 posted by roboberry

    Hi Elias,
    Could you send me the full output of; sudo systemctl -i hostapd ,please.
    Another area to double check is the default file as that can cause hostapd to exit.
    in /etc/default/hostapd

    check the last line #DAEMON_OPTS="" starts with a #, and the DAEMON_CONF="/etc/hostapd/hostapd.conf" line has the correct path. I know this is in the guide but just want to eliminate common config errors.

    I have tried a few things but not getting the error ostapderror: unexpectedly disconnected from boot.that you are, but Hostapd is the cause of the problem, we just need to determine whats causing it to exit.

    Report
  • Comment Link Elias Friday, 09 March 2018 17:36 posted by Elias

    Thank you for your response. The ip address are good and the nohook spa_supplicant is entered as per your instructions. The dnsmasq.service is Active Running. The hosted.service it show "Active (exited) and few lines below i see "hostapderror: unexpectedly disconnected from boot.."

    Report
  • Comment Link roboberry Thursday, 08 March 2018 20:52 posted by roboberry

    Hi Elias, It may be that there is a config issue somewhere. Firstly check that dnsmasq is running ok, in terminal enter sudo systemctl status dnsmasq, you should see some green text within the output that says running.
    If thats ok check hostpd is ok as well, sudo systemctl status hostapd.

    If there is an issue with either just double check their config files.
    If you try the command ip addr you should see the ip address for the hotspot displayed 192.168.50.10

    if not also check that the ip addresses in /etc/dnsmasq.conf and /etc/dhcpcd.conf all start with 192.168.50

    Check that wpa_supplicant is not running, enter wpa_cli -i wlan0 status, if it returns information about your wifi like IP numbers, then it is still running. Make sure that in /etc/dhcpcd.conf that the line nohook wpa_supplicant is entered.


    if you have no luck, let me know if you are using Jessie or Stretch and if you are using the Internet or non Internet setup.

    Report
  • Comment Link Elias K Thursday, 08 March 2018 05:19 posted by Elias K

    Hi,

    I am newbie in this space, I followed your instructions but i can't see the hotspot from my mobile devices, i checked with multiple devices and the ssid is not advertised. In the task bar I have the up&down arrow instead of the wifi symbol and if a hover my mouse over i see (eth0: configured , wlan0: Not associated).
    I don't know where to start troubleshooting it, any help will be appreciated.

    thanks

    Report
  • Comment Link Stefano Saturday, 10 February 2018 17:52 posted by Stefano

    Hi roboberry, thanks for answering me.
    During this days I found another guide (also published by yiu) that respond better to my issue: “Raspberry Pi - Auto WiFi Hotspot Switch - Direct Connection” (with no ethernet routing”). works fine and now Ikm about to follow the other one you made to add the ethernet routing while, in the hotspot mode, I’ll connect the ethernet cable.
    I’ll let you know if it works...
    As you can imagine I’ve deleted old configs so I can’t do tests you suggest....but I’m quite sure I wrote something wrong....
    bye
    S

    Report
  • Comment Link roboberry Friday, 09 February 2018 20:23 posted by roboberry

    Hi Granpino, thanks for sharing the script. Should make a hotspot easier to setup for people who don't want to use the command line :)
    As you say it was the result of various guides online it would be nice to reference those sites that was most help to you. Thanks

    Report
  • Comment Link Granpino Thursday, 08 February 2018 11:04 posted by Granpino

    Hello
    I put together a script following these steps for easy installation. I tested it with Raspberry pi 2 only. https://github.com/granpino/Rpi2_stretch_AP .

    Report
  • Comment Link roboberry Sunday, 04 February 2018 21:17 posted by roboberry

    Hi Stefano, As long as the Ethernet cable is connected to the Pi you should have Internet access, as that side of the configuration is not changed. If you enter the command: ip addr ,you should see a line for eth0: with a ip address, something like
    eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b6:11:bc:3f:2e:3b brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.27/24 brd 192.168.0.255 scope global eth0

    for me the IP address 192.168.0.27 is what my router has given to the Pi through the eth0 port. If there is no IP address then there is an issue between the pi and the router.

    I'm not sure why you needed to clear your routers details from the wpa_supplicant file as the line
    nohook wpa_supplicant
    in the dhcpcd.conf stops the wpa_supplicant file from being read. Check that there is no entry in /etc/network/interfaces file as any entry for wpa_supplicant in this file will also start it up which will work against the hotspot setup.

    If you are getting a eth0 ip address from your router but can't access the Internet then let me know and I will look into it further.

    Report
  • Comment Link roboberry Sunday, 04 February 2018 14:30 posted by roboberry

    Hi Emmanuel Z, As the ngnix server is running on the pi you would be able to access it at 192.168.50.10 or 192.168.50.10:80 if the ip 10.0.77.1 is important and also available on the pi then you could try adding this line to dnsmasq
    address=/edu.box/10.0.77.1
    This is untested but should redirect any requests for edu.box to the ip

    Or you could change the hotspots IP to that what you need the webserver to be.

    In /etc/dhcpcd.con change
    static ip_address=192.168.50.10/24
    static routers=192.168.50.1

    to
    static ip_address=10.0.77.1/24
    static routers=10.0.77.1

    and in /etc/dnsmasq.conf change
    dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h

    to
    dhcp-range=10.0.77.150,10.0.77.200,255.255.255.0,12h

    Then any device connected to the hotspot will be able to access the webserver with 10.0.77.1 in the web browser or the machines hostname ie raspberrypi.local

    Hope this helps

    Report
  • Comment Link Emmanuel Z. Saturday, 03 February 2018 15:07 posted by Emmanuel Z.

    Hi,
    Thanks for this great tuto!
    Would it be possible to serve content from a nginx server running on the pi at 10.0.77.1:80 when the users are connected to the Wifi Hotspot and access edu.box address for example in their browser and let them access internet for all other queries and domains?

    edu.box -> serving local content on the pi
    all other domains -> normal internet access

    Maybe by changing settings in iptables?

    Thanks for your help

    Report
  • Comment Link Stefano Saturday, 03 February 2018 13:08 posted by Stefano

    First of all congratulations for you guide, very clear and simple also for me (new for Linux..).
    I've tried to setup the configuration with Internet access (not the autohotspot). Everything goes fine (dhcp, hotspot, etc.) and from my laptop, connected to the new hotspot, I'm able to connect to RPi via VNC Viewer...But, neither from my laptop and neither from the RPi itself, I'm able to browse the web.
    First of all I've to say that, in order to have the HotSpot up (two opposite green arrow in the upper right corner of the screen), I had to delete, in wpa_supplicant.conf, rows related to the configration of my home wiFi...
    This is the config I have at my home:
    InternetHomeRouterHomeWiFiPCs
    And this is the config with my little RPi 3b:
    InternetHomeRouterRPiWiFiPCs

    As I told you, I wasn't able to navigate also from the RPi...any test I can make in order to understand the problem?
    I've alredy tried to:
    1) connect PC directly to HomeRouter --> OK
    2) open a web page from RPi --> enable to find addr
    3) open a web page from PC ---> request time out
    4) ping a www.something from RPi ---> seems to resolve the IP addr but wasn't able to perform ping
    5) ping a www.something from PC --> same as above
    Does make sense try to PING Pubblic IP given by my provider?

    Thanks a lot
    Stefano

    Report
  • Comment Link Roboberry Monday, 25 December 2017 22:03 posted by Roboberry

    Hi Vaibhav, what issues are you having on reboot. This guide is for a permanent static hotspot so it will always boot as a hotspot.

    Report
  • Comment Link Vaibhav V Sunday, 24 December 2017 05:21 posted by Vaibhav V

    Hi Roboberry,
    Thanks for this informative guide on setting up Hotspot on a RPI. My question is whether is it possible for the pi to automatically become a Hotspot on reboot?? Because I want the Pi to instantly become a hotspot once it is turned on. I donot want to make these settings everytime when the PI gets booted.Is that possible?? Please help.
    Eagerly awaiting for your reply.

    Thanks and Regards
    Vaibhav V.

    Report

Additional information