MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.88k stars 497 forks source link

Tor Hotspot misconfigured at installation? #5253

Closed vielka444 closed 1 year ago

vielka444 commented 2 years ago

Thanks for working on IPv6 support for hotspots @MichaIng

Testing using 8.1 I have successfully confirmed that the wifi hotspot feature works perfectly, but Tor hotspot doesnt seem to be configured correctly when installed and doesn't function on connected devices.

I have attached the log which I see at the end of installation:

Step: Install completed

[  OK  ] DietPi-Survey | Purging survey data[ SUB1 ] DietPi-Services > restart [FAILED] DietPi-Services | restart : isc-dhcp-server[  OK  ] DietPi-Services | restart : tor[  OK  ] DietPi-Services | restart : hostapd[  OK  ] DietPi-Services | restart : cronroot@pi:~# tor
Feb 07 23:27:36.042 [notice] Tor 0.4.5.10 running on Linux with Libevent 2.1.12-stable, OpenSSL 1.1.1k, Zlib 1.2.11, Liblzma 5.2.5, Libzstd 1.4.8 and Glibc 2.31 as libc.
Feb 07 23:27:36.045 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Feb 07 23:27:36.048 [notice] Read configuration file "/etc/tor/torrc".
Feb 07 23:27:36.077 [notice] You configured a non-loopback address '192.168.42.1:53' for DNSPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Feb 07 23:27:36.080 [notice] You configured a non-loopback address '192.168.42.1:9040' for TransPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Feb 07 23:27:36.109 [notice] You configured a non-loopback address '192.168.42.1:53' for DNSPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Feb 07 23:27:36.111 [notice] You configured a non-loopback address '192.168.42.1:9040' for TransPort. This allows everybody on your local network to use your machine as a proxy. Make sure this is what you wanted.
Feb 07 23:27:36.115 [notice] Opening Socks listener on 127.0.0.1:9050
Feb 07 23:27:36.117 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Feb 07 23:27:36.117 [notice] Opening DNS listener on 192.168.42.1:53
Feb 07 23:27:36.119 [notice] Opened DNS listener connection (ready) on 192.168.42.1:53
Feb 07 23:27:36.121 [notice] Opening Transparent pf/netfilter listener on 192.168.42.1:9040
Feb 07 23:27:36.121 [warn] Could not bind to 192.168.42.1:9040: Address already in use. Is Tor already running?
Feb 07 23:27:36.122 [notice] Closing partially-constructed DNS listener connection (ready) on 192.168.42.1:53
Feb 07 23:27:36.125 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Feb 07 23:27:36.127 [err] Reading config failed--see warnings above.
MichaIng commented 2 years ago

It seems an instance of Tor is already running. Please check htop and systemctl status tor. If the first shows a Tor instance but the second shows to be not active/running, then systemctl stop tor does not seem to stop the process as expected.

vielka444 commented 2 years ago

Thanks @MichaIng

I started with a fresh DietPi_RPi-ARMv7-Bullseye image and chose Tor hotspot and selected install. The following is the log output:

DietPi-Software                                                                                                                                              
─────────────────────────────────────────────────────                                                                                                         
 Step: Installing WiFi Hotspot: turn your device into a wifi hotspot                                                                                          
                                                                                                                                                              
