On 10/26/2004 13:25, "Coax" <coax@???> wrote:
> I have the existing scenario..
>
> I have a database with this schema:
>
> mysql> describe global_blacklist;
> +---------+-------------+------+-----+---------+-------+
> | Field | Type | Null | Key | Default | Extra |
> +---------+-------------+------+-----+---------+-------+
> | address | varchar(15) | YES | MUL | NULL | |
> | comment | varchar(50) | YES | | NULL | |
> +---------+-------------+------+-----+---------+-------+
> 2 rows in set (0.00 sec)
>
>
> A sample of data might be:
>
> INSERT into global_blacklist VALUES ('127.0.0.1', 'Spammer!');
>
> I have MySQL acl that does the following on connect:
>
> deny message = $sender_host_address found in local blacklist..
> hosts = mysql;select address from global_blacklist where \
> address = '$sender_host_address'
>
>
>
> Problem is, I have to blacklist each individual IP address i'd like
> blacklisted - in order for this to work.
>
> I'd like to store '127.0.0' in the database, and have the acl strip the
> trailing '.' and following numbers located in $sender_host_address - and
> query the database for THAT. (i.e. i'd like to blacklist a whole subnet!)
>
We (not I) elected to store our addresses for this sort of purpose in two
columns: network (a /24 address, just the first 3 bytes) and host (the
final byte). We (with encouragement from me) also elected to use a daemon
written in Python to do the actual lookups, which have other things to check
in addition to our equivalent of this table.
It's working for us, but may well not be what you want to do. (And it
leaves the problem of now and then wanting to blacklist all but a few hosts
within a particular /24...which is an issue for whatever it is you use to
populate the table.)
I think we did the design before the $mask operator appeared...not sure.
--John