mattlongman / Hassio-Access-Point

Hass.io addon to let you create a WiFi access point, perfect for using WiFi devices on off-grid installations.
MIT License
81 stars 62 forks source link

Client not get Internet Access #11

Closed hellresistor closed 1 year ago

hellresistor commented 2 years ago

Client cannot get internet

HA Addon LOG:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Starting Hass.io Access Point Addon
# Setup interface:
Add to /etc/network/interfaces: iface wlan0 inet static
Run command: nmcli dev set wlan0 managed no
Run command: ip link set wlan0 down
Add to /etc/network/interfaces: address 192.168.99.1
Add to /etc/network/interfaces: netmask 255.255.255.0
Add to /etc/network/interfaces: broadcast 192.168.99.255
Run command: ip link set wlan0 up
# Setup hostapd:
Add to hostapd.conf: ssid=Myspot
Add to hostapd.conf: wpa_passphrase=********
Add to hostapd.conf: channel=6
Add to hostapd.conf: ignore_broadcast_ssid=0
Add to hostapd.conf: macaddr_acl=0
Add to hostapd.conf: interface=wlan0
# DHCP enabled. Setup dnsmasq:
Add to dnsmasq.conf: dhcp-range=192.168.99.10,192.168.99.20,12h
Add to dnsmasq.conf: interface=wlan0
Add custom DNS: dhcp-option=6,8.8.4.4,8.8.8.8
## Starting dnsmasq daemon
## Starting hostapd daemon
Configuration file: /hostapd.conf
rfkill: Cannot open RFKILL control device
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr dc:a6:32:77:fb:62 and ssid "Myspot"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: STA 7c:fd:6b:74:a7:ad IEEE 802.11: disassociated
wlan0: STA 7c:fd:6b:74:a7:ad IEEE 802.11: associated
wlan0: AP-STA-CONNECTED 7c:fd:6b:74:a7:ad
wlan0: STA 7c:fd:6b:74:a7:ad RADIUS: starting accounting session B77E632380E08929
wlan0: STA 7c:fd:6b:74:a7:ad WPA: pairwise key handshake completed (RSN)

HA Addon Config ssid: Myspot wpa_passphrase: beybeybey channel: '6' address: 192.168.99.1 netmask: 255.255.255.0 broadcast: 192.168.99.255 interface: wlan0 hide_ssid: '0' dhcp: '1' dhcp_start_addr: 192.168.99.10 dhcp_end_addr: 192.168.99.20 allow_mac_addresses: [] deny_mac_addresses: [] debug: 1 hostapd_config_override: [] client_internet_access: '1' client_dns_override:

mattlongman commented 2 years ago

Hey @hellresistor. Is this on Debian 10?

hellresistor commented 2 years ago

@mattlongman It is Debian 11 aarch64 rpi 5.10.0-7-arm64 #1 SMP Debian 5.10.40-1 (2021-05-28) aarch64

hellresistor commented 2 years ago

@mattlongman has same for Debian 10 aarch64

on journalctl -xe getting this f8a244bd2db2[601]: Add custom DNS: dhcp-option=6,8.8.8.8,8.8.4.4

the '6,' maybe mistaken ?

on Addon Log get: (the same)

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] done.
[services.d] starting services
[services.d] done.
Starting Hass.io Access Point Addon
# Setup interface:
Add to /etc/network/interfaces: iface wlan0 inet static
Run command: nmcli dev set wlan0 managed no
Run command: ip link set wlan0 down
Add to /etc/network/interfaces: address 192.168.99.1
Add to /etc/network/interfaces: netmask 255.255.255.0
Add to /etc/network/interfaces: broadcast 192.168.99.255
Run command: ip link set wlan0 up
# Setup hostapd:
Add to hostapd.conf: ssid=Myplace
Add to hostapd.conf: wpa_passphrase=********
Add to hostapd.conf: channel=6
Add to hostapd.conf: ignore_broadcast_ssid=0
Add to hostapd.conf: macaddr_acl=0
Add to hostapd.conf: interface=wlan0
# DHCP enabled. Setup dnsmasq:
Add to dnsmasq.conf: dhcp-range=192.168.99.10,192.168.99.20,12h
Add to dnsmasq.conf: interface=wlan0
Add custom DNS: dhcp-option=6,8.8.8.8,8.8.4.4
## Starting dnsmasq daemon
## Starting hostapd daemon
Configuration file: /hostapd.conf
rfkill: Cannot open RFKILL control device
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr dc:a6:32:77:fb:62 and ssid "Myplace"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
hellresistor commented 2 years ago

