bimble
Posts: 4
Joined: Fri May 22, 2015 7:25 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri May 22, 2015 7:37 am

pokrivnik wrote:If you enter "sudo service udhcpd start" It works OK

If you enter "sudo update-rc.d udhcpd enable" does not start after reboot.
Mine does exactly this and I'd just arrived here to seek an answer too. I'd followed the tutorial and got to the point of it working but udhcpd fails on reboot. Start it manually afterwards and it works just fine. Log extract below -

Code: Select all

May 21 20:39:51 raspberrypi udhcpd[2219]: udhcpd (v1.20.2) started
May 21 20:39:51 raspberrypi udhcpd[2219]: max_leases=235 is too big, setting to 11
May 21 20:39:51 raspberrypi udhcpd[2219]: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
May 21 20:39:51 raspberrypi udhcpd[2219]: is interface wlan0 up and configured?: Cannot assign requested address
May 21 20:39:51 raspberrypi dhcpcd[1977]: wlan0: carrier acquired
May 21 20:39:51 raspberrypi dhcpcd[1977]: all: IPv6 kernel autoconf disabled
May 21 20:39:51 raspberrypi dhcpcd[1977]: wlan0: IAID 60:05:02:af
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: Link beat detected.
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: Executing '/etc/ifplugd/ifplugd.action wlan0 up'.
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: client: /sbin/ifup: interface wlan0 already configured
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: Program executed successfully.
Starting udhcpd with "service start" once the pi is booted and it comes up and works perfectly - I can get to the pi from an android phone and I get allocated an IP. I can browse to the running nginx just fine too.

Am I supposed to have udhcpd *and* dhcpcd? I seem to have both. Working backwards up the thread...

hunternet93
Posts: 336
Joined: Mon Dec 12, 2011 4:34 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri May 22, 2015 5:52 pm

bimble wrote:
pokrivnik wrote:If you enter "sudo service udhcpd start" It works OK

If you enter "sudo update-rc.d udhcpd enable" does not start after reboot.
Mine does exactly this and I'd just arrived here to seek an answer too. I'd followed the tutorial and got to the point of it working but udhcpd fails on reboot. Start it manually afterwards and it works just fine. Log extract below -

Code: Select all

May 21 20:39:51 raspberrypi udhcpd[2219]: udhcpd (v1.20.2) started
May 21 20:39:51 raspberrypi udhcpd[2219]: max_leases=235 is too big, setting to 11
May 21 20:39:51 raspberrypi udhcpd[2219]: can't open '/var/lib/misc/udhcpd.leases': No such file or directory
May 21 20:39:51 raspberrypi udhcpd[2219]: is interface wlan0 up and configured?: Cannot assign requested address
May 21 20:39:51 raspberrypi dhcpcd[1977]: wlan0: carrier acquired
May 21 20:39:51 raspberrypi dhcpcd[1977]: all: IPv6 kernel autoconf disabled
May 21 20:39:51 raspberrypi dhcpcd[1977]: wlan0: IAID 60:05:02:af
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: Link beat detected.
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: Executing '/etc/ifplugd/ifplugd.action wlan0 up'.
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: client: /sbin/ifup: interface wlan0 already configured
May 21 20:39:52 raspberrypi ifplugd(wlan0)[1650]: Program executed successfully.
Starting udhcpd with "service start" once the pi is booted and it comes up and works perfectly - I can get to the pi from an android phone and I get allocated an IP. I can browse to the running nginx just fine too.

Am I supposed to have udhcpd *and* dhcpcd? I seem to have both. Working backwards up the thread...
Hmm, looks like things have changed in the latest version of Raspbian. When I have time I'll run through the tutorial and see what broke, from your log excerpt it seems that udhcpd is starting before the static IP is set on wlan0.

bimble
Posts: 4
Joined: Fri May 22, 2015 7:25 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri May 22, 2015 6:49 pm

I'd guessed it was some sort of ordering problem but have no idea how to re-order the start up of those 2 services.

