vnix27 Asked: 2011-05-31 20:37:46 +0800 CST2011-05-31 20:37:46 +0800 CST 2011-05-31 20:37:46 +0800 CST Using SED to update .htaccess with blocked IP addresses 772 I have a file that has a list of "bad" IP addresses. I want to import this file of bad IP addresses into my .htaccess file to deny access via apache. I want to automate this process using sed. How would I go about doing this? linux scripting bash sed 2 Answers Voted spectre256 2011-05-31T22:15:41+08:002011-05-31T22:15:41+08:00 Why sed? Use fail2ban. It can be configured to work with many different services, including Apache. Best Answer gelraen 2011-05-31T22:41:00+08:002011-05-31T22:41:00+08:00 You can make .htaccess template with "%BANNED_IP_LIST%" in place where that list should be and use something like sed -e "s/%BANNED_IP_LIST%/$(cat banned.txt)/" to create actual .htaccess file.
Why sed? Use fail2ban. It can be configured to work with many different services, including Apache.
You can make
.htaccess
template with "%BANNED_IP_LIST%" in place where that list should be and use something likesed -e "s/%BANNED_IP_LIST%/$(cat banned.txt)/"
to create actual.htaccess
file.