[ INFO ] DietPi-Software | APT install for: hostapd isc-dhcp-server iptables libnl-3-200, please wait...debconf: delaying package configuration, since apt-utils is not installed                                                                                     
Selecting previously unselected package hostapd.
(Reading database ... 22339 files and directories currently installed.)
Preparing to unpack .../0-hostapd_2%3a2.9.0-21_armhf.deb ...
Unpacking hostapd (2:2.9.0-21) ...
Selecting previously unselected package netbase.
Preparing to unpack .../1-netbase_6.3_all.deb ...
Unpacking netbase (6.3) ...
Selecting previously unselected package libip6tc2:armhf.
Preparing to unpack .../2-libip6tc2_1.8.7-1_armhf.deb ...
Unpacking libip6tc2:armhf (1.8.7-1) ...
Selecting previously unselected package libnfnetlink0:armhf.
Preparing to unpack .../3-libnfnetlink0_1.0.1-3+b1_armhf.deb ...
Unpacking libnfnetlink0:armhf (1.0.1-3+b1) ...
Selecting previously unselected package libnetfilter-conntrack3:armhf.
Preparing to unpack .../4-libnetfilter-conntrack3_1.0.8-3_armhf.deb ...
Unpacking libnetfilter-conntrack3:armhf (1.0.8-3) ...
Selecting previously unselected package libnftnl11:armhf.
Preparing to unpack .../5-libnftnl11_1.1.9-1_armhf.deb ...
Unpacking libnftnl11:armhf (1.1.9-1) ...
Selecting previously unselected package iptables.
Preparing to unpack .../6-iptables_1.8.7-1_armhf.deb ...
Unpacking iptables (1.8.7-1) ...
Selecting previously unselected package libisccfg-export163.
Preparing to unpack .../7-libisccfg-export163_1%3a9.11.19+dfsg-2.1_armhf.deb ...
Unpacking libisccfg-export163 (1:9.11.19+dfsg-2.1) ...
Selecting previously unselected package libirs-export161.
Preparing to unpack .../8-libirs-export161_1%3a9.11.19+dfsg-2.1_armhf.deb ...
Unpacking libirs-export161 (1:9.11.19+dfsg-2.1) ...
Selecting previously unselected package isc-dhcp-server.
Preparing to unpack .../9-isc-dhcp-server_4.4.1-2.3_armhf.deb ...
Unpacking isc-dhcp-server (4.4.1-2.3) ...
Setting up libip6tc2:armhf (1.8.7-1) ...
Setting up libnftnl11:armhf (1.1.9-1) ...
Setting up hostapd (2:2.9.0-21) ...
Created symlink /etc/systemd/system/multi-user.target.wants/hostapd.service → /lib/systemd/system/hostapd.service.
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.
Created symlink /etc/systemd/system/hostapd.service → /dev/null.
Setting up libisccfg-export163 (1:9.11.19+dfsg-2.1) ...
Setting up libnfnetlink0:armhf (1.0.1-3+b1) ...
Setting up netbase (6.3) ...
Setting up libirs-export161 (1:9.11.19+dfsg-2.1) ...
Setting up isc-dhcp-server (4.4.1-2.3) ...
Generating /etc/default/isc-dhcp-server...
Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
invoke-rc.d: initscript isc-dhcp-server, action "start" failed.
● isc-dhcp-server.service - LSB: DHCP server
     Loaded: loaded (/etc/init.d/isc-dhcp-server; generated)
     Active: failed (Result: exit-code) since Fri 2022-02-11 14:44:42 GMT; 60ms ago
       Docs: man:systemd-sysv-generator(8)
    Process: 4334 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)
        CPU: 214ms

