Rootop 服务器运维与web架构

华为云服务器iptables中的自定义链IN_HIDS_MYSQLD_BIP_DROP和IN_HIDS_MYSQLD_DENY_DROP

测试环境日志报连不上测试数据库,本地测试可以远程连接。其它服务器也可以连接,tcp抓包有reset位,推测是什么安全机制断开了连接。

在 /var/log/messages 日志中发现有mysqld_drop的字眼,遂查看iptables规则

[4333361.597329] mysqld_drop: IN=eth0 OUT= MAC=fa:16:3e:c0:96:2a:fa:16:3e:90:0d:c4:08:00 SRC=124.70.xxx.xxx DST=192.168.0.38 LEN=60 TOS=0x00 PREC=0x00 TTL=56 ID=15889 DF PROTO=TCP SPT=54734 DPT=3306 WINDOW=29200 RES=0x00 SYN URGP=0 
[4333361.702625] mysqld_drop: IN=eth0 OUT= MAC=fa:16:3e:c0:96:2a:fa:16:3e:90:0d:c4:08:00 SRC=124.70.xxx.xxx DST=192.168.0.38 LEN=60 TOS=0x00 PREC=0x00 TTL=56 ID=30534 DF PROTO=TCP SPT=47370 DPT=3306 WINDOW=29200 RES=0x00 SYN URGP=0 
[4333362.150774] mysqld_drop: IN=eth0 OUT= MAC=fa:16:3e:c0:96:2a:fa:16:3e:90:0d:c4:08:00 SRC=124.70.xxx.xxx DST=192.168.0.38 LEN=60 TOS=0x00 PREC=0x00 TTL=56 ID=52149 DF PROTO=TCP SPT=44338 DPT=3306 WINDOW=29200 RES=0x00 SYN URGP=0 

# 服务器iptables规则

[root@ecs-38b6-0002 ~]#  iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
IN_HIDS_MYSQLD_BIP_DROP  tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3306
IN_HIDS_MYSQLD_DENY_DROP  tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:3306

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain IN_HIDS_MYSQLD_BIP_DROP (1 references)
target     prot opt source               destination         

Chain   (1 references)
target     prot opt source               destination         
LOG        all  --  124.70.xxx.xxx        0.0.0.0/0            LOG flags 0 level 4 prefix "mysqld_drop: "
REJECT     all  --  124.70.xxx.xxx        0.0.0.0/0            reject-with icmp-port-unreachable

发现多出来 IN_HIDS_MYSQLD_BIP_DROP 自定义链,这条链还被INPUT链引用了。而且规则中的ip是测试服的公网ip。
通过规则可以看出来自测试服的ip访问3306被丢弃+记录日志。

这2条链并不是我加的,发工单问华为云客服,客服也不知道,让排查是否自己安装。

ps查进程,发现有个hostguard进程

[root@ecs-38b6-0002 conf]# ps aux | grep hostguard
root      7361  0.0  0.0 112712   968 pts/0    S+   16:33   0:00 grep --color=auto hostguard
root      9206  0.0  0.0  49044  1468 ?        Ss   Jun17   9:34 /usr/local/hostguard/bin/hostguard
root     27978  0.1  0.0 1398848 7388 ?        Sl   Jul13  99:12 /usr/local/hostguard/bin/hostguard
[root@ecs-38b6-0002 conf]# cd /usr/local/hostguard/conf/
[root@ecs-38b6-0002 conf]# ll
total 2448
-r-------- 1 root root      32 May 14 13:00 agent.conf
-rw-r--r-- 1 root root     105 Aug 31 00:00 agentinfo
drwxr-xr-x 2 root root    4096 May 14 13:00 benchmarkconf
-r-------- 1 root root   14340 May 14 13:00 cmsvul.dat
-r-x------ 1 root root    1497 May 14 13:00 config_ssh_log.sh
-r-x------ 1 root root    3193 May 14 13:00 config_ssh_xinetd.sh
-r-------- 1 root root   35332 May 14 13:00 dict.dat
-rw-r--r-- 1 root root      33 Jun 17 12:28 lb.dat
-r-------- 1 root root 1751200 May 14 13:00 magic.mgc
-rw-r--r-- 1 root root      63 Aug 31 16:29 master.dat
-rw-r--r-- 1 root root       0 Aug 30 23:36 modlogin_deny.conf
-rw-r--r-- 1 root root       0 Jul 13 19:19 mysqld_iptables_bip
-rw-r--r-- 1 root root       0 Aug 28 11:21 mysqld_iptables_block
-rw-r--r-- 1 root root    5128 Jun 17 12:29 policy.dat
-rw-r--r-- 1 root root      24 Jul 13 19:18 priv_cpu.dat
-r-------- 1 root root      65 May 14 13:00 res.conf
-r-------- 1 root root   40181 May 14 13:00 rootkit.json
-r-------- 1 root root    3332 May 14 13:00 selfitgr.dat
-rw-r--r-- 1 root root      10 Aug 31 16:33 sending.dat
-r-------- 1 root root     149 Jun 17 12:28 system.conf
-r-------- 1 root root     426 May 14 13:00 user.key
-r-------- 1 root root      26 May 14 13:00 version
-r-------- 1 root root  590648 May 14 13:00 wsyrules.dat

发现也有mysql相关的文件,估计就是这个进程导致的了。查华为文档发现,hostguard是华为主机安全软件。
至于原因,推测是测试服发起了大量连接(有对mysql连接池操作过加大动作)或者大量的错误mysql认证,导致云服务器中的安全进程判断为不安全连接,直接给拒绝了。

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4854.html

作者:Venus

服务器运维与性能优化

评论已关闭。