frankv
Posts: 4
Joined: Wed Feb 05, 2014 4:44 am

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

Tue Feb 11, 2014 9:10 am

I have followed the wiki article (mostly **) and everything went well until the last step.... I have the same problem as thak above, so hoping someone will answer that. After a reboot I see

Code: Select all

pi@raspberrypi ~ $ sudo service hostapd status
[FAIL] hostapd is not running ... failed!
When I run

Code: Select all

pi@raspberrypi ~ $ sudo service hostapd start
[ ok ] Starting advanced IEEE 802.11 management: hostapd.
pi@raspberrypi ~ $ 
I can see my RPi on my phone's list of WiFi networks, so I know that at least that's working. However I can't connect to it. After several seconds showing "Connecting..." (and occassionally "Saved") I get a popup that says "Network disabled. Poor connection". I don't really believe it because there's an icon showing a strong connection, and my phone & RPi are side by side. I suspect it's really saying it can't get an IP address from the DHCP server. Setting up my phone with a static IP in the same subnet as the RPi does get a "Connected" status.

** Where I said "mostly" above, I meant that I left out the NAT steps in the tutorial. :? What I want to do is to have a publicly accessible server running on the RPi. So any nearby phone user can run an app, which will connect to a TCP port on the RPi. So I don't want any WiFi security, and I do want DHCP rather than a static IP for the phone. But also I don't want anyone coming in from the WiFi to be able to go through my RPi to the Ethernet connection & Internet. Hence I decided I didn't want to run NAT. Is this the right way to do that?

Frank

HopeItWorks
Posts: 19
Joined: Mon Feb 10, 2014 8:41 pm

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

Tue Feb 11, 2014 7:17 pm

Hii hope you folks can help me with some hotspot issues. My PI Edimax wlan0 should by default set as a dhcp client in an existing network. started by event the wlan0 will be set static, with a specific ip, hostapd and udhcp should be started.

i overwrite the /etc/network/interfaces by

Code: Select all

auto 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
gateway 10.0.0.1
followed by ifdown wlan0 && ifup wlan0
of cource the raspy accept this and ifconfig return:

Code: Select all

wlan0     Link encap:Ethernet  HWaddr 80:1f:02:af:11:78
          inet addr:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
the settings for /etc/hostapd/hostapd.conf are

Code: Select all

interface=wlan0
driver=rtl871xdrv
ssid=Raspi
channel=1
wmm_enabled=1
hw_mode=g
auth_algs=1
it is starting without any trouble.
The uDHCP Deamon hast this config:

Code: Select all


start   10.0.0.10
end     10.0.0.50
interface wlan0
opt     dns     10.0.0.1
option  subnet  255.255.255.0
opt     router  10.0.0.1
option  domain  local
opt     lease   864000
like Hostapd, udhcpd start without any error.

if i change the ip adress, starting the deamons i cant see the AP in the wifi settings of my iphone neither on my Win7 Laptop.
When i reboot the Raspi, it is still with the static ip 10.0.0.1. When i start now the hostapd and the udhcpd, i can find the wireless on all my devices and can connect.
Somebody had similar issues and could solve the problem? Thanks for any hint

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

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

Wed Feb 12, 2014 2:11 pm

thak wrote:I followed your tuto (and the one for edimax dongle) everything is fine except that i can't start hostapd and/or udhcpd on boot...
Which other tutorial did you follow? Other tutorials can use different programs, it's possible there was a conflict of some sort. The error messages you got look like hostapd and udhcpd aren't installed, what happens when you run:

Code: Select all

sudo hostapd /etc/hostapd/hostapd.conf
And then in another terminal window/virtual terminal/SSH session:

Code: Select all

