I’ve been plagued by hackers trying to log in to my Home Assistant.
I added each offender to ip_bans.yaml
but they just increment their ip address to get around the ban.
I’ve changed the http component to be able to ban by subnet (a.b.c.d/n etc) and this has eased the problem considerably.
My fork is here
Would anybody find this useful?
To test my forked http component:
Make sure your HA version is at least 2025.2.5
Copy the whole http component from my fork into the custom_components config folder.
You have to add a "version": "1.0.0"
at the bottom of manifest.json so it looks like this
{
"domain": "http",
"name": "HTTP",
"codeowners": ["@home-assistant/core"],
"documentation": "https://www.home-assistant.io/integrations/http",
"integration_type": "system",
"iot_class": "local_push",
"quality_scale": "internal",
"version": "1.0.0"
}
To ban networks, add the following to configuration.yaml
in the http
section
http:
....
ip_ban_enabled: True # optional as defaults to True
banned_networks: # Make sure the format is right, e.g. /16 must end in 0.0/16
- 111.7.0.0/16
- 45.0.0.0/8
- 179.43.0.0/16
- 123.160.0.0/14
- 195.178.0.0/16
log_banned_networks: True # optional as defaults to True
notify_banned_networks: True # optional as defaults to True
If you enable logging it will report as info messages so if the default logger setting is above this you will need to add a log line to the logger on configuration.yaml
like this
logger:
default: critical
logs:
custom_components.http: info
I strongly suggest you install samba so you can access the config folder without using the ha file editor addon in case something breaks and you are locked out of ha. You should also have ssh access through a client like putty so you can restart if needed.
Views please
[modified from original as configuration is now in configuration.yaml
]