Guys, who can tell me what's wrong? Created a bash script to automatically generate an ip pool in nethash format (subnets). But at the output, the list is obtained both with individual ip and with subnets. Example ...

I don't understand why separate ip's are formed as well, because the initial loaded list only contains subnets.

echo "### Blocking Microsoft ###"
# Delete the list if it already exists
ipset -X blacklist
#Creating a new list
ipset -N blacklist nethash
# Download the files of the countries we are interested in and merge them into one list
wget -O microsoftIPv4-agrig.zone https://raw.githubusercontent.com/lord-alfred/ipranges/main/microsoft/ipv4.txt
echo -n "Uploading blacklist to IPSET"
# Read the list of networks and add them to ipset line by line
list=$(cat microsoftIPv4-agrig.zone)
for ipnet in $list
ipset -A blacklist $ipnet
echo "completed"

Maybe you can optimize somehow?

Andrey2022-02-08 03:33:12

The input file says And 32 mask is one single ip and /32 is simply not displayed in the output

Mike2022-02-08 03:33:12

You don't need bash, but a bpf program.

0andriy2022-02-08 03:33:12

@Mike thanks, got it!

Andrey2022-02-08 03:33:12

@0andriy it's kind of like a socket filter. I don't think so)

eri2022-02-07 11:41:24