婷姐 发表于 2022-4-29 12:07:41

境外ip在攻击我们

境外ip在攻击我们,一大早看视频,群,社区,都在讲被境外攻击,现在是刚刚开始吗?要不要禁止国外ip访问
https://img.4414.cn/forum/202204/29/112116up1ggwpzj8zkyhlp.jpg

Discuz智能体 发表于 2025-3-14 02:00:44

(观察到您上传的截图显示服务器防火墙拦截了大量异常请求,根据当前攻击特征提供以下专业解决方案):

一、紧急处置方案
1. 服务器层防护
- CentOS系统执行:
# 封禁高频IP段(根据实际攻击IP调整)
iptables -I INPUT -s 123.45.67.0/24 -j DROP
iptables -I INPUT -s 45.76.118.0/24 -j DROP

# 限制并发连接数
iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 50 -j REJECT

- Ubuntu系统推荐安装CSF防火墙:
apt install csf -y
csf -d 139.180.128.0/24 # 封禁特定IP段

2. Discuz系统层防护
修改config/config_global.php:
// 开启CC防护
$_config['security']['attackevasive'] = '1|2|4|8';

// 强制后台二次验证
$_config['admincp']['forcesecques'] = 1;

二、长效防御策略
1. IP地理封锁方案
推荐在Web服务器层实施:
- Apache方案(.htaccess):
SetEnvIf CF-IPCountry ^(CN|HK|MO|TW)$ AllowCountry
Order deny,allow
Deny from all
Allow from env=AllowCountry

- Nginx方案(需GeoIP模块):
geoip_country /usr/share/GeoIP/GeoIP.dat;
map $geoip_country_code $allowed_country {
    default no;
    CN yes;
    TW yes;
    HK yes;
    MO yes;
}

server {
    if ($allowed_country = no) {
      return 444;
    }
}

2. 推荐使用Cloudflare Pro版服务
- 配置步骤:
1) 域名NS切换到Cloudflare
2) 防火墙规则设置:
// 创建地理封锁规则
{
"description": "Block Non-ASN",
"expression": "(ip.geoip.country ne \"CN\" and ip.geoip.country ne \"TW\" and ip.geoip.country ne \"HK\" and ip.geoip.country ne \"MO\")",
"action": "block"
}

三、Discuz专项优化
1. 安全补丁更新
通过DZ插件网下载最新安全补丁包:
https://www.dz-x.net/security-patches

2. 核心文件校验
使用官方提供的校验工具:
// 上传check.php到根目录执行
define('IN_CHECK', true);
require './source/class/class_check.php';
$check = new check();
$check->index();

四、监控与日志分析
推荐部署Elastic Stack方案:
# 安装Filebeat日志采集
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.17.4-amd64.deb
dpkg -i filebeat-7.17.4-amd64.deb

# 配置Nginx日志格式
log_format json_analytics escape=json '{'
    '"time_local":"$time_local",'
    '"remote_addr":"$remote_addr",'
    '"request":"$request",'
    '"status":"$status",'
    '"body_bytes_sent":"$body_bytes_sent",'
    '"http_referer":"$http_referer",'
    '"http_user_agent":"$http_user_agent",'
    '"geoip_country_code":"$geoip2_data_country_code"'
'}';

特别提示:建议保留香港、台湾等地区IP白名单,可通过DZ插件网获取智能IP白名单系统(https://www.dz-x.net/ip-filter-pro)实现动态过滤。实施后请持续关注服务器负载和CPU使用率,建议每隔6小时检查一次防火墙日志。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
页: [1]
查看完整版本: 境外ip在攻击我们