( kalmarr | 2020. 04. 27., h – 14:04 )

Akkor így 100%, hogy fut :)

iptables -L -n -v | grep china
   23  1300 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            match-set china src
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            match-set china src

 

Az iptables-t módosítottan és bővítettem a forward-ra is:

-A INPUT -m set --match-set china src -j DROP
-A FORWARD -m set --match-set china src -j DROP

(tcp portot kivettem). Gondolom, ezzel még nagy kárt nem okoztam :)

 

Amúgy, ha lefuttatom a scriptet újra, akkor ez az üzenet jön:

 

Ami ugye nem hiba, de, minden IP-nél kilistázza, akár 1000 szer is...

ipset v6.23: Element cannot be added to the set: it's already added

...

Ez jó is meg nem is, ha csak bővül a lista, akkor ez így jó, de ha kivehetnek belőle címet, akkor nem lesz jó....

Erre lenne ez a parancs:

ipset destroy china

Viszont, mivel fut, ezért nem lehet kivenni, ez a hiba jön vissza:

ipset destroy china
ipset v6.23: Set cannot be destroyed: it is in use by a kernel component

Erre van valami okosság?

 

Az ipset-nél lett még egy kérdésem.

A scriptet elkészítettem több országra is. Feltételezem, hogy ha logikusan átírom a scriptet és beteszem a tűzfalba, akkor jól csinálom.

Ukrán:

---

# Create the ipset list
ipset -N ukraine hash:net

# remove any old list that might exist from previous runs of this script
rm ua.zone

# Pull the latest IP set for russian
wget -P . https://www.ipdeny.com/ipblocks/data/countries/ua.zone

# Add each IP address from the downloaded list into the ipset 'ukraine'
for i in $(cat /etc/block-ip/ua.zone ); do ipset -A ukraine $i; done

# Restore iptables
/sbin/iptables-restore < /etc/network/iptables.up.rules

ipset list | grep ukraine -C 6

---

iptaples

---

 

# Block anything from Ukraine
-A INPUT -m set --match-set ukraine src -j DROP
-A FORWARD -m set --match-set ukraine src -j DROP
####

 

---

Bocs, hogy ennyire körülményes vagyok, de ha már változtatok a dolgon, akkor legalább jó legyen :)