taiwan_ips_ipset_config.sh
· 696 B · Bash
Surowy
#!/bin/bash
# Delete the existing taiwan_ips ipset collection if it exists
ipset destroy taiwan_ips
# Create a new taiwan_ips ipset collection
ipset create taiwan_ips hash:net
# Download the Taiwan IP range file using wget (commented out)
wget https://github.com/Loyalsoldier/geoip/raw/release/text/tw.txt -O tw.txt
# Add IPv4 ranges to the ipset collection
while IFS= read -r line; do
# Check if the line contains an IPv4 address
if [[ "$line" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ ]]; then
ipset add taiwan_ips "$line"
fi
done < tw.txt
# Delete the downloaded file (commented out)
# rm tw.txt
# View the contents of the taiwan_ips ipset collection
# ipset list taiwan_ips
| 1 | #!/bin/bash |
| 2 | |
| 3 | # Delete the existing taiwan_ips ipset collection if it exists |
| 4 | ipset destroy taiwan_ips |
| 5 | |
| 6 | # Create a new taiwan_ips ipset collection |
| 7 | ipset create taiwan_ips hash:net |
| 8 | |
| 9 | # Download the Taiwan IP range file using wget (commented out) |
| 10 | wget https://github.com/Loyalsoldier/geoip/raw/release/text/tw.txt -O tw.txt |
| 11 | |
| 12 | # Add IPv4 ranges to the ipset collection |
| 13 | while IFS= read -r line; do |
| 14 | # Check if the line contains an IPv4 address |
| 15 | if [[ "$line" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ ]]; then |
| 16 | ipset add taiwan_ips "$line" |
| 17 | fi |
| 18 | done < tw.txt |
| 19 | |
| 20 | # Delete the downloaded file (commented out) |
| 21 | # rm tw.txt |
| 22 | |
| 23 | # View the contents of the taiwan_ips ipset collection |
| 24 | # ipset list taiwan_ips |