使用iptables封指定IP访问网站的方法
2012-10-22 14:57
567 查看
使用iptables封指定IP访问网站的方法
近来网站访问量异常增长,通过分析apache access_log找出了频繁访问的IP地址,确认是盗链,决定使用iptables封掉.
脚本如下:
# awk '{print $1}' access_log.20110622 |sort |uniq -c |sort -nr |more
15112 183.38.186.60
5289 218.83.160.164
4566 58.61.154.18
4428 183.39.105.113
3169 121.14.162.56
2121 113.108.116.17
1971 121.14.162.46
1614 121.14.162.65
1515 192.168.39.134
1430 59.152.221.14
1391 121.14.162.47
1350 183.38.181.117
1317 183.38.189.202
1293 121.14.162.85
1285 121.14.162.117
iptables的使用方法如下:
封单个IP的命令
iptables -I INPUT -s 183.38.186.60 -j DROP
封IP段的命令
iptables -I INPUT -s 183.38.186.0/16 -j DROP
封整个段的命令
iptables -I INPUT -s 183.38.0.0/8 -j DROP
封几个段的命令
iptables -I INPUT -s 183.38.186.0/24 -j DROP
iptables -I INPUT -s 183.38.187.0/24 -j DROP
只封80端口
iptables -I INPUT -p tcp –-dport 80 -s 183.38.186.0/24 -j DROP
iptables -I INPUT -s 183.38.186.0/24 -j DROP
删除所有限制项
iptables -F
删除指定限制项
iptables -D INPUT 数字
如 iptables -D INPUT 1
查看iptables配置项
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP tcp -- 10.200.1.149 anywhere tcp dpt:http
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#
删除一个配置项
# iptables -D INPUT 1
复核iptables配置项
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#
近来网站访问量异常增长,通过分析apache access_log找出了频繁访问的IP地址,确认是盗链,决定使用iptables封掉.
脚本如下:
# awk '{print $1}' access_log.20110622 |sort |uniq -c |sort -nr |more
15112 183.38.186.60
5289 218.83.160.164
4566 58.61.154.18
4428 183.39.105.113
3169 121.14.162.56
2121 113.108.116.17
1971 121.14.162.46
1614 121.14.162.65
1515 192.168.39.134
1430 59.152.221.14
1391 121.14.162.47
1350 183.38.181.117
1317 183.38.189.202
1293 121.14.162.85
1285 121.14.162.117
iptables的使用方法如下:
封单个IP的命令
iptables -I INPUT -s 183.38.186.60 -j DROP
封IP段的命令
iptables -I INPUT -s 183.38.186.0/16 -j DROP
封整个段的命令
iptables -I INPUT -s 183.38.0.0/8 -j DROP
封几个段的命令
iptables -I INPUT -s 183.38.186.0/24 -j DROP
iptables -I INPUT -s 183.38.187.0/24 -j DROP
只封80端口
iptables -I INPUT -p tcp –-dport 80 -s 183.38.186.0/24 -j DROP
iptables -I INPUT -s 183.38.186.0/24 -j DROP
删除所有限制项
iptables -F
删除指定限制项
iptables -D INPUT 数字
如 iptables -D INPUT 1
查看iptables配置项
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP tcp -- 10.200.1.149 anywhere tcp dpt:http
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#
删除一个配置项
# iptables -D INPUT 1
复核iptables配置项
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#
相关文章推荐
- 【腾讯云的1001种玩法】Nginx网站使用CDN之后禁止用户真实IP访问的方法
- Nginx网站使用CDN之后禁止用户真实IP访问的方法
- Nginx网站使用CDN之后禁止用户真实IP访问的方法
- python3使用代理ip访问指定网站
- Nginx网站使用CDN之后禁止用户真实IP访问的方法
- Apache设置禁止使用IP访问网站的方法
- Apache设置禁止使用IP访问网站的方法
- iptables防火墙只允许指定ip连接指定端口、访问指定网站
- iptables防火墙只允许指定ip连接指定端口、访问指定网站
- 在apache中设置禁止使用IP访问网站的方法
- 只让用户通过域名访问网站,使用IP不能访问的方法
- linux下通过iptables只允许指定ip地址访问指定端口的设置方法
- 同一域名对应不同IP,访问指定主机文件内容的方法
- iptables 防火墙 只允许某IP访问某端口、访问特定网站
- iptables只允许指定ip访问本机的指定端口
- Apache下禁止使用IP直接访问本站的配置方法
- linux系统中配置Nginx 拒绝代理访问指定IP的方法
- apache禁止使用IP访问的实现方法