I have Home Assistant running and exposing it via DDNS for remote access with Port Forwarding. Whilst mac address whitelist works for WiFi, I could not manage to identify a mac address for my mobile when on cellular. The cellular IP is also generic not allowing me to use CIDR notation.
Therefore my question, does anyone have an idea how to control access?
I would personally suggest disabling the port forward as this exposes your home assistant to the internet. You could setup a wireguard VPN. This would allow you to dial into your home network and access any LAN resources.
MAC addresses are on visible on your local LAN (L2), they don't go beyond your ISPs first hop. You really should close all remote access (port forwardings) and connect to your home assistant only via a well secured VPN (roadwarrior type setup), e.g. via wireguard (or OpenVPN, IPsec, ...).
Thanks for you advice which make totally sense. I followed the current approach as this was the one I was most familiar with. Though, I am already working on the Wireguard setup.
Checking the docs I struggle to find some details hwo Wireguard works with DDNS. Do you happen to have some details please?
What I meant with random cellular IP was that the range was way to wide to be an effective security / control measure.
My first question when attempting to setup WireGuard was, as I can not find a configuration in the UI, how to configure the DDNS domain? To get a better understanding, I now used the automated WireGuard Script "Named Peers with IDs" where there is a corresponding variable.
I think I am close to getting the setup done using my mobile as a peer.
Thanks for the confirmation, I got these already. Though, I could not find the configuration where the DDNS Domain, please note that I got my own domain, is configured but with the script it should be fine. Unfortunately I can not establish a connecting form my mobile peer. Got to check for more sources to learn it properly.
In the phone, enter the DNS name of your router, that is the one registered with DDNS. Open one port on the firewall for UDP which leads to the Wireguard process. Configure that port number into the phone.
The IP of the phone will always be the same inside the tunnel, and you can route that to your LAN. Outside the tunnel it may have any IP, in general you don't care about that since Wireguard secures the connection with keys.
let's take a look at your config files to see if there are any issues that would prevent you from connecting...
We also need to make sure you have a public IP on the WAN of your router. Take a look at the LuCI web interface main status page and find the IPv4 upstream section... look at the IP address shown there and compare it to the result you get when you google "what's my IP" -- if they don't match, you either don't have a public IP from your ISP, or you've got a double-NAT situation... we'll explore if needed. If in doubt, post the first to octets of your IP address (in bold: aaa.bbb.ccc.ddd).
Please copy the output of the following commands and post it here using the "Preformatted text </> " button:
Remember to redact passwords, MAC addresses and any public IP addresses you may have:
cat /etc/config/network
cat /etc/config/firewall
And also please provide the wireguard config from your phone.
cat /etc/config/network
config interface 'loopback'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
option device 'lo'
config globals 'globals'
option ula_prefix 'fd2c:48ce:ad4f::/48'
config interface 'lan'
option force_link '1'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
option device 'br-lan'
config interface 'wan'
option proto 'pppoe'
option username 'MY_USER'
option password 'MY_PASSWORD'
option ipv6 'auto'
option device 'br-wan'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
option blinkrate '2'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0 1 2 3 5t'
config switch_port
option device 'switch0'
option port '1'
option led '6'
config switch_port
option device 'switch0'
option port '2'
option led '9'
config switch_port
option device 'switch0'
option port '5'
option led '2'
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0.1'
config device
option name 'br-wan'
option type 'bridge'
list ports 'eth1'
config interface 'NestVPN'
option proto 'wireguard'
option private_key 'MY_PRIVATE_KEY'
option listen_port '51820'
list addresses '192.168.9.1/24'
list addresses 'fdf1:e8a1:8d3f:9::1/64'
config wireguard_NestVPN 'wgclient'
option preshared_key 'MY_PRE_SHARED_KEY'
list allowed_ips '192.168.9.2/32'
list allowed_ips 'fdf1:e8a1:8d3f:9::2/128'
option public_key 'XbYcuAW34Ix2m/x6UXRuXTYshAMmQuiCUZBMWXxOfUU='
option private_key 'MY_PRIVATE_KEY'
option route_allowed_ips '1'
cat /etc/config/firewall
config defaults
option input 'ACCEPT'
option output 'ACCEPT'
option drop_invalid '1'
option synflood_protect '1'
option forward 'REJECT'
config zone 'lan'
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
list network 'NestVPN'
config zone 'wan'
option name 'wan'
option output 'ACCEPT'
option mtu_fix '1'
option input 'REJECT'
option forward 'REJECT'
option masq '1'
option log '1'
list network 'wan'
config forwarding
option src 'lan'
option dest 'wan'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
option enabled '0'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option src_ip 'fe80::/10'
option src_port '547'
option dest_ip 'fe80::/10'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config include
option path '/etc/firewall.user'
config redirect
option dest 'lan'
option target 'DNAT'
list proto 'tcp'
option src 'wan'
option src_dport '443'
option dest_ip '192.168.1.123'
option name 'Nest-Assistent External LetsEncrypt 443'
option dest_port '8123'
option enabled '0'
config redirect
option dest 'lan'
option target 'DNAT'
option name 'WireGuard'
list proto 'udp'
option src 'wan'
option src_dport '51820'
config rule 'wg'
option name 'Allow-WireGuard'
option src 'wan'
option dest_port '51820'
option proto 'udp'
option target 'ACCEPT'
The WireGuard Status extension states the server is up and running. Trying to connect via my mobile, peer config was shared via QR Code, throws a DNS Resolution Error (Endpoint not reachable).
Dns resolution errors are very different than endpoint not reachable (unless the former causes the latter).
Check your endpoint address as entered into the mobile peer config - what does it have in there? If it is your ddns domain name, are there any typos? Can your phone resolve the address using another dns resolution or ping tool?
Thanks for the hint. Indeed, the QR Code setup did not configure the DDNS Domain but another value. After correcting that I managed to establish a connection but the peer in OpenWRT is reported to not being connected
Did that a couple of time but to no avail. The WireGuard iPhone app states "Tunnel status us now 'connected'" but no packages arrive. I deleted the peer, setup it up once more two times. Once manually, another time via QR. No spaces in the keys, all seem valid.