Here are 2 links for getting ideas about the database schema: https://dba.stackexchange.com/questions/36446/ip-address-lookup-star-schema-design
and https://www.sqlservercentral.com/forums/topic/database-structure-to-manage-ip-addresses
Those 2 are about MS SQL server, but the same approach as said works also with other RDBMS like MySQL (we use) and PostgreSQL e.g.
For connecting BAS to the MySQL db we use the mysql2 node.js module. Works very well but you can also use the built in SQL functionality.

