So I wrote simple script to ban every connection exceeding 8 connections. It works quite well, I have stable 8 connections and 60% of consumed RAM.
ban.sh
X=0;
for i in $(~/cli getpeerinfo | grep addr\" | awk '{print $3}' | sed "s/\"\|,//g" | sed "s/:.*//" ); do
if [ "$X" -ge "8" ]; then
echo $i banned for 3600s
~/cli setban $i add 3600
fi ;
X=$(($X + 1));
done
sleep 1;
done
I run it as
~/ban.sh >> ~/banned_IPs.log &
and in cron I have
Just posting here in case somebody else have same issue.