If you need me to test anything feel free to ask.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Thu Jun 04, 2015 5:24 pm

I have a RTL8188CUS usb dongle, I followed this guide http://www.lucadentella.it/2014/11/12/r ... ess-point/that uses dnsmasq and hostapd to setup the access point.
I cans ee the wifi but when I try to connect to it the phone still says: "Connecting" and the log

Code: Select all

Jun  4 19:21:16 raspberrypi hostapd: wlan0: STA 10:68:3f:43:b9:ca IEEE 802.11: associated
Jun  4 19:21:16 raspberrypi hostapd: wlan0: STA 10:68:3f:43:b9:ca RADIUS: starting accounting session 5570881E-00000003
Jun  4 19:21:24 raspberrypi dnsmasq-dhcp[1440]: DHCPDISCOVER(wlan0) 10:68:3f:43:b9:ca
Jun  4 19:21:24 raspberrypi dnsmasq-dhcp[1440]: DHCPOFFER(wlan0) 192.168.0.38 10:68:3f:43:b9:ca
Jun  4 19:21:24 raspberrypi dnsmasq-dhcp[1440]: DHCPDISCOVER(wlan0) 10:68:3f:43:b9:ca
Jun  4 19:21:24 raspberrypi dnsmasq-dhcp[1440]: DHCPOFFER(wlan0) 192.168.0.38 10:68:3f:43:b9:ca
Jun  4 19:21:41 raspberrypi dnsmasq-dhcp[1440]: DHCPDISCOVER(wlan0) 10:68:3f:43:b9:ca
Jun  4 19:21:41 raspberrypi dnsmasq-dhcp[1440]: DHCPOFFER(wlan0) 192.168.0.38 10:68:3f:43:b9:ca
Jun  4 19:22:02 raspberrypi hostapd: wlan0: STA 10:68:3f:43:b9:ca IEEE 802.11: disassociated
Here my hostapd.conf

Code: Select all

#wlan0 will be working in AP mode
interface=wlan0
#your AP SSID
ssid=RPiAP
#WiFi channel used by AP
channel=3
#Hardware configuration
#type of driver to be used (in may be different depending on your WiFi dongle chipset)
#in majority of cases it will be driver=nl80211
driver=rtl871xdrv
#Whether IEEE 802.11n (HT) is enabled
ieee80211n=1
#User-friendly description of device (optional)
device_name=RTL8188CUS
#Manufacturer name (optional)
manufacturer=Realtek
#WPS RF Bands (a = 5G, b = 2.4G, g = 2.4G, ag = dual band)
hw_mode=g
wmm_enabled=0
interfaces

Code: Select all

auto lo eth0

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.0.7
  netmask 255.255.255.0
I set mac address access list on my router, previously the raspberry was connected to it via wifi so che mac access is enabled.
I set in the interfaces file the reserved ip set in the router DHCP reservation.
Any help?

nick268
Posts: 3
Joined: Sun Jun 28, 2015 11:52 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Sun Jun 28, 2015 12:16 pm

I too ran into problems using a version of this tutorial using isc-dhcp-server as the DHCP server, rather than the server specified here. My intention was to use this as the basis of a VPN routed wireless router.

Again on first putting in the necessary files and settings it worked brilliantly, however on reboot I had the same issue that WLAN0 was not getting the fixed IP address, and so the DHCP server was not starting properly (or possibly vice versa).

I note the suspicion that the various servers are starting in an order that seems to cause the issue.

As a work around I have edited /etc/rc.local by adding the lines

Code: Select all

sudo ifconfig wlan0 192.168.42.1
sudo isc-dhcp-server start
to get it to start on bootup and reboot as intended.
I will check back to see if anyone solves the issues without my scrappy workaround, but I seem to have succeeded in my quest for a working VPN router using this tutorials method and openvpn together with iptables taken from another tutorial.

There are some other issues such as how to turn the PI Router off without logging into it via ssh, and flushing the ip tables using iptables -F which is not working in a bash script I have cobbled together from various sources, that I will turn my attention to.