Feb 11 14:44:40 DietPi dhcpd[4349]: before submitting a bug.  These pages explain the proper
Feb 11 14:44:40 DietPi dhcpd[4349]: process and the information we find helpful for debugging.
Feb 11 14:44:40 DietPi dhcpd[4349]: 
Feb 11 14:44:40 DietPi dhcpd[4349]: exiting.
Feb 11 14:44:42 DietPi isc-dhcp-server[4334]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ...
Feb 11 14:44:42 DietPi isc-dhcp-server[4354]:  failed!
Feb 11 14:44:42 DietPi isc-dhcp-server[4355]:  failed!
Feb 11 14:44:42 DietPi systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Feb 11 14:44:42 DietPi systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Feb 11 14:44:42 DietPi systemd[1]: Failed to start LSB: DHCP server.
Setting up libnetfilter-conntrack3:armhf (1.0.8-3) ...
Setting up iptables (1.8.7-1) ...
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/iptables-nft to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-nft to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/arptables-nft to provide /usr/sbin/arptables (arptables) in auto mode
update-alternatives: using /usr/sbin/ebtables-nft to provide /usr/sbin/ebtables (ebtables) in auto mode
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u2) ...
[  OK  ] DietPi-Software | APT install for: hostapd isc-dhcp-server iptables libnl-3-200
[  OK  ] DietPi-Software | systemctl stop hostapd isc-dhcp-server[  OK  ] DietPi-Software | update-alternatives --set iptables /usr/sbin/iptables-legacy[  OK  ] DietPi-Software | update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy[  OK  ] DietPi-Software | systemctl unmask hostapd[ SUB1 ] DietPi-Set_hardware > wifimodules (enable)[ INFO ] DietPi-Set_hardware | Please wait, enabling WiFi modules...[ INFO ] DietPi-Set_hardware | Checking for required APT packages: iw wireless-tools crda wpasupplicant[  OK  ] wifimodules enable | Completed[  OK  ] DietPi-Software | /etc/dhcp/dhcpd.conf: backup to /etc/dhcp/dhcpd.conf.bak_110222_0[ INFO ] DietPi-Software | For a full list of backup items, please see /var/tmp/dietpi/logs/G_BACKUP_FP.db[  OK  ] DietPi-Software | sed -Ei /(allow-hotplug|auto)[[:blank:]]+wlan/q0 /etc/network/interfaces[  OK  ] DietPi-Software | Comment in /etc/network/interfaces converted to setting: allow-hotplug wlan1
[  OK  ] DietPi-Software | ip a add 192.168.42.1 dev wlan1[  OK  ] DietPi-Software | chmod 0600 /etc/hostapd/hostapd.conf[  OK  ] DietPi-Software | Added setting ieee80211n=1 to end of file /etc/hostapd/hostapd.conf
net.ipv4.ip_forward = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.forwarding = 1
iptables v1.8.7 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
iptables v1.8.7 (legacy): Couldn't load match `state':No such file or directory

Try `iptables -h' or 'iptables --help' for more information.
iptables v1.8.7 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `nat': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Installing Tor Hotspot: optional: route hotspot traffic through tor

[ INFO ] DietPi-Software | APT install for: tor, please wait...debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libevent-2.1-7:armhf.
(Reading database ... 22634 files and directories currently installed.)
Preparing to unpack .../libevent-2.1-7_2.1.12-stable-1_armhf.deb ...
Unpacking libevent-2.1-7:armhf (2.1.12-stable-1) ...
Selecting previously unselected package runit-helper.
Preparing to unpack .../runit-helper_2.10.3_all.deb ...
Unpacking runit-helper (2.10.3) ...
Selecting previously unselected package tor.
Preparing to unpack .../tor_0.4.5.10-1~deb11u1_armhf.deb ...
Unpacking tor (0.4.5.10-1~deb11u1) ...
Setting up runit-helper (2.10.3) ...
Setting up libevent-2.1-7:armhf (2.1.12-stable-1) ...
Setting up tor (0.4.5.10-1~deb11u1) ...
Something or somebody made /var/lib/tor disappear.
Creating one for you again.
Something or somebody made /var/log/tor disappear.
Creating one for you again.
Created symlink /etc/systemd/system/multi-user.target.wants/tor.service → /lib/systemd/system/tor.service.
Processing triggers for libc-bin (2.31-13+rpt2+rpi1+deb11u2) ...
[  OK  ] DietPi-Software | APT install for: tor
[  OK  ] DietPi-Software | systemctl stop tor[ INFO ] DietPi-Software | Removing obsolete SysV tor service[  OK  ] DietPi-Software | rm /etc/init.d/tor[  OK  ] DietPi-Software | update-rc.d tor remove[  OK  ] DietPi-Software | rm /etc/default/toriptables v1.8.7 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
iptables v1.8.7 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `filter': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `nat': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
iptables v1.8.7 (legacy): unknown option "--dport"
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.8.7 (legacy): unknown option "--dport"
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.8.7 (legacy): unknown option "--syn"
Try `iptables -h' or 'iptables --help' for more information.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `nat': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `nat': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.
modprobe: FATAL: Module ip6_tables not found in directory /lib/modules/5.10.63-v7+
ip6tables v1.8.7 (legacy): can't initialize ip6tables table `nat': Table does not exist (do you need to insmod?)
Perhaps ip6tables or your kernel needs to be upgraded.

 DietPi-Software