sudo udhcpd -f /etc/udhcpd.conf
frankf wrote:I can see my RPi on my phone's list of WiFi networks, so I know that at least that's working. However I can't connect to it. After several seconds showing "Connecting..." (and occassionally "Saved") I get a popup that says "Network disabled. Poor connection". I don't really believe it because there's an icon showing a strong connection, and my phone & RPi are side by side. I suspect it's really saying it can't get an IP address from the DHCP server. Setting up my phone with a static IP in the same subnet as the RPi does get a "Connected" status.
It sounds like udhcpd isn't running, try the command:

Code: Select all

sudo udhcpd -f /etc/udhcpd.conf[code]
Assuming there are no error messages, see if you can connect. If so, there's some sort of issue preventing services from starting on boot properly, possibly a recent update to Raspbian changed some things.
[quote="frankf"]** Where I said "mostly" above, I meant that I left out the NAT steps in the tutorial. :? What I want to do is to have a publicly accessible server running on the RPi. So any nearby phone user can run an app, which will connect to a TCP port on the RPi. So I don't want any WiFi security, and I do want DHCP rather than a static IP for the phone. But also I don't want anyone coming in from the WiFi to be able to go through my RPi to the Ethernet connection & Internet. Hence I decided I didn't want to run NAT. Is this the right way to do that?[/quote]
Yep, that's the right way to set up a local-only network. 


[quote="HopeItWorks"]if i change the ip adress, starting the deamons i cant see the AP in the wifi settings of my iphone neither on my Win7 Laptop.
When i reboot the Raspi, it is still with the static ip 10.0.0.1. When i start now the hostapd and the udhcpd, i can find the wireless on all my devices and can connect.[/quote]
Which IP address are you changing? The one in udhcpd.conf? The Pi's wlan0 static IP?

HopeItWorks
Posts: 19
Joined: Mon Feb 10, 2014 8:41 pm

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

Wed Feb 12, 2014 5:20 pm

hunternet93 wrote:
HopeItWorks wrote:if i change the ip adress, starting the deamons i cant see the AP in the wifi settings of my iphone neither on my Win7 Laptop.
When i reboot the Raspi, it is still with the static ip 10.0.0.1. When i start now the hostapd and the udhcpd, i can find the wireless on all my devices and can connect.
Which IP address are you changing? The one in udhcpd.conf? The Pi's wlan0 static IP?
hi hunternet.
- if wlan0 is static with ip 10.0.0.1, udhcpd /hostapd will be up
- if wlan0 is dynamic on an ip from the local net at my home, it gets the ip of a dhcp of my router. its something 192.168. then udhcpd and hostapd is down.

i was investigate more today. monitoring the output of ifup /down. it seems that the device is not starting correctly because the new route is not written. ifup wlan0 -v drops an error directly after ip add route.

frankv
Posts: 4
Joined: Wed Feb 05, 2014 4:44 am

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

Wed Feb 12, 2014 5:34 pm

After a bit more experimenting, my RPi hot spot is now working as I want :)

I'm not entirely sure what I did that made it work... I think that maybe it was switching from the NOOBS distribution to the Raspbian image may have been the significant thing.... certainly, after installing an SDcard with that image, doing the update and upgrade stuff, then working through the tutorial (except step 4 = NAT), suddenly everything works, including starting hostapd and udhcpd at boot up. :D :D :D

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

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

Thu Feb 13, 2014 2:57 pm

HopeItWorks wrote:hi hunternet.
- if wlan0 is static with ip 10.0.0.1, udhcpd /hostapd will be up
- if wlan0 is dynamic on an ip from the local net at my home, it gets the ip of a dhcp of my router. its something 192.168. then udhcpd and hostapd is down.

i was investigate more today. monitoring the output of ifup /down. it seems that the device is not starting correctly because the new route is not written. ifup wlan0 -v drops an error directly after ip add route.
It sounds like you're trying to use your wireless card to both connect to an access point and act as an access point. Unfortunately, almost all wireless cards don't support this, they can only connect to an AP or be an AP. You can get around this by using two wireless cards, use one to connect to an AP and the other to provide the hotspot.

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

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

Thu Feb 13, 2014 2:59 pm