If I get it working in a neat way I may even take the plunge and publish for the information of others.

User avatar
Gerrelt
Posts: 294
Joined: Sat Nov 10, 2012 9:01 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Thu Jul 09, 2015 8:14 pm

Thank you so much! I was fighting with isc-dhcp-server too, and that solved it. 8-)

I cannot get the elinux tutorial to work anymore with the latest raspbian image, so I mixed the tutorial with this post:
viewtopic.php?t=31227#p293467
(see also two posts beneath it)
That post suggests to use isc-dhcp-server.

And after applying your workaround, it worked!

Thanks again.
my Raspberry Pi page: http://raspberry.gerrelt.nl

User avatar
DougieLawson
Posts: 32102
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Jul 10, 2015 8:12 am

nick268 wrote:
As a work around I have edited /etc/rc.local by adding the lines

Code: Select all

sudo ifconfig wlan0 192.168.42.1
sudo isc-dhcp-server start
to get it to start on bootup and reboot as intended.
/etc/rc.local does NOT need sudo, it's running as root anyway.

Also a better place to put your commands for networking is in /etc/network/if-up.d as all scripts in there get run when an interface comes up active.

Create a file called /etc/network/if-up.d/fixnet (using sudo nano)

Code: Select all

#!/bin/bash
[ "$IFACE" != "lo" ] || exit 0

if [ "$IFACE" = "wlan0" ]; then
  ifconfig wlan0 192.168.42.1
  isc-dhcp-server start
fi
sudo chmod 755 /etc/network/if-up.d/fixnet (to make it executable). That script will then run whenever you use a explicit ifup wlan0 command or when that gets done automatically during boot up.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3B*3, 3B+

Please post ALL technical questions on the forum. Do not send private messages.

McRis
Posts: 1
Joined: Thu Jul 23, 2015 7:33 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Thu Jul 23, 2015 7:44 pm

Hey guys.. I am trying to use my raspberry pie as an isolated Access point (no internet) and I followed the instructions of these tutorials http://blog.pistuffing.co.uk/building-t ... -activity/ , http://elinux.org/RPI-Wireless-Hotspot. I get no errors during the process, and I can see my accespoint on other devices but it seems like the Rpi doesn's assign IP addresses on my devices. Udhcpd seems to be running. Also despite the fact that in the interfaces file I assign a static IP to my wifi adapter after a reboot it gets 168.259.x.x a an address (or something similar) .
The only thing I noticed is that when I try to restart my dhcp service

Code: Select all

sudo service dhcpd restart 
I get an error saying "hostapd ioctl invalid argument" but then continues and starts running
Can you help me, I am really new to raspberry? (I am using an edimax wifi adapter)
Thanks in advance!

Teoma
Posts: 7
Joined: Thu Aug 06, 2015 4:16 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Thu Aug 06, 2015 6:36 pm

I've been playing with hostapd and isc-dhcp-server to use the Pi as a WiFi router.

After a LOT of experimenting I think I found the reason hostapd drops the IP address of wlan0 and that's because it reinitialises it. BUT if the device isn't up at boot it works OK; and this is just down to /etc/network/interfaces and the line "auto wlan0".
I removed that and all seems fine over reboots.
You can still set its static IP as usual, just don't have it come up automatically and just let hostapd manage it.

In services (/etc/rc2.d/) hostapd starts before isc-dhcp-server so if wlan0 was up; it would reset it and then isc-dhcp-server then fails to start because it listens on wlan0 also.

mokargas
Posts: 5
Joined: Sun Jun 23, 2013 6:08 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Wed Aug 12, 2015 5:45 am

Hey all, not sure if this is the correct place to post this

I've followed this tutorial to create a WIFI AP. Devices can currently connect to it. I'm using an RTL8188EU chipset.

My RPI is connected to ether which supplies internet.

I have two questions

a) How do I enable connected devices to use this internet connection. Currently it doesn't share it.
b) How can I see (from my PI) what devices are connected? I have tried