─────────────────────────────────────────────────────
 Step: Finalising install

[  OK  ] DietPi-Software | systemctl daemon-reload2022-02-11 14:46:05 [ INFO ] DietPi-RAMlog | Storing /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store...
2022-02-11 14:46:05 [  OK  ] DietPi-RAMlog | Stored /var/log to /var/tmp/dietpi/logs/dietpi-ramlog_store.
[ SUB1 ] DietPi-Services > dietpi_controlled [  OK  ] DietPi-Services | dietpi_controlled : isc-dhcp-server[  OK  ] DietPi-Services | dietpi_controlled : tor[  OK  ] DietPi-Services | dietpi_controlled : hostapd[  OK  ] DietPi-Services | dietpi_controlled : cron
 DietPi-Software
─────────────────────────────────────────────────────
 Step: Applying final first run setup steps

[  OK  ] DietPi-AutoStart | systemctl daemon-reload[  OK  ] DietPi-Software | Applied final first run setup steps
 DietPi-Software
─────────────────────────────────────────────────────
 Step: Install completed

[  OK  ] DietPi-Survey | Purging survey data[ SUB1 ] DietPi-Services > restart [FAILED] DietPi-Services | restart : isc-dhcp-server[  OK  ] DietPi-Services | restart : tor[FAILED] DietPi-Services | restart : hostapd[  OK  ] DietPi-Services | restart : cron
MichaIng commented 2 years ago

You need to reboot as your kernel has been upgraded and the iptables kernel module can hence not be loaded. We're working on a better handling of such case: https://github.com/MichaIng/DietPi/issues/4959#issuecomment-1033941896

vielka444 commented 2 years ago

Thanks again @MichaIng. I should have noted my next step was to reboot. HW_Model:3 | HW_Arch 2 | Distro: 6

After rebooting I entered dietpi-config and set the country code, and enabled the USB wifi dongle, set a name and passkey for the wifi then restarted again.

System status tor = active (exited) htop = showing 1 instance of /usr/bin/tor. Hostapd appears and vanishes after 1 second every so often.

I'm not seeing the hotspot on other devices wifi networks to connect to.

Dietpi-config > Network Options: Adapters > Wifi Available [On] Status: Offline State: [Disabled] | Select to turn on hotspot

Dietpi-config > Network Options: Adapters > Onboard Wifi [Off] Dietpi-config > Network Options: Adapters > IPv6 [On] Dietpi-config > Network Options: Adapters > Test = [Success] Online

When I then went to the following to enable the hotspot, it failed with an error: Dietpi-config > Network Options: Adapters > Wifi Available [On] > State: [Disabled] | Select to turn on hotspot

Job for hostapd.service failed because the control process exited with error code.                                   │ 
│ See "systemctl status hostapd.service" and "journalctl -xe" for details. 
:~# systemctl status hostapd.service
● hostapd.service - Access point and authentication server for Wi-Fi and Ethernet                                                                             
     Loaded: loaded (/lib/systemd/system/hostapd.service; disabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Fri 2022-02-11 16:33:08 GMT; 835ms ago
       Docs: man:hostapd(8)
    Process: 4722 ExecStart=/usr/sbin/hostapd -B -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=1/FAILURE)
        CPU: 29ms
MichaIng commented 2 years ago

What does the following show:

