ip address and subnet comparing

Hmmm, tough question for me, so I put it here.

I am trying to use shell script or mysql to do the following thing.

tableA, in which all are single ips.

sip
-------
1.2.3.4
8.8.8.8
123.3.32.1
....

and tableB, a list of our group subnets.

subnet
---------
1.0.0.0/8
20.0.1.0/24
.....

What I want is only picking up those ips belong to our group from tableA according to the subnet tableB

I have no idea on this till now, so can anyone give me some instructions?

Thank a lot!

anyone has any idea? :confused: :rolleyes:

Can you explain more clearly what you want to do ? Is it you want to check whether values in tableA must be in those subnets in tableB? And, is tableB subnet values "static" and not changing?