..... after some reinstallations... continue ...

mattlongman commented 2 years ago

Hi @hellresistor - I've not had any time to look at this. I can't say when I will get time, but it's on my list.

hellresistor commented 2 years ago

Can I confirm work on Home Assistant OS 6.5 But still not working an debian/rpi Supervised installation

jaybz commented 2 years ago

I've ran into this on Home Assistant OS 7.6 and 8.0.rc3. On 8.0.rc3 the route for wlan0 is missing. Running the following command within the addon's container fixes it: (change the ip addresses with what you've actually configured)

ip route add 192.168.99.0/24 dev wlan0 scope link src 192.168.99.1 metric 100

@mattlongman I've gotten it to work on my fork. The relevant changeset is here: https://github.com/jaybz/Hassio-Access-Point/commit/8bac53b4f0b0b9a5152685cf9637e8437db57c76. If you want me to create a PR, do you want the PR to be against the main branch or dev branch? Looks like it didn't work after all. The route just got preserved between restarts of the add-on. Retarting the host removed the route.

jaybz commented 2 years ago

@mattlongman I believe I got it properly working this time. I reset my fork so the changeset on my previous post is no longer valid. The changeset I have working right now is here: https://github.com/jaybz/Hassio-Access-Point/commit/076ebf971e607427b83b4b7bb23b01354ca0e09f. I'm not sure if the network line in /etc/network/interfaces matters. What does matter is the use of ifup and ifdown. Both binaries still read /etc/network/interfaces and they also create the route for the wireless interface. I don't think the ip link set up/down commands are still necessary, at least on my RPI4, however, seeing as they behave differently from ifup/ifdown, I've left them in just in case. If you want me to create a PR for this, just tell me which branch you want the PR to go into.

I'm also not familiar with the other platforms HAOS is built for, but if the ip binary is more reliable than ifup/ifdown, it shouldn't be difficult to use ipcalc to pull the prefix so that it can be used for ip route instead.

aladin2000 commented 1 year ago

I entered a similar issue recently I wander if the routing solution is implemented .. seems to me NO ? What's up with such a problem

hellresistor commented 1 year ago

Hi @dingausmwald , I think it is a misunderstanding of words, English is not my main language, I will use translator about https://github.com/mattlongman/Hassio-Access-Point/issues/11

my setup (use Access Point main version ): sit

my config (I don't even know what to modify anymore, I've made so many variations.):

ssid: myap
wpa_passphrase: mypassword
channel: "6"
address: 192.168.99.1
netmask: 255.255.255.0
broadcast: 192.168.99.255
interface: wlan0
hide_ssid: "0"
dhcp: 1
dhcp_start_addr: 192.168.99.10
dhcp_end_addr: 192.168.99.20
allow_mac_addresses: []
deny_mac_addresses: []
debug: 1
hostapd_config_override: []
client_internet_access: 1
client_dns_override: []
dnsmasq_config_override: []

my log:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Starting Hass.io Access Point Addon
# Setup interface:
Add to /etc/network/interfaces: iface wlan0 inet static
Run command: nmcli dev set wlan0 managed no
Run command: ip link set wlan0 down
Add to /etc/network/interfaces: address 192.168.99.1
Add to /etc/network/interfaces: netmask 255.255.255.0
Add to /etc/network/interfaces: broadcast 192.168.99.255
Run command: ip link set wlan0 up
# Setup hostapd:
Add to hostapd.conf: ssid=myap
Add to hostapd.conf: wpa_passphrase=********
Add to hostapd.conf: channel=6
Add to hostapd.conf: ignore_broadcast_ssid=0
Add to hostapd.conf: macaddr_acl=0
Add to hostapd.conf: interface=wlan0
# DHCP enabled. Setup dnsmasq:
Add to dnsmasq.conf: dhcp-range=192.168.99.10,192.168.99.20,12h
Add to dnsmasq.conf: interface=wlan0
Add DNS: dhcp-option=6,192.168.10.10,192.168.10.1
## Starting dnsmasq daemon
## Starting hostapd daemon
rfkill: Cannot open RFKILL control device
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 
wlan0: STA 16:1a:c3:e1:83:ae IEEE 802.11: associated
wlan0: AP-STA-CONNECTED 96:1a:b3:ee:83:ae
wlan0: STA 16:1a:c3:e1:83:ae RADIUS: starting accounting session E67814BF5A87C664
wlan0: STA 16:1a:c3:e1:83:ae WPA: pairwise key handshake completed (RSN)
wlan0: EAPOL-4WAY-HS-COMPLETED 16:1a:c3:e1:83:ae

My smartphone does not get internet, but network works, I can access the other devices.

I did today the installation of debian11 in rpi4. That is, a clean install without any addon.

dingausmwald commented 1 year ago

That is sad to hear, im sorry. Your config looks legit, the only difference i see is in: hide_ssid: "0" for me it is: hide_ssid: 0

without the ""

This is mine:

ssid: ssid wpa_passphrase: pass channel: "6" address: 192.168.99.1 netmask: 255.255.255.0 broadcast: 192.168.99.255 interface: wlan0 hide_ssid: 1 dhcp: 1 dhcp_start_addr: 192.168.99.10 dhcp_end_addr: 192.168.99.20 allow_mac_addresses: [] deny_mac_addresses: [] debug: 0 hostapd_config_override: [] client_internet_access: 1 client_dns_override: [] dnsmasq_config_override:

can you make an update with your sonoff? I red somewhere that some smartphones (iphones i believe) had problems with propper internet sharing.

My system is running on a raspberry pi 4b with HASSOS 64bit. Tasmoadmin, but not node-red. In addition i disabled ipv6 in HA system/network configuration. At the bottom of this i enabled auto configure.

Don't know what i can help you more. I am not from this team

hellresistor commented 1 year ago

can you make an update with your sonoff? I red somewhere that some smartphones (iphones i believe) had problems with propper internet sharing.

Interesting, I went to check the IP received on the smartphone, and I'm getting IPv6 & IPv4 addresses :| I'll look for another older smartphone.

My system is running on a raspberry pi 4b with HASSOS 64bit. Tasmoadmin, but not node-red. In addition i disabled ipv6 in HA system/network configuration. At the bottom of this i enabled auto configure.

hmm.. ok I Disable. The Wifi was defaults. So, are you using the devices with Tasmota on TasmoAdmin through wifi ? 1 2 3

Don't know what i can help you more. I am not from this team

Thanks mate, you've managed to give me some more light on where to look. see if I can understand. For without internet it won't be the problem, it would be more of an "option for a future if needed". Here I managed to add Tasmota device to TasmoAdmin, but TasmoAdmin can't "give orders/detect active" to that device (Red line). But this is already an offtopic of this. Would it be possible to contact you via the HA Discord group? Greetings and sorry for the trouble.

hellresistor commented 1 year ago

@mattlongman here my steps,

Download image here Debian 11 Rpi4 -> https://raspi.debian.net/tested/20220121_raspi_4_bullseye.img.xz ( https://raspi.debian.net/tested-images/ ) , use BelenaEtcher to transfer into SDCard.

In Local keyboard:

apt update && apt upgrade -y
apt install sudo -y
adduser YOUR_USERNAME
usermod -aG sudo YOUR_USERNAME
ip addr show eth0
reboot

In SSH login Session with YOUR_USERNAME:

sudo -i

apt update && sudo apt upgrade -y && sudo apt autoremove -y
apt-get install -y jq curl avahi-daemon apparmor-utils udisks2 libglib2.0-bin network-manager dbus wget systemd-journal-remote

## Enable CGroup V1. 
sed -i 's/.*/& systemd.unified_cgroup_hierarchy=0/' /boot/firmware/cmdline.txt

systemctl disable ModemManager && systemctl stop ModemManager

curl -fsSL get.docker.com | sh

## Checkk last version
wget https://github.com/home-assistant/os-agent/releases/download/1.4.1/os-agent_1.4.1_linux_aarch64.deb
dpkg -i os-agent_1.4.1_linux_aarch64.deb

wget https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.deb
dpkg -i homeassistant-supervised.deb

reboot

My actually configs addon:

ssid: myap
wpa_passphrase: myappassword
channel: 6
address: 192.168.99.1
netmask: 255.255.255.0
broadcast: 192.168.99.255
interface: wlan0
hide_ssid: 0
dhcp: 1
dhcp_start_addr: 192.168.99.10
dhcp_end_addr: 192.168.99.50
allow_mac_addresses: []
deny_mac_addresses: []
debug: 1
hostapd_config_override: []
client_internet_access: 1
client_dns_override: []
dnsmasq_config_override: []
Anton-Le commented 1 year ago

To pitch in I have encountered the same problem ony my HAOS 9.4 running on an RPi 4. I'm using the Pi's wlan as a separate network to which only the home automation devices are connected. Unfortunately some of them (still) require cloud access, so I have to be able to connect from the wifi to the actual network.

The following set-up was working rather well until I updated the HAOS to 9.4 (from 9.2 I think) 2 days ago, at which point the access to the internet just died.

The previously working config was:

ssid: <network name>
wpa_passphrase: <pwd>
channel: 3
address: 192.168.2.1
netmask: 255.255.255.0
broadcast: 192.168.2.255
interface: wlan0
hide_ssid: 0
dhcp: 1
dhcp_start_addr: 192.168.2.10
dhcp_end_addr: 192.168.2.50
allow_mac_addresses: []
deny_mac_addresses: []
debug: 0
hostapd_config_override:
  - country_code=DE
  - wpa_pairwise=CCMP
  - rsn_pairwise=CCMP
client_internet_access: 1
client_dns_override:
  - 192.168.0.3

For context: The Pi has an internal network adress of 192.168.0.3 and is running AdGuard as DNS service for the network, hence requests are redirected to it (I also use it to block any comms of the wifi plugs and other devices I don't deem necessary).

On my first set-up a few months ago the wifi connection would be dropped very frequently, so I went into an old hostapd.conf from PiHole and got the wpa_pairwise and rsn_pairwise overrides from there, after adding those the wifi seemed to stabilise (it may be corellation w/o causation though).

After the update of the OS devices could connect to the wifi but internet access was no longer possible. I see DNS requests from the devices in AdGuard's log - so these are passed on, but any form of communication from the wifi to the internet appears impossible (tried it with a simple ping -c4 9.9.9.9 from a laptop).

Logging into HAOS via SSH and querying the routes I see, which seems reasonable:

default via 192.168.0.1 dev eth0  metric 100 
172.17.232.0/23 dev docker0 scope link  src 172.17.232.1 
172.30.32.0/23 dev hassio scope link  src 172.30.32.1
192.168.0.0/24 dev eth0 scope link  src 192.168.0.3  metric 100 
192.168.2.0/24 dev wlan0 scope link  src 192.168.2.1 

The log output for this add-on, with debug enabled, is:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
Starting Hass.io Access Point Addon
# Setup interface:
Add to /etc/network/interfaces: iface wlan0 inet static
Run command: nmcli dev set wlan0 managed no
Run command: ip link set wlan0 down
Add to /etc/network/interfaces: address 192.168.2.1
Add to /etc/network/interfaces: netmask 255.255.255.0
Add to /etc/network/interfaces: broadcast 192.168.2.255
Run command: ip link set wlan0 up
# Setup hostapd:
Add to hostapd.conf: ssid=<wifi-name>
Add to hostapd.conf: wpa_passphrase=********
Add to hostapd.conf: channel=3
Add to hostapd.conf: ignore_broadcast_ssid=0
Add to hostapd.conf: macaddr_acl=0
Add to hostapd.conf: interface=wlan0
# Custom hostapd config options:
Add to hostapd.conf: country_code=DE
Add to hostapd.conf: wpa_pairwise=CCMP
Add to hostapd.conf: rsn_pairwise=CCMP
# DHCP enabled. Setup dnsmasq:
Add to dnsmasq.conf: dhcp-range=192.168.2.10,192.168.2.50,12h
Add to dnsmasq.conf: interface=wlan0
Add custom DNS: dhcp-option=6,192.168.0.3
# Custom dnsmasq config options:
Add to dnsmasq.conf: dhcp-host=<mac-of-wifi-plug>,192.168.2.10
## Starting dnsmasq daemon
## Starting hostapd daemon
rfkill: Cannot open RFKILL control device
wlan0: interface state UNINITIALIZED->COUNTRY_UPDATE
wlan0: interface state COUNTRY_UPDATE->ENABLED
wlan0: AP-ENABLED 
wlan0: STA <mac-of-wifi-plug> IEEE 802.11: associated
wlan0: AP-STA-CONNECTED <mac-of-wifi-plug>
wlan0: STA <mac-of-wifi-plug> RADIUS: starting accounting session 28ED2B78EEBC94E1
wlan0: STA <mac-of-wifi-plug> WPA: pairwise key handshake completed (RSN)
wlan0: EAPOL-4WAY-HS-COMPLETED <mac-of-wifi-plug>

I am very much confused as to where the problem lies because the DNS requests are apparently being processed, but pinging is impossible.

Any suggestions are appreciated!

Anton-Le commented 1 year ago

As a follow-up to my above post:

Reverting homeassistant OS back to 9.2 fixed the problem. Checking the changelog from 9.2 to 9.3 and to 9.4 I'd say the reason for the problem are the networking changes introduced in 9.4.

9.4 introduces a switch from iptables to nf_tables, which I think is the likeliest candidate for the problem described in the post above. The switch to use the fq_codel scheduler for network Quality-of-Service is probably not the reason for the error.

dingausmwald commented 1 year ago

@Anton-Le this is interesting. Thanks for the hint. Could you solve it by now? I will have a look too. I want to update soon. The maintainer isn't very active here anymore

dingausmwald commented 1 year ago

So i figured it out. In run.sh there are 6 lines starting with iptables. I just changed them to iptables-nft and everything works fine again on 9.4.

You can get my version with additional features like setting a different internet access interface (from default eth0 to what you want).

https://github.com/dingausmwald/Hassio-Access-Point

I had to remove ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] from hostapd.conf since my additional wifi usb stick does not support [DSSS_CCK-40] and "hostapd_config_override" option does not seem to work anymore like stated in this: https://github.com/mattlongman/Hassio-Access-Point/issues/2

would be nice if someone could check hostapd_config_override function so i can set this back to default.

mattlongman commented 1 year ago

So i figured it out. In run.sh there are 6 lines starting with iptables. I just changed them to iptables-nft and everything works fine again on 9.4.

You can get my version with additional features like setting a different internet access interface (from default eth0 to what you want).

https://github.com/dingausmwald/Hassio-Access-Point

I had to remove ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] from hostapd.conf since my additional wifi usb stick does not support [DSSS_CCK-40] and "hostapd_config_override" option does not seem to work anymore like stated in this: #2