frankv wrote:After a bit more experimenting, my RPi hot spot is now working as I want :)

I'm not entirely sure what I did that made it work... I think that maybe it was switching from the NOOBS distribution to the Raspbian image may have been the significant thing.... certainly, after installing an SDcard with that image, doing the update and upgrade stuff, then working through the tutorial (except step 4 = NAT), suddenly everything works, including starting hostapd and udhcpd at boot up. :D :D :D
That's great! I haven't tested the tutorial with NOOBS, possibly it changes something or other which interferes with the tutorial.

HopeItWorks
Posts: 19
Joined: Mon Feb 10, 2014 8:41 pm

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

Thu Feb 13, 2014 4:53 pm

hunternet93 wrote:
HopeItWorks wrote:hi hunternet.
- if wlan0 is static with ip 10.0.0.1, udhcpd /hostapd will be up
- if wlan0 is dynamic on an ip from the local net at my home, it gets the ip of a dhcp of my router. its something 192.168. then udhcpd and hostapd is down.

i was investigate more today. monitoring the output of ifup /down. it seems that the device is not starting correctly because the new route is not written. ifup wlan0 -v drops an error directly after ip add route.
It sounds like you're trying to use your wireless card to both connect to an access point and act as an access point. Unfortunately, almost all wireless cards don't support this, they can only connect to an AP or be an AP. You can get around this by using two wireless cards, use one to connect to an AP and the other to provide the hotspot.
I dont want to connect to an AP and be an AP at the same time. The plan is to have the WIFI connected to different APs but if i am without a registered Wifi in my Area, i can put the Raspi to AP Mode so i can connect to it.

I have an idea which can be the problem. As a passive part of a WIFI the wlan0 is getting all information by a DHCP from outside. When i switch the wlan0 to AP mode, i have to give all static informations. Here is the problem with the route, thats why the wlan0 seems not to be up correctly. Ill check this, hand hope to found the bug in my config.

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

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

Fri Feb 14, 2014 12:20 am

HopeItWorks wrote:I dont want to connect to an AP and be an AP at the same time. The plan is to have the WIFI connected to different APs but if i am without a registered Wifi in my Area, i can put the Raspi to AP Mode so i can connect to it.

I have an idea which can be the problem. As a passive part of a WIFI the wlan0 is getting all information by a DHCP from outside. When i switch the wlan0 to AP mode, i have to give all static informations. Here is the problem with the route, thats why the wlan0 seems not to be up correctly. Ill check this, hand hope to found the bug in my config.
For the DHCP server to work correctly, wlan0 must have a static IP address. You can set the IP address manually with these commands:

Code: Select all

sudo ip addr flush dev wlan0
sudo  ip addr add dev wlan0 10.0.0.1/24
The '/24' on the end of the IP address is the subnet mask, it specified how large the subnet should be. In most cases (at least with small home/office networks) it will be 24.

HopeItWorks
Posts: 19
Joined: Mon Feb 10, 2014 8:41 pm

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

Fri Feb 14, 2014 9:34 am

hunternet93 wrote:

Code: Select all

sudo ip addr flush dev wlan0
sudo  ip addr add dev wlan0 10.0.0.1/24
The '/24' on the end of the IP address is the subnet mask, it specified how large the subnet should be. In most cases (at least with small home/office networks) it will be 24.
Hey hunternet93, the way you describe ist working. so the reason of the strange behaviour my lack of knowledge about routing and gateways. new things learned, problem solved. Thank you for helping

thak
Posts: 51
Joined: Wed Apr 10, 2013 6:22 pm

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

Sat Feb 15, 2014 9:23 am

Hi!

Sorry for the late reply...
So, i run again your tuto, when i said mostly i mean that i used the link on your wiki for edimax dongle only to get the hostpd custom file (with the right driver normaly...)

so now my hotspot shows up, but he can't give ipadresse to any device who trying to connect.

here the result of your command :

Code: Select all