journalctl -u hostapd
vielka444 commented 2 years ago
Feb 11 16:40:42 DietPi systemd[1]: hostapd.service: Scheduled restart job, restart counter is at 109.
Feb 11 16:40:42 DietPi systemd[1]: Stopped Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:40:42 DietPi systemd[1]: Starting Access point and authentication server for Wi-Fi and Ethernet...
Feb 11 16:40:42 DietPi hostapd[1772]: Configuration file: /etc/hostapd/hostapd.conf
Feb 11 16:40:42 DietPi hostapd[1772]: Could not read interface wlan1 flags: No such device
Feb 11 16:40:42 DietPi hostapd[1772]: nl80211: Driver does not support authentication/association or connect commands
Feb 11 16:40:42 DietPi hostapd[1772]: nl80211: deinit ifname=wlan1 disabled_11b_rates=0
Feb 11 16:40:42 DietPi hostapd[1772]: Could not read interface wlan1 flags: No such device
Feb 11 16:40:42 DietPi hostapd[1772]: nl80211 driver initialization failed.
Feb 11 16:40:42 DietPi hostapd[1772]: wlan1: interface state UNINITIALIZED->DISABLED
Feb 11 16:40:42 DietPi hostapd[1772]: wlan1: AP-DISABLED
Feb 11 16:40:42 DietPi hostapd[1772]: wlan1: CTRL-EVENT-TERMINATING
Feb 11 16:40:42 DietPi hostapd[1772]: hostapd_free_hapd_data: Interface wlan1 wasn't started
Feb 11 16:40:42 DietPi systemd[1]: hostapd.service: Control process exited, code=exited, status=1/FAILURE
Feb 11 16:40:42 DietPi systemd[1]: hostapd.service: Failed with result 'exit-code'.
Feb 11 16:40:42 DietPi systemd[1]: Failed to start Access point and authentication server for Wi-Fi and Ethernet.
vielka444 commented 2 years ago

I have another wifi adaptor (or two or three) to try, if that helps. I was able to create the vanilla wifi hotspot without issue using this adaptor perviously. Only this time I'm trying with HW_Model:3 instead of a Pi1.

Thinking out loud, i'm wondering if it is a power issue. I'll remove the minimum overclock I added and keep the same wifi dongle attached.

vielka444 commented 2 years ago

Removing the overclock didnt make any difference.

Now trying another power supply, just incase.

MichaIng commented 2 years ago

Could not read interface wlan1 flags: No such device

Hmm it seems during install G_GET_NET -t wlan iface returned wlan1, which would be the case when there was another, e.g. internal WiFi adapter while an external adapter was configured before. When you disabled onboard WiFi, then rebooted, the original wlan0 internal adapter gets removed and the external one becomes wlan0, i.e. wlan1 does not exist anymore. Please try:

sed -i 's/wlan1/wlan0/g' /etc/hostapd/hostapd.conf /etc/iptables.ipv4.nat /etc/iptables.ipv6.nat /etc/network/interfaces /etc/default/isc-dhcp-server
ifdown wlan0
ifup wlan0
systemctl restart hostapd
sleep 3
journalctl -u hostapd
vielka444 commented 2 years ago

That worked! Thank you @MichaIng. I see the network show up on other devices. I will confirm if the hotspot connects and if the Tor feature now works with these changes. It will take me a while to complete those steps, but I will update here.

Thank you for your continued help and work on the project, it is a fun hobby and I learn new things helping to debug issues as I play with the software provided via DietPi.