Code: Select all

sudo arp -a
, but I can only see my ethernet connections. Not devices on the AP.

Overall picture: I'm creating an AP on the PI so my MiLight controller can connect to it. Ideally I want to control the MiLight through that connection from code on the PI

Teoma
Posts: 7
Joined: Thu Aug 06, 2015 4:16 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Wed Aug 12, 2015 7:25 am

"cat /var/lib/dhcp/dhclient.leases" will show connected devices. As for it not sharing internet just make sure you follow the tutorial correctly, especially enabling forwarding and setting up the firewall correctly. And try ping google from the routing device.

mokargas
Posts: 5
Joined: Sun Jun 23, 2013 6:08 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Wed Aug 12, 2015 9:32 pm

Teoma wrote:"cat /var/lib/dhcp/dhclient.leases" will show connected devices. As for it not sharing internet just make sure you follow the tutorial correctly, especially enabling forwarding and setting up the firewall correctly. And try ping google from the routing device.
Leases is empty, despite two devices reporting they are connected to the AP. I'll double check to see if I missed anything.

I did have to install a special version of hostapd which supports my wifi dongle. Maybe the issue is there.

mokargas
Posts: 5
Joined: Sun Jun 23, 2013 6:08 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Thu Aug 13, 2015 12:44 am

Ok, I've got it working. Thanks for your help!

I had to install the correct R8188EU driver for my version of Raspbian (3.18.11+) using this script https://dl.dropboxusercontent.com/u/802 ... 8188eu.tgz by @LaFambe (on the forum here: viewtopic.php?f=28&t=62371)

Then I had to set the date, which was stuck in 1970 for some reason (no matter how many times I ran raspi-config). To do this I used ntpdate.

For some reason, this is what enabled the internet-sharing part to work. I admit it was a guess, based on logs from the SYSLOG which was automatically releasing clients as soon as they connected. I assumed that meant the connections expired. Works great now.

Next part is to connect the MiLight wifi bridge to the AP, and start shooting UDP commands at it.

pangren
Posts: 42
Joined: Thu Dec 19, 2013 2:52 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Thu Aug 20, 2015 4:21 pm

Hi I've been trying to get this working. All is well until I tried

Code: Select all

sudo service hostapd start
It returned :

Code: Select all

[FAIL] Starting advanced IEEE 802.11 management: hostapd failed!
the other command works though.

Code: Select all

sudo service udhcpd start


Anyone has any idea what is happening? I'm using tp link TL WN821N dongle.

jayme
Posts: 1
Joined: Wed Sep 02, 2015 4:44 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Wed Sep 02, 2015 4:53 am

I have done everything I can think of following several forum posts.

When I run:

Code: Select all

sudo hostapd -d /etc/hostapd/hostapd.conf
I get the following:

Code: Select all

random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
Line 10: unknown configuration item 'wpa_passphrase_key'
Line 12: invalid cipher 'TPIK'.
WPA-PSK enabled, but PSK or passphrase is not configured.
3 errors found in configuration file '/etc/hostapd/hostapd.conf'
I see that this is an old post, but I have tried a lot of different things posted on different forums and started over. I am still stuck in the same spot.

Teoma
Posts: 7
Joined: Thu Aug 06, 2015 4:16 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Wed Sep 02, 2015 8:29 am

Code: Select all

Line 10: unknown configuration item 'wpa_passphrase_key'
Line 12: invalid cipher 'TPIK'.
just a spelling mistake in the config. They should be TKIP and wpa_passphrase

G109B
Posts: 21
Joined: Thu Sep 12, 2013 9:57 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Wed Oct 28, 2015 3:00 pm

It worked "straight out of the box" for me - raspiB+ running jessie, and solved at a stroke my requirement to connect to a stand-alone application with no web connectivity. Some observations:

1. I was forced into using a Realtek 8188A dongle with wheezy due to frequent dropouts and lockups. While this dongle is faultless, it does NOT work with hostapd and I have reverted to a Ralink 5730. (No problems so far).