pi@raspberrypi ~ $ sudo hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x515638
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
Using interface wlan0 with hwaddr 80:1f:02:c6:01:ce and ssid 'BearWifi'
rtl871x_set_wps_assoc_resp_ie
rtl871x_set_wps_beacon_ie
rtl871x_set_wps_probe_resp_ie
rtl871x_set_key_ops
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid_ops
ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument

Code: Select all

pi@raspberrypi ~ $ sudo udhcpd -f /etc/udhcpd.conf
udhcpd (v1.20.2) started
udhcpd: can't open '/var/lib/misc/udhcpd.leases': No such file or directory

thak
Posts: 51
Joined: Wed Apr 10, 2013 6:22 pm

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

Sat Feb 15, 2014 10:37 am

Ok so now everything work on boot after removing the "mathkernel" (wolfram-engine it seem)

But, still unable to provide an Ip adress to any device who trying to connect :/

thak
Posts: 51
Joined: Wed Apr 10, 2013 6:22 pm

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

Tue Feb 18, 2014 4:46 pm

Hi,

when I start manualy the udhcpd file, I can connect a device but without that nothing...
any idea on what could block udhcpd to start on boot ?

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)

Tue Feb 18, 2014 5:43 pm

Try this: remove default installed package "wolfram-engine" (mathkernel), unless you need it... This package can give problems when adding a daemon script for starting at startup. This package contains a faulty daemon script, which will prevent adding another daemon.
Execute:

Code: Select all

sudo apt-get remove -y wolfram-engine
It will also free up 429 Mb of disk space! :)

After this, I think you have to execute this again:

Code: Select all

sudo update-rc.d hostapd enable
sudo update-rc.d udhcpd enable
my Raspberry Pi page: http://raspberry.gerrelt.nl

thak
Posts: 51
Joined: Wed Apr 10, 2013 6:22 pm

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

Tue Feb 18, 2014 5:47 pm

I already removed it trought your tuto for the squeezebox bbc ^^

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)

Tue Feb 18, 2014 5:56 pm

:D :D Oh yeah...now I see.. :)
my Raspberry Pi page: http://raspberry.gerrelt.nl

thak
Posts: 51
Joined: Wed Apr 10, 2013 6:22 pm

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

Tue Feb 18, 2014 8:57 pm

Well...

I managed to make everything works with a little trick :)

I edit the /etc/rc.local file and add before "exit 0" those lines :

Code: Select all

sudo ifconfig wlan0 192.168.42.1
sudo service hostapd start
sudo service udhcpd start
And now i have my BBC squeezebox up and running :p

poing
Posts: 1131
Joined: Thu Mar 08, 2012 3:32 pm

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

Tue Feb 18, 2014 9:27 pm

thak wrote:Well...

I managed to make everything works with a little trick :)

I edit the /etc/rc.local file and add before "exit 0" those lines :

Code: Select all

sudo ifconfig wlan0 192.168.42.1
sudo service hostapd start
sudo service udhcpd start
And now i have my BBC squeezebox up and running :p
Not sure I follow :shock: /etc/rc.local is not edited in the tutorial...

thak
Posts: 51
Joined: Wed Apr 10, 2013 6:22 pm

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

Tue Feb 18, 2014 9:32 pm

Yep it's not...
But since the

Code: Select all

sudo update-rc.d udhcpd enable
Doesn't work for me... I used another way to make it work on boot :-)

Assassik
Posts: 1
Joined: Sat Apr 19, 2014 8:02 am

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

Sat Apr 19, 2014 8:31 am

I have problem with this tutotrial.

Everytime when i run sudo ifup wlan0 my iptables look like this:

Code: Select all

pi@raspbmc:~$ sudo iptables -vL
Chain INPUT (policy ACCEPT 30 packets, 2364 bytes)
 pkts bytes target     prot opt in     out     source               destination 
    7  1617 ACCEPT     all  --  wlan0  any     192.168.42.0/24      anywhere    
    0     0 DROP       all  --  wlan0  any     anywhere             anywhere    

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination 
    0     0 ACCEPT     all  --  eth0   wlan0   anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  wlan0  eth0    anywhere             anywhere    

