Edit blacklist.sh, need help

Hestia has an ip list script for the block:
https://raw.githubusercontent.com/hestiacp/hestiacp/main/install/deb/firewall/ipset/blacklist.sh

Who can tell me how to add a comment to the output in the list.
The script outputs addresses of the form:
xxx.xx.xx.xxx
xxx.xx.xx.xxx
etc

What should I add to make the output:
xxx.xx.xx.xx comment=blablabla
xxx.xx.xx.xx comment=blablabla
etc

Who knows, please tell me. :drooling_face:

You can’t xxx.xx.xx.xx comment=blablabla is not valid output for ipset

xxx.xx.xx.xxx/32 #xxxxx might work but not tested also default file will get overwritten

Yes. I understand… in theory, how to do it? maybe someone knows.

It think the last sed command makes sure that only valid ip ranges are possible. Have no clue to be honest…

This script does what we need. But we need to figure out how to add multiple lists.

#!/bin/sh
saveTo=/root
now=$(date);
rm -f blacklist.rsc
echo "/ip firewall address-list" >> $saveTo/blacklist.rsc
wget -q -O - http://ipverse.net/ipblocks/data/countries/kr.zone | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist";}' >> $saveTo/blacklist.rsc

p.s. this is a script for example. the basis…

https://docs.hestiacp.com/admin_docs/settings/firewall.html#can-i-combine-multiple-sources-in-one

and then

https://docs.hestiacp.com/admin_docs/settings/firewall.html#how-do-i-setup-ip-set-black-whitelist

I read it =) I studied all the documentation.
it’s a little different. left it that way for now, does what I need. communicating makes my brain work better =) thanks for the company =)

#!/bin/sh
saveTo=/root
now=$(date);
rm -f blacklist.rsc
echo "/ip firewall address-list" >> $saveTo/blacklist.rsc
wget -q -O - http://ipverse.net/ipblocks/data/countries/kr.zone | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist";}' >> $saveTo/blacklist.rsc

wget -q -O - http://ipverse.net/ipblocks/data/countries/cn.zone | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist";}' >> $saveTo/blacklist.rsc

wget -q -O - http://ipverse.net/ipblocks/data/countries/ru.zone | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist";}' >> $saveTo/blacklist.rsc

etc… :drooling_face:

no. it can be simpler =) lists work with a space =)

#!/bin/sh
saveTo=/root
now=$(date);
rm -f blacklist.rsc
echo "/ip firewall address-list" >> $saveTo/blacklist.rsc
wget -q -O - http://ipverse.net/ipblocks/data/countries/kr.zone http://ipverse.net/ipblocks/data/countries/cn.zone | awk --posix '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist";}' >> $saveTo/blacklist.rsc

you can close the thread, so that there is no unnecessary flooding. :wink:

p.s. I just need to figure out how to delete similar strings when forming the list :sneezing_face:

just add at the end:

|sort -n|sort -mu

it goes like this:

'/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ { print "add list=blacklist address=" $1 " comment=blacklist";}' |sort -n|sort -mu >>

happy :yum:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.