would be nice if someone could check hostapd_config_override function so i can set this back to default.

I've implemented this change, but currently have no way of testing it.

@dingausmwald - thanks for adding this info. If this is an addon you use, I'd be happy to add you as a maintainer as I haven't been able to work on this at all recently.

dingausmwald commented 1 year ago

@mattlongman Well, my coding skills are limited, i don't think i can help this addon alot. But i use it, yes. Like i said i couldn't find a way to get hostapd_config_override to work again. So don't rely on me to much. If you think this will help, you can add me. I will try to help

Anton-Le commented 1 year ago

@Anton-Le this is interesting. Thanks for the hint. Could you solve it by now? I will have a look too. I want to update soon. The maintainer isn't very active here anymore

Great that youve figured it out!

I wasnt planning to get to it until after christmas since I need to set-up a separate system for testing. My original post was direct consequence of the stupid decision to ignore the old wisdom: "Never touch a running system", by upgrading the system that's actually running my home automation while having the thermal controls still bound to cloud via the RPI network set-up with this add-on.

Once I get a separate test system up I'll be able to give a bit more feedback on other issues here as well, maybe contribute, too.

CarlosGS commented 1 year ago

It works! Thank you @dingausmwald for finding it and @mattlongman for releasing it so quickly :tada:

hellresistor commented 1 year ago

@dingausmwald @mattlongman @Anton-Le Is working in RaspiOS lite + HA Supervised ;)

THANK YOU ;)

this will close many issues ^^

@dingausmwald just need some adjustments on configuration page and be perfect update!!

Best Regards