这是我的 ipset shell 脚本文件,如下所示
#!/bin/bash
for IP in $(wget -O /var/geoiptest.txt http://www.ipdeny.com/ipblocks/data/countries/{ad,ae,af}.zone)
do
# ban everything - block country
sudo ipset add geo /var/geoiptest.txt
done
我认为最后一排有问题,我该如何解决?
答案1
你的迭代是错误的。正确的语法类似于:
#!/bin/bash
sudo wget -O /var/geoiptest.txt http://www.ipdeny.com/ipblocks/data/countries/{ad,ae,af}.zone
while read ip; do
sudo ipset add geo $ip
done < /var/geoiptest.txt