Home>
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 40.87.183.236/31 51.120.224.192/28 51.141.8.62 104.46.121.72 ...
I don't understand why separate ip's are formed as well, because the initial loaded list only contains subnets.
#!/bin/bash
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
do
ipset -A blacklist $ipnet
done
echo "completed"
The input file says 51.141.8.62/32 And 32 mask is one single ip and /32 is simply not displayed in the output
Mike2022-02-08 03:33:12You 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:24Related questions
- linux : Forward client traffic through a different interface and forward the port
- linux : Is it possible to check the result of the execution of someone else's script?
- linux : Grep Number of matches in specific files
- linux : Bash -Put the transfer of the line after the first word
- How to read the Linux environment variable
- linux : Bash script to copy files to a specific expansion and change of the upper case to the lower
- Performing a Python script from another python script with a visual component
- linux : Create a bash script which groups files and searches the last
- linux : How to change the sound in the Ubuntu terminal?
Maybe you can optimize somehow?
Andrey2022-02-08 03:33:12