I have an Apache web server running under Ubuntu 20.04 LTS.
I allowed the access to the website only to specific ranges of IP addresses.
Everything was working fine until I saw some requests (attacks) coming from not-allowed IP addresses (China, Singapore, USA, etc.) with sometimes some nasty requests.
I double and triple checked everything and those IP addresses do not belong to allowed ranges.
I checked everywhere I could on Google as well as through questions to chatGPT.
I am now out of leads to follow to identify the cause of this security issue.
What could the reasons be?
I even started again from scratch and the issues persists. And it's a real problem that UFW cannot correctly block all those IP addresses from unwanted areas.
UPDATE: As requested, here are examples of the added rules
80,443/tcp ALLOW IN 216.252.224.0/19
80,443/tcp ALLOW IN 217.11.32.0/20
80,443/tcp ALLOW IN 217.11.208.0/20
80,443/tcp ALLOW IN 217.14.64.0/20
80,443/tcp ALLOW IN 217.20.192.0/20
80,443/tcp ALLOW IN 217.22.128.0/20
80,443/tcp ALLOW IN 217.26.32.0/20
It's simply a long list of rules of the same kind.
Let's illustrate the problem with the following example of rule:
80,443/tcp ALLOW IN 216.252.224.0/19
The IP address range 216.252.224.0/19 represents a subnet with a netmask of 255.255.224.0, which allows for 8,192 unique IP addresses. In this case, the range spans from 216.252.224.0 to 216.252.255.255 (this is what chatGPF tells me). Those are the only IP addresses starting with 216.252.xx.xx I want let go through
So, if I get a visitor with the following IP: 216.252.xxx.xx which doesn't belong to the range, then this a problem.