chupa
August 16, 2021, 7:23am
1
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.
eris
August 16, 2021, 7:27am
2
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
chupa
August 16, 2021, 7:30am
3
Yes. I understand… in theory, how to do it? maybe someone knows.
eris
August 16, 2021, 7:35am
4
It think the last sed command makes sure that only valid ip ranges are possible. Have no clue to be honest…
chupa
August 16, 2021, 7:54am
5
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…
chupa
August 16, 2021, 8:06am
7
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…
chupa
August 16, 2021, 8:11am
8
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.
p.s. I just need to figure out how to delete similar strings when forming the list
chupa
August 16, 2021, 8:27am
9
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
system
Closed
September 15, 2021, 8:28am
10
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.