2. There is a huge (unacceptable) performance/throughput hit if you choose to use a passphrase. Open mode is ok in the field, but I have to be careful on the bench where the eth0 interface has net connectivity.

Brilliant tutorial, many thanks.

G109B
Posts: 21
Joined: Thu Sep 12, 2013 9:57 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Sat Oct 31, 2015 7:14 pm

There are now lots of people reporting that hostapd and/or udhcpd do not start after boot-up, and I have had the same problem. Mostly the threads lead you in the right direction but fail to report the outcome.

Firstly I am running Raspian jessie which is different in some respects.
Secondly, I do not profess to be an expert.

So here are the things that gave me trouble:

1. The suggested setup in /etc/network/interfaces does not always result in the correct ip address being assigned, sometimes it gets set to some default value - check with ifconfig. Obviously this is not acceptable and I would welcome help in solving this one.

2. These 5370 dongles are not perfect, and it may be wise to have alternative ones to try (they do get very hot). Always use sudo halt, power-down, power-up, instead of sudo reboot to make sure they are starting from the same point every time.

3. The "update-rc.d" commands ending in "enable" should now use "defaults" instead of "enable".

4. Run the init.d scripts by hand to make sure they are ok before trying them at boot time.
("sudo /etc/init.d/hostapd start" and "sudo /etc/init.d/udhcpd start"). Do not rely on the 'stop' versions - see 7 below.

5. The udhcpd script first line "#! /bin/sh" should not have a space character in it.

6. "grep udhcpd /var/log/syslog" is very useful in debugging, and sometimes shows that udhcpd started before wlan0 was configured, which looks like a race condition. The effect is to delay the connection until way past the point at which the SSID is broadcast. (Fix anyone ?)

7. /usr/sbin/udhcpd is a sim-link to /bin/busybox which gives the service stop command a problem because it is looking for udhcpd instead of busybox. Only a problem if you try stop/start instead of re-boot.

8. I went back to apache2 to serve my web page because it just works whereas lighttpd is a beast to set up.

I have re-started it now several times, and it has come up each time and stayed up, so I am hopeful it might last.

bendylegs
Posts: 10
Joined: Tue Apr 28, 2015 10:19 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 7:16 pm

I had hostapd working under wheezy with a pi hut nl80211 usb stick but now under jessie when I manually run hostapd I get
nl80211: Could not configure driver mode
nl80211 driver initialization failed.
hostapd_free_hapd_data: Interface wlan0 wasn't started
any ideas?

G109B
Posts: 21
Joined: Thu Sep 12, 2013 9:57 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 7:55 pm

I put this in /etc/rc.local and have had no more trouble:

/sbin/ifdown wlan0
/sbin/ifup wlan0
/sbin/ifconfig wlan0 192.168.42.1

bendylegs
Posts: 10
Joined: Tue Apr 28, 2015 10:19 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 8:55 pm

Cheers, that helped. So did uninstalling wicd and network-manager.

bendylegs
Posts: 10
Joined: Tue Apr 28, 2015 10:19 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 10:34 pm

When I plug or unplug my wired ethernet into my pi it seems to kill my hotspot, ifconfig tells me the wlan0 has no ip, i have to bring it down, back up, assign an ip and manually restart hostapd before it comes back to life. Is this normal? How do I fix this?

G109B
Posts: 21
Joined: Thu Sep 12, 2013 9:57 am

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 10:48 pm

Sounds like the work of ifplugd, which I do not use.

bendylegs
Posts: 10
Joined: Tue Apr 28, 2015 10:19 pm

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 10:53 pm

Would sudo apt-get remove ifplugd help?

User avatar
DougieLawson
Posts: 32102
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: [Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Fri Nov 13, 2015 11:50 pm

bendylegs wrote:Would sudo apt-get remove ifplugd help?
That used to be the #1 recommendation for anyone trying to get an access point running.

Now you probably need to remove dhcpcd5 and raspberry-net-mods as well.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3B*3, 3B+

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 5 guests