Feb 11 16:57:59 DietPi systemd[1]: hostapd.service: Control process exited, code=exited, status=1/FAILURE
Feb 11 16:57:59 DietPi systemd[1]: hostapd.service: Failed with result 'exit-code'.
Feb 11 16:57:59 DietPi systemd[1]: Failed to start Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:58:01 DietPi systemd[1]: hostapd.service: Scheduled restart job, restart counter is at 18.
Feb 11 16:58:01 DietPi systemd[1]: Stopped Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:58:01 DietPi systemd[1]: Starting Access point and authentication server for Wi-Fi and Ethernet...
Feb 11 16:58:01 DietPi hostapd[832]: Configuration file: /etc/hostapd/hostapd.conf
Feb 11 16:58:02 DietPi hostapd[832]: Using interface wlan0 with hwaddr xxx and ssid "wifi"
Feb 11 16:58:02 DietPi hostapd[832]: wlan0: interface state UNINITIALIZED->ENABLED
Feb 11 16:58:02 DietPi hostapd[832]: wlan0: AP-ENABLED
Feb 11 16:58:02 DietPi systemd[1]: hostapd.service: Succeeded.
Feb 11 16:58:02 DietPi systemd[1]: Stopped Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:58:02 DietPi systemd[1]: Starting Access point and authentication server for Wi-Fi and Ethernet...
Feb 11 16:58:02 DietPi hostapd[882]: Configuration file: /etc/hostapd/hostapd.conf
Feb 11 16:58:02 DietPi hostapd[882]: Using interface wlan0 with hwaddr xxx and ssid "wifi"
Feb 11 16:58:02 DietPi hostapd[882]: wlan0: interface state UNINITIALIZED->ENABLED
Feb 11 16:58:02 DietPi hostapd[882]: wlan0: AP-ENABLED
Feb 11 16:58:02 DietPi systemd[1]: Started Access point and authentication server for Wi-Fi and Ethernet.Feb 11 16:57:59 DietPi systemd[1]: hostapd.service: Control process exited, code=exited, status=1/FAILURE
Feb 11 16:57:59 DietPi systemd[1]: hostapd.service: Failed with result 'exit-code'.
Feb 11 16:57:59 DietPi systemd[1]: Failed to start Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:58:01 DietPi systemd[1]: hostapd.service: Scheduled restart job, restart counter is at 18.
Feb 11 16:58:01 DietPi systemd[1]: Stopped Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:58:01 DietPi systemd[1]: Starting Access point and authentication server for Wi-Fi and Ethernet...
Feb 11 16:58:01 DietPi hostapd[832]: Configuration file: /etc/hostapd/hostapd.conf
Feb 11 16:58:02 DietPi hostapd[832]: Using interface wlan0 with hwaddr xxx and ssid "wifi"
Feb 11 16:58:02 DietPi hostapd[832]: wlan0: interface state UNINITIALIZED->ENABLED
Feb 11 16:58:02 DietPi hostapd[832]: wlan0: AP-ENABLED
Feb 11 16:58:02 DietPi systemd[1]: hostapd.service: Succeeded.
Feb 11 16:58:02 DietPi systemd[1]: Stopped Access point and authentication server for Wi-Fi and Ethernet.
Feb 11 16:58:02 DietPi systemd[1]: Starting Access point and authentication server for Wi-Fi and Ethernet...
Feb 11 16:58:02 DietPi hostapd[882]: Configuration file: /etc/hostapd/hostapd.conf
Feb 11 16:58:02 DietPi hostapd[882]: Using interface wlan0 with hwaddr xxx and ssid "wifi"
Feb 11 16:58:02 DietPi hostapd[882]: wlan0: interface state UNINITIALIZED->ENABLED
Feb 11 16:58:02 DietPi hostapd[882]: wlan0: AP-ENABLED
Feb 11 16:58:02 DietPi systemd[1]: Started Access point and authentication server for Wi-Fi and Ethernet.
vielka444 commented 2 years ago

Hi again @MichaIng,

I connected to the Tor Hotspot using another device, but there was no internet access on the connected device.

What can I do to help? I am able to test connecting with another Pi with DietPi installed on it

MichaIng commented 2 years ago

Does it work when you connect to an IPv4 host explicitly? Also please paste:

cat /etc/iptables.ipv4.nat /etc/iptables.ipv6.nat
journalctl -u tor
vielka444 commented 2 years ago

I will test with IPv4, I know how to set both the hotspot and connecting device to IPV4 in Dietpi-config, is this what you mean, or can you suggest a host to test and I keep both set to IPv6?

Should I run this command on the hotspot or connected device?

MichaIng commented 2 years ago

Just curl -I4 https://dietpi.com/ on the client 😉.

vielka444 commented 2 years ago

curl: (6) Could not resolve host https://dietpi.com/

I tried turning off IPv6 on the hotspot and client DietPi installations to see if IPv4 worked via the connection test, but it didnt.

MichaIng commented 2 years ago