Chain OUTPUT (policy ACCEPT 33 packets, 3905 bytes)
 pkts bytes target     prot opt in     out     source               destination 
"Chain INPUT" should be empty, but it's not. I tryed even add up iptables --flush into /etc/network/interfaces, but it's always added and i dont know where from.

I need always run sudo iptables --flush and then restore iptables from /etc/iptables.ipv4.nat after every "ifup" command.

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

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

Sun Apr 20, 2014 7:09 pm

Your distro, RaspbMC, apparently sets its own iptables rules on boot. I don't have an SD card with RaspbMC handy, but try:

Code: Select all

sudo update-rc.d iptables disable
This will stop the custom iptables rules from being loaded on boot. (This won't stop iptables itself from running, just the service that sets the default iptables rules.)
Assassik wrote:I have problem with this tutotrial.

Everytime when i run sudo ifup wlan0 my iptables look like this:

Code: Select all

pi@raspbmc:~$ sudo iptables -vL
Chain INPUT (policy ACCEPT 30 packets, 2364 bytes)
 pkts bytes target     prot opt in     out     source               destination 
    7  1617 ACCEPT     all  --  wlan0  any     192.168.42.0/24      anywhere    
    0     0 DROP       all  --  wlan0  any     anywhere             anywhere    

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination 
    0     0 ACCEPT     all  --  eth0   wlan0   anywhere             anywhere             state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  wlan0  eth0    anywhere             anywhere    

Chain OUTPUT (policy ACCEPT 33 packets, 3905 bytes)
 pkts bytes target     prot opt in     out     source               destination 
"Chain INPUT" should be empty, but it's not. I tryed even add up iptables --flush into /etc/network/interfaces, but it's always added and i dont know where from.

I need always run sudo iptables --flush and then restore iptables from /etc/iptables.ipv4.nat after every "ifup" command.

gmuller1234
Posts: 3
Joined: Tue Apr 29, 2014 3:52 pm

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

Tue Apr 29, 2014 4:02 pm

I followed this guide completely and I have a working wifi router :D ; but I'm having a problem using a VPN connection; I believe the root cause is that iptables is blocking the incoming VPN port (Port 1723). I however don't know how to unblock this port with iptables. I'm using a TP-Link TL-WDN3200 if that makes any difference.

Thanks,
gmuller1234

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

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

Wed Apr 30, 2014 1:02 am

gmuller1234 wrote:I followed this guide completely and I have a working wifi router :D ; but I'm having a problem using a VPN connection; I believe the root cause is that iptables is blocking the incoming VPN port (Port 1723). I however don't know how to unblock this port with iptables. I'm using a TP-Link TL-WDN3200 if that makes any difference.

Thanks,
gmuller1234
Please give me more details about your setup, are you hosting a VPN from the Pi or are you trying to connect to one? What VPN software are you using?

gmuller1234
Posts: 3
Joined: Tue Apr 29, 2014 3:52 pm

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

Wed Apr 30, 2014 2:04 am

In connecting from my computer to a VPN server, I'm just connecting with the windows 8 VPN client; like I said I belive that the the cause is iptables blocking the ports needed to establish the connection between my computer and the server

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

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

Thu May 01, 2014 1:17 am

gmuller1234 wrote:In connecting from my computer to a VPN server, I'm just connecting with the windows 8 VPN client; like I said I belive that the the cause is iptables blocking the ports needed to establish the connection between my computer and the server
I don't have a computer set up to test this right now, but try:

Code: Select all

sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT -p gre
This should enable forwarding GRE (generic routing encapsulation, an IP protocol used by PPTP), if it works then run:

Code: Select all

sudo iptables-save > /etc/iptables.ipv4.nat
This will save the changes.

Return to “Networking and servers”