#!/bin/bash
if [ $# -ne 1 ];then
echo "usage : $0 ip "
exit 0
fi
DENY_IP="$1"
iptables -I INPUT -s $DENY_IP -j DROP
if [ $? -eq 0 ];then
echo "$DENY_IP" >> deny_ip_list
fi
/etc/rc.d/init.d/iptables save
~
if [ $# -ne 1 ];then
echo "usage : $0 ip "
exit 0
fi
DENY_IP="$1"
iptables -I INPUT -s $DENY_IP -j DROP
if [ $? -eq 0 ];then
echo "$DENY_IP" >> deny_ip_list
fi
/etc/rc.d/init.d/iptables save
~
本文介绍了一个简单的bash脚本,用于通过iptables防火墙规则来屏蔽特定的IP地址。该脚本接受一个参数作为要屏蔽的IP地址,并将其添加到iptables的INPUT链中,规则为DROP,确保从此IP来的所有连接请求都被丢弃。此外,被屏蔽的IP地址会被记录在一个名为deny_ip_list的文件中,以便日后查看。
880

被折叠的 条评论
为什么被折叠?