Can you show the output of the commands mentioned above: https://github.com/MichaIng/DietPi/issues/5253#issuecomment-1036582729

Also, while I think Internet access doesn't work in general, please verify that by trying to ping some plain IPs from the client:

ping 1.1.1.1
ping 9.9.9.9
vielka444 commented 2 years ago

Sorry for the delayed response on this @MichaIng

For both of the following the reply was the same as listed below.

ping 1.1.1.1 ping 9.9.9.9

ping: connect: Network is unreachable

MichaIng commented 2 years ago

Do the clients have default route set to the Tor Hotspot host?

ip r l default
ip -6 r l default
vielka444 commented 2 years ago

@MichaIng I typed the commands to set the default route you suggested and tried ping again with the same response: “Ping: connect: Network is unreachable”

MichaIng commented 2 years ago

These are not to "set" the default route, but to "list" the default routes. Did they give any output?

vielka444 commented 2 years ago

@MichaIng oh right, no output from either.

MichaIng commented 2 years ago

Then there is no default route defined at all. Can you verify that this client has successfully connected to the DietPi hostspot and received an IP address via DHCP? If this is a DietPi system, then the following should give some logs:

journalctl -t ifup -t dhclient -t wpa_supplicant
armstrys commented 2 years ago

I was running into this issue as well and the fix for wlan0/1 combined with changing my country code seems to have fixed the issue.

MichaIng commented 2 years ago

@armstrys As well, you have an RPi with internal WiFi but use an external WiFi card? The country code is applied now during WiFi Hotspot installation already, but the interface naming change has not been addressed yet. Actually this is an argument to switch to "predictable" network interface naming, like wlp1s1 instead of wlan0. Not as simple/beautiful, but the first ones do not change regardless which other network adapters are attached/enabled and in which order the system detects them.

armstrys commented 2 years ago

I don’t have a WiFi adapter on mine. Just a stock Pi 3B+ running in the US. All I had plugged into it is the ethernet connection. Let me know if you have any other ideas or ways I can help debug!

MichaIng commented 2 years ago

Then it's indeed strange that the WiFi adapter was detected as interface wlan1 at any time 🤔. So now it's wlan0 and the only detected WiFi interface, right?

ip l
G_GET_NET -t wlan iface
armstrys commented 2 years ago

Yes wlan0 is now the only wlan interface showing. Tailscale was installed after I got the hotspot working.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
4: tailscale0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1280 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 500
    link/none 

Edit: should add that I wasn’t able to get the G_GET_NET command to run. I may need to run as sudo (?) but I am remote right now and will have to try that later.

MichaIng commented 2 years ago

This command shouldn't require root permissions 🤔. It's a bash function, loaded into interactive bash shells. Probably you use a different login shell than bash?

armstrys commented 2 years ago

Ahh that could be it. I’m running these commands over SSH using ServerCat on my phone right now. Looks like it is trying to run as bash, but I do run zsh at home. I will have to try this again in a couple days when I’m home.

MichaIng commented 2 years ago

It's not so important, it does not much more than printing the first WiFi interface found, preferably the one with a default route assigned > IP address assigned > set to up. Would be mainly interesting to assure the right one is shown, but now it is practically impossible that it shows wlan1 and I think it's not worth the trouble to reflash a new image and retest with first boot.

vielka444 commented 2 years ago

I think it's not worth the trouble to reflash a new image and retest with first boot

Just wondering if I should test Tor Hotspot again in the next few days, with a fresh hotspot and client installs on 2 separate Raspberry Pi @MichaIng?

Thanks

MichaIng commented 1 year ago

If you find time, that would be great. Reading again through the thread, the client wasn't receiving a default route/gateway, which should have been passed by the WiFi hotspot's DHCP server for IPv4, and by the router for IPv6 (if enabled at all).

The missing kernel module issue has been solved in the meantime, as dietpi-software now forces one to do a reboot after kernel upgrades (resp. if no matching kernel modules are present) before software installs can be done.

MichaIng commented 1 year ago

Marking as closed for now. Feel free to reopen when you find time to test again.