This is not super efficient, but assuming the addresses are stored in a varchar column with a name IPAddress, you can do:
SELECT
SUBSTRING(IPAddress, 1, LEN(IPAddress) - CHARINDEX('.',REVERSE(IPAddress))),
COUNT(*)
FROM
...
GROUP BY
SUBSTRING(IPAddress, 1, LEN(IPAddress) - CHARINDEX('.',REVERSE(IPAddress)))
This has not been tested, so I can disconnect somewhere or the bracket is missing.
, , , , , CHARINDEX . " " " " , .
( , , .)