Answer the question
In order to leave comments, you need to log in
How to loop through ip list in linux console?
I use awk to list ip like this:
"162.218.65.246"
"162.218.65.247"
"162.218.65.248"
"162.218.65.249"
"162.218.65.250"
"162.218.65.252"
"162.218.65.253"
"162.218.65.253
" 164.132.12.120"
"167.114.102.40"
"171.37.205.244"
Cut out all unnecessary characters from the output through sub.
Question #1: How to remove quotes from output?
Question #2: How to skip this entire list through the "ufw deny from" command ?
The idea is to request the necessary ip list with one command in the console (almost implemented) and deny access to the listed ip by adding these ip to the deny rules in the firewall.
Answer the question
In order to leave comments, you need to log in
Question #1: How to remove quotes from output?
Question #2: How to skip this entire list through the "ufw deny from" command?
But it seems to me that you need not to "pass through the command", but "call the command once with each ip". This is true:... | tr -d \" | xargs -r -n1 ufw deny from
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question