Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Raspberry Pi 3 access-point-setup
#!/bin/bash
#
# This version uses September 2017 august stretch image, please use this image
#
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
if [[ $# -lt 1 ]];
then echo "You need to pass a password!"
echo "Usage:"
echo "sudo $0 yourChosenPassword [apName]"
exit
fi
APPASS="$1"
APSSID="rPi3"
if [[ $# -eq 2 ]]; then
APSSID=$2
fi
apt-get remove --purge hostapd -yqq
apt-get update -yqq
apt-get upgrade -yqq
apt-get install hostapd dnsmasq -yqq
cat > /etc/dnsmasq.conf <<EOF
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h
EOF
cat > /etc/hostapd/hostapd.conf <<EOF
interface=wlan0
hw_mode=g
channel=10
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
wpa_passphrase=$APPASS
ssid=$APSSID
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
EOF
sed -i -- 's/allow-hotplug wlan0//g' /etc/network/interfaces
sed -i -- 's/iface wlan0 inet manual//g' /etc/network/interfaces
sed -i -- 's/ wpa-conf \/etc\/wpa_supplicant\/wpa_supplicant.conf//g' /etc/network/interfaces
sed -i -- 's/#DAEMON_CONF=""/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/g' /etc/default/hostapd
cat >> /etc/network/interfaces <<EOF
# Added by rPi Access Point Setup
allow-hotplug wlan0
iface wlan0 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
EOF
echo "denyinterfaces wlan0" >> /etc/dhcpcd.conf
systemctl enable hostapd
systemctl enable dnsmasq
sudo service hostapd start
sudo service dnsmasq start
echo "All done! Please reboot"
Owner

Lewiscowles1986 commented Mar 6, 2016

This is specifically for the raspberry pi 3. The script should work with any wireless card setup as wlan0 that does not require a driver, please provide feedback, let me know any issues.

The use-case is setting up a private network, maybe for some rPi zero's to connect to, but the sky is the limit; you could bolt on a dns-server and provide a walled-garden internet experience like facebook (please don't), or host your personal project to showcase at interview.

Now allows you to specify the Access point (AP) name, so it does not have to be whatever it was before.

I suggest to share the eth0 connection that you add
net.ipv4.ip_forward=1
in /etc/sysctl.conf
and execute the following iptables command:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

This will allow the traffic to pass through the wifi AP and out via the ethernet connection.

Owner

Lewiscowles1986 commented Mar 15, 2016 edited

Hi @vhgarandil,

Thanks for the suggestions, this is not a script to setup a wireless->ethernet bridge, however it is a good idea for an additional script to allow using a device (doesn't matter really if it's ethernet or another wifi dongle).

The main purpose of this script is to provide an access point with guest network (for now). But I may consider adding this, as many have asked for it

I am a very very new user having just received my rPi3 running Raspbian. In at the deep end I know but I thought this function would be useful. I have been able to compile the script and even run it, but am at a loss at getting past "you need a password!"
How do I respond to the usage advice line? I have tried to input a password but cannot get beyond causing the error 'command not found'. What am I missing?

Can you give me a prod in the right directions? Thanks if you can take the time to no doubt tell me the obvious!

I find this very useful. Could you add some options to help the user to share the eth0 connection through wifi.

Owner

Lewiscowles1986 commented Mar 25, 2016

Hi @ipplepen

So once you run the script, you can run
sudo rPi3-ap-setup.sh password wifiapname
and it will setup with the password "password", and the SSID "wifiapname"

Owner

Lewiscowles1986 commented Mar 25, 2016

@bitterypaul

Thanks, I'm looking right now at releasing something separate for that, so that you can share eth0, or any other networking device; I believe @vhgarandil suggestion (see above) will work for bridging eth0 as the primary connection, but to make a script do this; I think they should be separate scripts for people like me that don't want a bridge or repeater station.

elck commented Mar 27, 2016

I have some problems with this script.
Mind you, I am a total beginner with linux
On line 19 there is a var $APSSID (should that be APSSID ?) whilst on line 40 I see ssid=$APNAME (shouldn't that be $APSSID ?)

The other thing is an error I get on line 50 (when I remove the redirection that is)
Failed to create interface mon.wlan0 :-95 (Operation not supported)
wlan0 could not connect to kernel driver

What am I doing wrong please?

Owner

Lewiscowles1986 commented Mar 28, 2016

@elck nice catch on APSSID vs APNAME, must have renamed a var and forgot to copy to / update all lines (managing this via git might have been a better idea)

can I ask if you are using this on a raspberry Pi 3 using raspbian?

Most of the steps are entirely applicable on any debian based Linux on the Pi3, but raspbian has the official rPi3 hardware libs; so I'd advise using that (they have a lite edition now)

Thanks for the feedback, keep me updated

crone commented Apr 3, 2016

I have tried this script. All seems to be ok on the RPI3 side. But non of my devices at home are able to connect to the AP.

Any help would be appreciated.

Owner

Lewiscowles1986 commented Apr 4, 2016

can I ask the exact commands you ran?

Most devices should be able to connect to the rPi3, although it's not an internet pass-through Access-Point; it's so you can access your Pi to help to configure it with fewer wires

Good code you have here, but it just does not work for me,even though i am using raspbian. I've been trying for a few days to get the Pi3 AP working but it's always the same thing, saying that it could not start mon.wlan0 but the AP is enabled(i've attached a screenshot). Even so i can not connect with any device to the ap. Perhaps is there something i haven't installed?
capture

Hello,

i copy the code. and type chmod-R 755
if i start it. i get the following error:

root@HaRuVerhuur-Matrix:/home# ./rpi3-ap-setup.sh testing aptest
You need to pass a password!
Usage:
sudo ./rpi3-ap-setup.sh yourChosenPassword [apName]

Grees Ruben Dijk

marcelerkel commented Apr 21, 2016 edited by Lewiscowles1986

@RubenDijk
Try changing line 8 to:

if [[ $# -lt 1 ]];

The current code checks if the number of command line parameters is not equal to one (-ne 1). Since you specify the optional apName parameter, you have two parameters which causes the test to fail and hence the 'You need to pass a password!' error message.
Even better would be to test for less than one or greater than two, but I leave that as an exercise for @Lewiscowles1986 :)

_Author FYI_
I won't be taking part in "exercises" or assignments ๐Ÿ˜‰

csatt commented Jun 4, 2016

This works for me, but only if I add the following line to rc.local:

service hostapd start

I put it right before the "service dnsmasq restart".

imac8t commented Jun 11, 2016

Syntax error: "fi" unexpected (expecting "then")
why๏ผŸ

Hi,
How can switch wifi from "access point" mode to "standard" mode ?
Is it enough if i just remove lines from rc.local file and reboot?
Is there any other service like "dnsmasq" that needs to be swicthed off in "standard" mode?

I have this problem.
pi@raspberrypi:~ $ sudo python rPi3-ap-setup.sh
File "rPi3-ap-setup.sh", line 3
if [ "$EUID" -ne 0 ]
^
SyntaxError: invalid syntax
pi@raspberrypi:~ $

@ghost

ghost commented Jun 28, 2016

@lvhailong This is a shell script as denoted by the shebang at the top and .sh extension.

Owner

Lewiscowles1986 commented Jun 29, 2016

Thanks @usertaken

@navaneetharaopy you would have to edit the /etc/rc.local, but also disable hostapd and dnsmasq services

sed -i -- 's/wlan0/wlan999/g' /etc/rc.local should do for rc.local, then sed -i -- 's/wlan999/wlan0/g' /etc/rc.local if you want to restore on wlan0

Owner

Lewiscowles1986 commented Jun 29, 2016 edited

@csatt

This works for me, but only if I add the following line to rc.local:

service hostapd start

I put it right before the "service dnsmasq restart".

that should not be required as dnsmasq is started on the next line. Hostapd is started within the script too!

csatt commented Jun 30, 2016

I see where dnsmasq is started. Where is hostapd started? The "hostapd - B ..." command on the last line fails (for me) unless the service is started first. Do you have to run "sudo update-rc.d hostapd enable" or something like that for it to work without explicitly starting the service in rc.local?

@adiroman

I'm having a really similar problem, getting the errors

Failed to create interface mon.wlan0: 95 (Operation not supported)
and
wlan0: could not connect to kernel driver

but not the other stuff.

Anyone have a solution?

I tried sudo hostapd /etc/hostapd/hostapd.conf
Then i got

drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0xfc5648
ioctl[SIOCSIWMODE]: Invalid argument
Could not set interface to mode(3)!
Could not set interface to master mode!
rtl871xdrv driver initialization failed.

No one can help with @adiroman, @SammoMate AND my problem?

Owner

Lewiscowles1986 commented Aug 27, 2016

@marianomarini @adiroman @SammoMate I just used the script on a fresh jessie-lite image from the raspberry pi website. The only issue I encountered was one line for the access-point name which should now be fixed. This works with fresh jessie-lite image, not sure what could be interfering

Everything works perfectly, but I can not access the internet on my phone when connected to my pi. What should I change in order to be able to connect to the internet?

9H5G commented Sep 6, 2016

Many thanks @lewiscoles1986 - worked out of the box! Thank you :)

(If the bridge script were to come along that would be fantastic :))

Owner

Lewiscowles1986 commented Sep 8, 2016

I'll add the bridge script soon and link here

mehranexpert commented Sep 8, 2016 edited

Not work for me .

root@kali:~/git/ap# ./rPi3-ap-setup.sh  testtest mehran
./rPi3-ap-setup.sh: line 19: rPi3=mehran: command not found
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  freeglut3 libgnutls-deb0-28 libpng12-0 libpoppler57
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  hostapd*
0 upgraded, 0 newly installed, 1 to remove and 446 not upgraded.
After this operation, 981 kB disk space will be freed.
(Reading database ... 233701 files and directories currently installed.)
Removing hostapd (1:2.5-2+v2.4-2) ...
Purging configuration files for hostapd (1:2.5-2+v2.4-2) ...
dpkg: warning: while removing hostapd, directory '/etc/hostapd' not empty so not removed
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (230-7) ...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
dnsmasq is already the newest version (2.76-4).
The following packages were automatically installed and are no longer required:
  freeglut3 libgnutls-deb0-28 libpng12-0 libpoppler57
Use 'apt autoremove' to remove them.
The following NEW packages will be installed:
  hostapd
0 upgraded, 1 newly installed, 0 to remove and 446 not upgraded.
Need to get 0 B/491 kB of archives.
After this operation, 981 kB of additional disk space will be used.
Selecting previously unselected package hostapd.
(Reading database ... 233677 files and directories currently installed.)
Preparing to unpack .../hostapd_1%3a2.5-2+v2.4-2_armhf.deb ...
Unpacking hostapd (1:2.5-2+v2.4-2) ...
Processing triggers for systemd (230-7) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up hostapd (1:2.5-2+v2.4-2) ...
update-rc.d: We have no instructions for the hostapd init script.
update-rc.d: It looks like a network service, we disable it.
insserv: warning: current start runlevel(s) (empty) of script `hostapd' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `hostapd' overrides LSB defaults (0 1 6).
Processing triggers for systemd (230-7) ...
All done!

Owner

Lewiscowles1986 commented Sep 12, 2016 edited

root@kali yeah, looks like raspbian @mehranexpert... this is for specific hardware and software _RASPBERRY PI 3 & OFFICIAL RASPBIAN_

You might want to checkout resin.io

doktor500 commented Sep 26, 2016 edited

I have the same issue than @adiroman

I install the latest version of RASPBIAN JESSIE LITE on my Raspberry Pi Model 3
I ssh into it and run:

wget https://gist.githubusercontent.com/Lewiscowles1986/fecd4de0b45b2029c390/raw/71a732423f7302cd7dd441e9c98f38a7ec471b4c/rPi3-ap-setup.sh
chmod +x rPi3-ap-setup.sh
sudo apt-get update
sudo ./rPi3-ap-setup.sh password apname

All seems to be good, but when I run sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf

This is the output:

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:fc:f9:b4 and ssid "dmcom-mad"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
Owner

Lewiscowles1986 commented Oct 3, 2016

why are you running anything, just reboot the pi, it should automatically start... I'm going to make a slightly modified one using systemd service instead of hacky approach to /etc/rc.local, but I've just run this successfully on the pixel release and the latest jessie lite release.

Owner

Lewiscowles1986 commented Oct 3, 2016

_.bash_history_

ping google.com
cd /boot
ls
sudo reboot
sudo cp /boot/wpa_supplicant.conf /etc/wpa_supplicant/
sudo reboot
wget http://bit.ly/2cOGZuL
chmod +x  2cOGZuL
sudo apt update
sudo 2cOGZuL password apname
reboot

I did see some error messages on boot, but I still have the apname show up in my list (which is new for me, as I generally pick one)

image

Owner

Lewiscowles1986 commented Oct 4, 2016 edited

Also there is now a newer version using systemd, and this companion script for anyone wanting to pass through an adapter.

simar88 commented Oct 6, 2016 edited

Hello everyone, i'll always receive "errors were encountered while processing:hoastapd" during the setup.
Do you have any idea?
Thanks in advance,
Simone

Dear All,

I want to use Rpi 3's wifi in both Access Point and Station mode simultaneously or at a time one but without reconfigure(reboot the pi).And now, i did to both mode individual configure and work its fine but problem is every time configure change for individual mode.
Please guide me.

nenoork commented Oct 10, 2016 edited

How to setting up a kind of bridge between eth0 and wlan0 like @vhgarandil told. I don't get it it's not working for me. Please you upload a kind of other script just for doing a bridge? (I'd like to access to internet by the AP) I'm still waiting for it. Keep updating i like what you do @Lewiscowles1986!

Owner

Lewiscowles1986 commented Oct 13, 2016

@nenoork, there is another script linked above... Please go to this url https://gist.github.com/Lewiscowles1986/f303d66676340d9aa3cf6ef1b672c0c9

Owner

Lewiscowles1986 commented Oct 13, 2016

@PratikGajera I'm really sorry I don't understand what you are asking

I am asking about that which way to configure wifi that run it both mode station and Access Point.

dreetie commented Oct 22, 2016

Script runs great, but how do you revert back to station mode?

Owner

Lewiscowles1986 commented Oct 28, 2016

systemctl disable hostapd
systemctl disable dnsmasq

and adding

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf to /etc/interfaces should do it. Really at the point you are doing that this quick and dirty version won't work too well for you

Just ran this on my raspberry pi 3 and now I no longer have a wifi interface in raspbian. Does this require having another usb wifi adapter plugged in?

Also, How do I completely remove this?

Owner

Lewiscowles1986 commented Oct 31, 2016

@goodpunk6 this does not require a second wifi adapter unless using as a range extender...

@goodpunk6 to remove this try the following

sudo apt-get remove --purge hostapd dnsmasq

then add wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf to /etc/interfaces inside the /dev/wlan0 section

alternatively backup your home folder and re-flash the jessie-pixel or jessie-lite image

It would be really nice to have a way to automacally revert the chages made by this script, so that one could get back to normal use of your RPi as easily.

dreetie commented Nov 3, 2016

@goodpunk6 I've got the same problem as you: no wireless interfaces found

how i connect rspi3 to a network?

Owner

Lewiscowles1986 commented Nov 8, 2016

@heniotierra. More than happy to see a fork that does. I don't think shell is a good place to do this, it's more of a DSC deal where existing tools could take this and make for example an ansible playbook that stacks little scripts like this to specify a desired state of a raspberry pi

I'm having the same issue as @adiroman and @doktor500.
Apologies if I missed it but did either of you get a resolution to your problem?

Clint67 commented Jan 11, 2017 edited

GREAT JOB my firend!!
I was struggling among a lot of sligtly different directions to get my Rpi3 working as an AP.
Some of them didn't work at all, some just get the Rpi3 working as AP ignoring the other commands to route traffic to share the eth0 internet connection.
Your script worked at first shot and combined with your other script at
https://gist.github.com/Lewiscowles1986/f303d66676340d9aa3cf6ef1b672c0c9
I got it working also as a AP with traffic forwarding,...

...but my question is:

Can the Rpi3 work like any other 'out of the box' AP on the market?

I mean, 'transparent' like any AP I can buy on store shelfs? So, the wifi devices connected to the AP 'share' the same IP class as the primary router. Or, even better, get the IP address from the DHCP working on the primary router?

I am quite out of the IP configurations world, and I am just wondering if I can set the static IP class of the wlan0 to join my home lan configuration and have wireless devices on the same subnet of the primary router.

This because I need to send/receive some UDP packets to devices 'wifi connected' to the lan through the Rpi (on other ports than the 80)
Any idea is welcome...

And, once again, thank you very very much for sharing your code!

Owner

Lewiscowles1986 commented Jan 14, 2017

@Clint67 thanks ๐Ÿ‘

You can alter the dnsmasq config file to allocate to the same subnet if that is what you'd like. You could also adjust the mask or change the rules from the other script but I've never attempted nor have the inclination to make it compete with AP makers. Fork it and share your changes with the world!

๐Ÿ˜‰

Hi Lewis,

First off thank you for creating such an easy to use script and helping troubleshoot. I'm trying to set up a new Pi3 to create a local network for several other Pi3s and I stumbled upon your script (among several sketchy or out-of-date tutorials). I ran the script on a brand new installation of Rasbian using NOOBS but I'm having a couple issues. If I don't reboot after the script runs then I can see the newly created AP on my phone and laptop, but they are not being assigned an IP address. If I reboot the Pi3 then the AP doesn't even show up.

I'm a bit of a Linux noob so I'm unsure of how to go about troubleshooting; it appears as though hostapd and dnsmasq are both running after the reboot but they aren't functioning properly. Do these programs create a log file or anything I can look at? Is there any monitoring feature so I can see error/other messages in real-time?

Thanks again!

tverboon commented Jan 21, 2017 edited

Great script! Only thing I had to configure was the following:

sudo nano /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"

Otherwise the systemd service would exit right away. Not sure why, because the config is passed as a parameter.

Owner

Lewiscowles1986 commented Jan 25, 2017 edited

@tverboon that is strange, as you say we specify hostapd inside the service we completely generate from scratch

@dfarley1 this wasn't written for NOOBS and hasn't been tested on NOOBS, it's written for jessie pixel and jessie lite

On logging I haven't set it up, but try sudo ls -lhaR /var/log it should recursively list all log files. If there are not specific logs it may end up in syslog (I Have to admit I pretty much record what I do to get working, I'm by no means an expert with either. Much like yourself I became fed-up of tutorials asking people to attend the installation and have more than minimal input)

SamGG commented Feb 22, 2017

Thanks for the script!
I ran it step by step on a minibian https://minibianpi.wordpress.com/ after having installed the wifi https://minibianpi.wordpress.com/how-to/rpi3/
Nevertheless, I didn't use the line 67, because it does not make sense to me.
@adiroman, @doktor500, @botzen67 I encountered the same error, but it disappeared after a couple of reboot
NB: the length of the password must be at least 8 characters
I added a command to prevent energy saver from stopping the wifi interface: http://raspberrypi.stackexchange.com/questions/43473

ikester commented Mar 5, 2017

Thank you for this script. I was having trouble getting this to work after boot using 'hypriot'. If I manually restarted the service I could see the SSID but after a fresh reboot it just wouldn't show up. There were no errors in the logs and the output look exactly the same as when it worked manually. I figured it was a timing issue with the startup sequence. I finally got it to work by changing line 3 of the Systemd unit file to this instead:
After=network.target
It now shows up just fine after a reboot.

How to disable the AP script after use?

This is great! I ran into a problem however because the password length must be at least 8 character. It'd be great to add a check like:

if [ $APPASS -lt 8 ]
then
  echo "Password must be greater than 8 characters"
  exit
fi

Otherwise one must manually run /usr/sbin/hostapd -B /etc/hostapd/hostapd.conf -P /var/run/hostapd.pid to see the error (and the AP will silently fail to start).

reinhart1010, I copied the dhcpcd.conf and interfaces files to dhcpcd.conf.station and interfaces.station before I ran the script
and then copied them to dhcpcd.conf.access_point and interfaces.access_point after I ran the script. Then I have two little scripts in the same directory I can run to switch back and forth:

restart_station

#
cp dhcpcd.conf.station /etc/dhcpcd.conf
cp interfaces.station /etc/network/interfaces
systemctl disable hostapd
shutdown -r now

restart_access_point

#
cp dhcpcd.conf.access_point /etc/dhcpcd.conf
cp interfaces.access_point /etc/network/interfaces
systemctl enable hostapd
shutdown -r now

kaz325 commented Mar 30, 2017

@Clint67
Did you succeed with this setup? if so, could you share what you did?

xsteacy commented May 5, 2017

when running:
sudo /usr/sbin/hostapd /etc/hostapd/hostapd.conf
I got:

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:69:ae:44 and ssid "testing"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED

The AP is working, I can connect to it but there is no internet access.

I use an RPI3 with the build-in wireless and the latest Raspbian with Pixel

Help will be very much appreciated, Thnk you

Thank you! This worked for me. Also, thank you for not adding the wireless->ethernet bridge. A lot of people want this but in my case, I'm only providing an interface to my device.

Setting up captive portal would be helpful, so that a browser automatically opens and loads the main page from the server running on the RPi.

For captive portal, try adding in dnsmasq.conf

address=/#/<address of your ap>

MrWeax1 commented Jun 17, 2017

Hi there! I was wondering how I could make the SSID hidden, as in it isn't broadcast to all computers and you have to manually enter the SSID on the connecting devices.

w7efs commented Jun 22, 2017 edited

ignore_broadcast_ssid=0 in /etc/hostapd/hostapd.conf should hide the SSID.

hi,
thank you very much for sharing this! :)
but i've and error :

rPi3-ap-setup.sh: 6: [: Illegal number: rPi3-ap-setup.sh: 11: rPi3-ap-setup.sh: [[: not found rPi3-ap-setup.sh: 21: rPi3-ap-setup.sh: [[: not found Reading package lists... Done
how can I resolve this ?

Owner

Lewiscowles1986 commented Aug 21, 2017 edited

don't know what people are running to get some of these errors. I run stock raspbian-lite, and have now got this working with the stretch distro

I copy a wpa_supplicant.conf to the pi with my wifi details, create a file named ssh both on /boot, power it on, wait a few seconds

From my PC I then run

ssh pi@raspberrypi.local  -o UserKnownHostsFile=/dev/null

Once connected to the Pi I run

curl -sSL https://gist.github.com/Lewiscowles1986/fecd4de0b45b2029c390/raw/0c8b3af3530a35db9ab958defe9629cb5ea99972/rPi3-ap-setup.sh | sudo bash $0 password rPi3AP

sudo wget -q https://gist.githubusercontent.com/Lewiscowles1986/390d4d423a08c4663c0ada0adfe04cdb/raw/5b41bc95d1d483b48e119db64e0603eefaec57ff/dhcpcd.sh -O /usr/lib/dhcpcd5/dhcpcd
sudo chmod +x /usr/lib/dhcpcd5/dhcpcd

Then I reboot and it works

Hi, does it have a feature that if I connect ethernet cable on RPi3 and it gives internet connection like a router?

Owner

Lewiscowles1986 commented Sep 8, 2017 edited

@mrsimple97 it's not a bridge or wifi range extender, it's just an access point. I use it to make fake internet / network.

You can try combining with https://gist.github.com/Lewiscowles1986/f303d66676340d9aa3cf6ef1b672c0c9 to make this a bridge, however, YMMV depending upon interface names

Hello, I have tried to run your script but eth0 disappear. I have also written a script with the same base and eth0 also disappear. Have you an idea where is the trouble?

Owner

Lewiscowles1986 commented Sep 11, 2017

@jonathandreyer do you have a .bash_history I can look at. Also what is the output of ip -a command (it's the new ifconfig). Please attach to a gist or pastebin and link that here ๐Ÿ˜‰

buckster123 commented Sep 16, 2017 edited

This script works fine with Ubuntu Mate 16.04.3 LTS on rpi3.
Edit: I wanted to use this to trick my chromecast, but it is a No Go. Ho on earth do i reverse what the script did to have wlan works as before script was applied?
Edit: Please forgive my noobieness.

Edit: Figured it out :-D

Owner

Lewiscowles1986 commented Sep 18, 2017

๐Ÿ‘ @buckster123 glad you worked it out. Do you think this would benefit from an uninstall action?

JddAndrewLauren commented Sep 21, 2017 edited

This works well for me, correctly setting up the wireless AP, but I also lose my ethernet connection. If I comment out the lines added in the /etc/network/interfaces file and reboot, the AP goes down as expected and I get ethernet back.

Here's a pastebin of my ifconfig -a. Running on a rpi3 on Raspbian Stretch with desktop. Thanks.

Edit: I got the ethernet working again after adding these lines to /etc/network/interfaces:
auto eth0
iface eth0 inet dhcp

schmi85 commented Sep 28, 2017

At the very top

# This version uses September 2017 august stretch image, please use this image

So which exact release date is meant with that? 2017-09-07 or 2017-08-16

Thanks for clarification!

carlpoole commented Oct 6, 2017 edited

Spent a good couple of hours trying to do all this manually searching Google then stumbled across this script. Thanks!

I had previously setup bridging between eth0 and wlan0 with the iptables commands but after rebooting from running the script I noticed my eth0 disappeared from ifconfig so I added the following to /etc/network/interfaces underneath what your script added in there and it worked. Seems related to what @JddAndrewLauren mentioned.

auto eth0
    allow-hotplug eth0
    iface eth0 inet dhcp
Owner

Lewiscowles1986 commented Oct 12, 2017

Oh btw https://gist.github.com/Lewiscowles1986/390d4d423a08c4663c0ada0adfe04cdb fixes stretch release network config (which sucks)

Thanks for the script. Getting an AP up on an rpi3 w/ stretch is a BEAR. I used most of your initial script (above) and your most recent script on the stretch network config (here) BUT had to add hostapd -dd /etc/hostapd/hostapd.conf > /dev/null to my rc.local file. Without it the pi boots up and hostapd shows up as "active" "exited" and the AP never starts. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment