0

Here's my "starting position": I have a Raspberry Pi 3b+, which is already configured, and I wanted to convert it into an Access Point. I followed this tutorial: https://pimylifeup.com/raspberry-pi-wireless-access-point/ and the access point is up and running. The ip-address-distribution also works, I set the range from 172.16.0.20 to 172.16.0.30 with 255.255.255.0 and a lease time of 12h.

My goal is to connect my smartphone to the access point of the raspberry and to be able to access a specific (internal?) website which can be resolved on Port 5000 (172.16.0.3:5000).

If the raspberry is connected to my laptop with a lan-cable (and the laptop has an ip-address in this range, it currently has 172.16.0.4 - I set it manually), I'm able to access the website with my laptop.

But when I'm connected with my smartphone, I do get an ip-address, but I can't connect to the website.

Why is that so? I'm getting the right ip-address, why am I not able to "call" this website?

In step 19, a command for creating an iptables-setting is described. I also added that iptables-command, although I don't even want a wifi connection. Is it possible, that this might be the mistake? How can I solve it?

This is the first time I'm working with a raspberry / iptables / access-points, so a (if possible) simple answer would be great!

If I have expressed myself inaccurately, notify me. I'll try to answer upcoming questions as good as possible.

  • "*I'm getting the right ip-address*" - what ip address is it? Can you ping it from the RasPi? How do you "call" the web site? Why do you set the ip address manually on the laptop? How is the RasPi connected to the internet? – Ingo Dec 21 '20 at 00:44
  • 1
    @Ingo 1) Well the IP on my phone is in the range I set in the /etc/dnsmasq.conf-file (172.16.0.20 - 172.16.0.30) 2) Haven't tried that yet, I'm currently not at home. 3) I get to the website (on my laptop) by typing "http://172.16.0.3:5000" in the browser. 4) I got told to do so on another forum, and it works like this. I'm gonna try to let dhcp to do the work as soon as I can. 5) I connected the raspberry itself with my router at home (sudo nmcli device wifi con "ssid" password "pw"). – Tobias Kastl Dec 21 '20 at 15:56
  • Thanks for the detailed answers point by point. That is rare and worth mentioning. You wrote to use `nmcli`. Network Manager isn't supported by a *Raspberry Pi OS*. What operating system do you use? – Ingo Dec 21 '20 at 16:18
  • @Ingo Well, thanks for asking such questions. Honestly, I'm close to having a mental breakdown. If I start the pi and start hostapd and dnsmasq, it's not even working. I have to restart / stop / start the services for about 15 minutes in order to get the hotspot and (especially) the ip-distribution to work. What exact commands do I need to execute in order to get everything up and running? Is there a specific order? Would it be possible to execute those commands automatically after the pi started? I think the pi runs on "GNU/Linux" (says "uname -o") – Tobias Kastl Dec 21 '20 at 18:24
  • @Ingo Are you sure that nmcli isn't supporting it? I can actually connect to any access point by using that command. "Device 'wlan0' successfully activated with '...'." I can scan wifis with "sudo nmcli dev wifi rescan" and show them with "sudo nmcli dev wifi list". – Tobias Kastl Dec 21 '20 at 18:30
  • I'm a bit confused. The pi is connected to my wifi over wlan0 (says "ip addr"). But when I try to change the interface (e.g. in /etc/dhcpcd.conf) from "wlan0" to "wlan1" (so they don't "cross" each other), hostapd is not working anymore. – Tobias Kastl Dec 21 '20 at 19:05
  • @Ingo Alright, I have some answers: 1) Tried to let dhcp do the work -> my phone and my laptop both got an ip-address from the range but couldn't resolve 172.16.0.3:5000. 2) I somehow can't ping those ip-addresses from the pi.. but if I connect my laptop with a lan-cable to the pi (and set an ip-address), it works.. – Tobias Kastl Dec 21 '20 at 19:39
  • Website may be hosting on a specific network adapter adapter. To rule this out, make sure you can access the website when both pi and the web client are connected to a wireless router. – Abel Dec 22 '20 at 12:35

1 Answers1

1

Sorry, but it is a bit confusing what you are doing. Even with answering my questions in comments I wasn't able to understand your setup.

  • The tutorial you have linked is from 2017 and uses Raspbian, which is deprecated and replaced by the Raspberry Pi OS. It is unclear what operating system you are current using. You may find it with cat /etc/os-release.
  • You are using nmcli, which is the Network Manager Commandline Interface. if you have installed Raspbian or the RaspiOS then the Network Manager isn't available/supported. These operating systems use dhcpcd by default for networking. If you do not installed and configured the Network Manager then you do not use Raspbian or RaspiOS. Maybe you are on Ubuntu?
  • You connected the Laptop to the ethernet port of the RasPi with an ethernet cable. This is not the way how the access point is intended to be used. The wired port is used as uplink to your internet router and expected that there is an internet connection to reach multiple different ip addresses. That's the reason why you need the iptables rule (NAT resp. masquerade). Connecting a Laptop instead of a router will confuse the routing on the RasPi.
  • In a comment you wrote:

I connected the raspberry itself with my router at home (sudo nmcli device wifi con "ssid" password "pw")

Because you have configured a wired uplink to the internet router it is not possible that the RasPi also connect by WiFi to the internet router. An access point cannot connect as client to a remote hotspot without special configuration with an additional virtual network interface. I don't believe that you have created and configured a virtual interface, e.g. ap0.

As you see there are still some things unclear. To have clear conditions and a defined starting point I suggest to start again with an up to date setup using Setting up a Raspberry Pi as an access point - the easy way.

Ingo
  • 40,606
  • 15
  • 76
  • 189
  • I chose the linked tutorial because it got recommended by another one (https://pimylifeup.com/raspberry-pi-captive-portal/). I'm doing all of this because I need to create a captive portal. I guess I'm going to try your linked tutorial (although it doesn't seem that easy as it says in the title - just by scrolling through it). But thanks for explaining. The cat-command says: "Raspbian GNU/Linux 10 (buster)", Version_ID = 10, ID_like = debian. Don't know if that helps. If you can't understand something because of my english, you can message me in german. – Tobias Kastl Dec 22 '20 at 20:08
  • As I mentioned, I received an already configured pi 3b+. I guess, that the network manager is already installed? Can't think of any other solution, because joining the wifi-hotspot worked and I could execute apt-get update and so on. | Every tutorial is about using the access point for a wifi connection, but I don't even need that. My goal is to join the AP, do some login-stuff on the captive portal and then be able to access 172.16.0.3:5000 (.0.3 is the ip of the pi btw). – Tobias Kastl Dec 22 '20 at 20:14