hotspot icon indicating copy to clipboard operation
hotspot copied to clipboard

cannot connect to apache2 server and access to .local back to station mode

Open jasonyhwang opened this issue 2 years ago • 4 comments

Hi, I tried to use this script and it works great! Only thing I cannot resolve now is that once I started ap mode, I can login to my Raspberry Pi Zero with my hostname (raspberrypi.local), and also to my website with IP address. However, when I switched back to station mode, I noticed both of these cannot work. I can only log in to my rpi with ip address, which might not be a big deal, but more the problem I have is I lost my website access. Typed in the ip address like usual but would have below not able to reached error message only.

This site can’t be reached 192.168.1.xxx refused to connect.

Below is what I did to setup hotspot, please kindly see if there's something I can do to allow website access can also work on both modes. Thanks a lot!

$ hotspot modpar self aptaddinstlist "" $ hotspot setup $ hotspot modpar hostapd ssid xxx $ hotspot modpar hostapd wpa_passphrase xxx $ hotspot modpar hostapd country_code xx $ hotspot modpar crda REGDOMAIN xx $ hotspot start $ hotspot stop

jasonyhwang avatar May 02 '22 15:05 jasonyhwang

this is strange, because you can log in with ssh access to 192.168.1.xxx ? website is not answering on 192.168.1.xxx ? can you restart the webserver an try again to access on 192.168.1.xxx

what does "ip a" on cli say?

rudiratlos avatar May 03 '22 13:05 rudiratlos

restart the webserver (apache2) did not help... and reboot also did not help I had my luck to found what was that as I stopped firewall service, all the sudden I can connect to my raspberry pi webserver. I compared the difference on the firewall settings with "sudo firewall-cmd --list-all", and the difference seems to be "interface: wlan0" went missing in station mode, and masquerade is "no" in station mode. Not sure which one is the reason but I guess I can live without firewall for now. Thanks!

Station mode: public target: default icmp-block-inversion: no interfaces: services: dhcpv6-client ssh forward: no masquerade: no

AP mode: public (active) target: default icmp-block-inversion: no interfaces: wlan0 services: dhcpv6-client ssh forward: no masquerade: yes

jasonyhwang avatar May 03 '22 14:05 jasonyhwang

I think you have to add firewall rule with service http/https to public zone

rudiratlos avatar May 03 '22 15:05 rudiratlos

this is the firewall-cmd to open ports for webserver on zone public: firewall-cmd --permanent --zone=public --add-service=http --add-service=https

rudiratlos avatar May 04 '22 12:05 rudiratlos