maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Raspberry pi 4b creates hotspot that has no internet

Fri Oct 25, 2019 3:27 pm

Hello, I am a beginner at raspberry pi. However, I've crossed a huge problem. For the last month, I've been trying to set up raspberry pi's hotspot that has internet. However, it doesn't have one.

The raspberry pi creates an access point (hotspot) and I am able to connect to it from my laptop, however, there is no internet ( I am unable to visit any sites or do anything with that internet)

I've tried many different guides such as:
https://www.raspberrypi.org/documentati ... s-point.md
https://learn.sparkfun.com/tutorials/se ... -point/all#
and etc.
And none of them works.

My setup is :
Raspberry pi 4b
OS: raspbian buster
USB dongle: Huawei e3372

my raspberry pi's configs are:

Routes:
Capture1.PNG
Capture1.PNG (253.63 KiB) Viewed 920 times

dhcpcd.conf file:
```
interface wlan0
static ip_address=192.168.4.1/24
nohook wpa_supplicant
```

dnsmasq.conf file:
```
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
```

hostapd.conf file:
```
interface=wlan0
driver=nl80211
ssid=NameOfNetwork
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
```

Daemon Conf:
```
DAEMON_CONF="/etc/hostapd/hostapd.conf"
```

sysctl.conf file:
```
net.ipv4.ip_forward=1
```

iptables:
```
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
```
They are saved in:
```
/etc/ipatbles.ipv4.nat
```

I would appreciate any information regarding this topic.

Thanks in advance.

Edit note:
The raspberry pi itself has internet - it can ping to 8.8.8.8 without any problems. But the hotspot itself has no internet.
Last edited by maffy on Sat Oct 26, 2019 7:50 am, edited 1 time in total.

epoch1970
Posts: 3786
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Raspberry pi 4b creates hotspot that has no internet

Fri Oct 25, 2019 4:57 pm

Your ethernet (?) interface with the default gateway appears to be called eth1, not eth0.
Try

Code: Select all

sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel


maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Sat Oct 26, 2019 4:56 pm

All of the above suggestions are not working. The first IP table change to change for eth1 has no effect.

And the second answer has all the same things, that are happening in our case and is not able to provide any internet access

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Sun Oct 27, 2019 6:15 pm

Quick edit note: when I am using the second suggestion and typing the command - "hotspot try" I am getting an error - dhcp is waiting for ipaddr for wlan0. Can anyone suggest what is the problem here?

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Sat Nov 02, 2019 2:23 am

Does the wireless client have an ip adress? can it ping the raspberry?
issue a iptables -L -n so we can see the firewall config

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 7:42 pm

hello, thank you for the reply, here is the firewall photo:



12345.JPG
12345.JPG (33.18 KiB) Viewed 514 times

Sorry for the late reply.

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 7:55 pm

Have you enabled ip forwarding?
cat /proc/sys/net/ipv4/ip_forward

do a
netstat -M
as well

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 8:27 pm

yes, I have done that in, however i am getting this thing - here is a photo.
photo.JPG
photo.JPG (16.79 KiB) Viewed 493 times

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 8:34 pm

That's strange forwarding is enabled but it says no support for masquarading

Try
sudo iptables -t nat -L -n -v
Last edited by dorian-ny on Thu Nov 07, 2019 8:41 pm, edited 1 time in total.

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 8:40 pm

Any ideas, why this is happening?

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 8:41 pm

try
sudo iptables -t nat -L -n -v

You also don't seem to have a default route in dnsmasq.conf
add
domain=lan # Local wireless DNS domain
address=/gw.lan/192.168.4.1 #or whatever the wlan0 ip is
Last edited by dorian-ny on Thu Nov 07, 2019 8:54 pm, edited 2 times in total.

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 8:51 pm

Your previous edited post with something - echo 1 and etc helped me!

Could you re-edit that post and sent the whole text here, because maybe someone will use it in the future

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 8:58 pm

This enable ip_forwarding on boot: edit /etc/systctl.conf
uncommend line
#net.ipv4.ip_forward=1 (remove #)

echo 1 > /proc/sys/net/ipv4/ip_forward
This enables forwarding without reboot
readd iptables forwarding
sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Last edited by dorian-ny on Thu Nov 07, 2019 9:07 pm, edited 1 time in total.

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 9:01 pm

FYI any particular reason you are running the wifi in G mode?
perhaps you shoud update your hostapd conf to run N instead

change hw_mode=g to
hw_mode=a

and add
# N
ieee80211n=1

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 9:09 pm

I was just following the guide which showed me to write hw_mode = g. Is there a difference between g and a modes?

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 9:24 pm

maffy wrote:
Thu Nov 07, 2019 9:09 pm
I was just following the guide which showed me to write hw_mode = g. Is there a difference between g and a modes?
wifi g is very old and lmited to 56mbs
Any device made in the past 5 to 10 years should be fine with N
you can also enable N in 5ghz channels which will give you 300mbs (most devices made in the past 5 years will support 5ghz)
with
change
channel=7 to channel=40
# N
ieee80211n=1
require_ht=1
ht_capab=[MAX-AMSDU-3839][HT40-][SHORT-GI-20][SHORT-GI-40]

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Thu Nov 07, 2019 9:28 pm

Okay! Thank you for the incredible feedback and for your precious time. You've helped me a lot with this project.

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Fri Nov 08, 2019 11:23 am

]Additional question. I've came across one problem.

When I add this line in IP tables:

echo 1 > /proc/sys/net/ipv4/ip_forward

and

sudo iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

It works, however. I want to make my IP tables to go through tor.

I've found a guide - https://lifehacker.com/how-to-anonymize ... 1793869805

and when I add these lines -

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 22 -j REDIRECT --to-ports 22
sudo iptables -t nat -A PREROUTING -i wlan0 -p udp --dport 53 -j REDIRECT --to-ports 53
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --syn -j REDIRECT --to-ports 9040


Here are my IP tables and routes :
photo1111.JPG
photo1111.JPG (33.06 KiB) Viewed 346 times
The wifi stops working but has an access point. Any ideas on how I can fix this problem to work?
Attachments
photo1111.JPG
photo1111.JPG (33.06 KiB) Viewed 347 times

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Fri Nov 08, 2019 3:08 pm

First lest make sure tor is running properly.
Do a
sudo systemctl status tor
and
cat /var/log/tor/notices.log

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Fri Nov 08, 2019 4:15 pm

sudo systemctl shows that tor is active

ant here is cat log:
imp.JPG
imp.JPG (93.47 KiB) Viewed 313 times

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Fri Nov 08, 2019 10:17 pm

hmm there doesn't seem to be anything obviously wrong.
Lets see whats working and whats not.
From client (assuming windows) open cmd.exe
ping -n 2 192.168.4.1
ping -n 2 1.1.1.1
tracert -d 1.1.1.1
nslookup www.google.com

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Sat Nov 09, 2019 7:28 am

Here is a photo you requested.
requested.JPG
requested.JPG (88.42 KiB) Viewed 253 times

dorian-ny
Posts: 50
Joined: Fri Nov 01, 2019 11:29 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Sat Nov 09, 2019 2:17 pm

well that shows internet to be working so I assume you haven't started tor.
start tor and redo test

maffy
Posts: 14
Joined: Fri Oct 25, 2019 2:34 pm

Re: Raspberry pi 4b creates hotspot that has no internet

Sun Nov 10, 2019 6:58 pm

Tor is running :
12345567.JPG
12345567.JPG (42.15 KiB) Viewed 117 times

and routes and other things:


123456790.JPG
123456790.JPG (88.32 KiB) Viewed 117 times

Return to “Networking and servers”