2019/09/19

今天早上看mail收到DNS有問題的告警
本來以為是OS當了
看了之後OS還活著
再來想到的就是應該是更新後有問題
果然

看了一下更新的log

Sep 19 05:02:00 Updated: 32:bind-license-9.11.4-9.P2.el7.noarch
Sep 19 05:02:01 Installed: 32:bind-export-libs-9.11.4-9.P2.el7.x86_64
Sep 19 05:02:02 Updated: 32:bind-libs-lite-9.11.4-9.P2.el7.x86_64
Sep 19 05:02:03 Updated: 32:bind-libs-9.11.4-9.P2.el7.x86_64
Sep 19 05:02:18 Updated: 32:bind-9.11.4-9.P2.el7.x86_64
Sep 19 05:02:32 Updated: 32:bind-chroot-9.11.4-9.P2.el7.x86_64
Sep 19 05:02:39 Updated: 32:bind-utils-9.11.4-9.P2.el7.x86_64

錯誤訊息如下

Sep 19 08:05:09 dns2.edu.tw bash[754]: /etc/named.conf:166: writeable file 'named.rev0': already in use: /etc/...nf:59
Sep 19 08:05:09 dns2.edu.tw bash[754]: /etc/named.conf:204: writeable file 'named.rev1': already in use: /etc/...nf:93
Sep 19 08:05:09 dns2.edu.tw bash[754]: /etc/named.conf:214: writeable file 'named.rev2': already in use: /etc/...f:103
Sep 19 08:05:09 dns2.edu.tw bash[754]: /etc/named.conf:224: writeable file 'named.rev3': already in use: /etc/...f:113
Sep 19 08:05:09 dns2.edu.tw bash[754]: /etc/named.conf:234: writeable file 'named.rev4': already in use: /etc/...f:123
Sep 19 08:05:09 dns2.edu.tw bash[754]: /etc/named.conf:244: writeable file 'named.rev5': already in use: /etc/...f:133

查了一下相關資料

有人說可以使用 in-view 這個config
但試了之後發現沒用
文件上說明bind這個版本之後要把每個zone的file獨立出來
好吧
照做
建立link 使用不同的檔名
接下來改一下 /etc/named.conf
服務重啟
目前看來是正常了
再觀察看看
收工

2019/09/18

今天接到另一個問題
有人把graylog的index在沒有close情況下砍光了
然後出現了
graylog_deflector
這個index
砍了又會自動生出來
然後資料也進不去
本來想說再建一個indexset然後改成default再把原來的砍了
但 不行
找了半天
處理方法如下

Stop all Graylog nodes

(OPTIONAL) If you want to keep the already ingested messages, reindex them into the Elasticsearch index with the greatest number, e. g. graylog_23 if you want to fix the deflector graylog_deflector, via the Elasticsearch Reindex API.

Delete the graylog_deflector index via the Elasticsearch Delete Index API.


curl -u user:passwd -XDELETE http://10.0.0.0:9200/graylog_1


Add action.auto_create_index: false to the configuration files of all Elasticsearch nodes in your cluster and restart these Elasticsearch nodes, see Elasticsearch Index API - Automatic Index Creation and Creating an Index for details.

Start the Graylog master node.

Manually rotate the active write index of the index set on the System / Indices / Index Set page in the Maintenance dropdown menu.

(OPTIONAL) Start all remaining Graylog slave nodes.

https://community.graylog.org/t/graylog-error/10800

http://docs.graylog.org/en/3.0/pages/faq.html#how-do-i-fix-the-deflector-exists-as-an-index-and-is-not-an-alias-error-message

目前正常
觀察中

2019/09/07

昨天早上接到有人問graylog的問題 版本 3.0.2
說本來可以正常運作
但改完ip後
就收不到資料了
連進去看之後先df看了一下 發現HD的使用率很高
然後ES的log出現以下的訊息

[INFO ][cluster.routing.allocation.decider] [Milan] low disk watermark [15%] exceeded on [DZqnmWIZRpapZY_TPkkMBw][Milan] free: 58.6gb[12.6%], replicas will not be assigned to this node

徴求user同意後先把一個indices砍了

curl -u admin:password -XDELETE http://10.1.2.3:9200/graylog_0

HD使用率就下降了一半

再來在管理介面上 rotate active write index
 rotate active write index
可是下完後在管理介面上index就跑不出來了
去看了graylog的log出現以下訊息

elasticsearch.exceptions.AuthorizationException: AuthorizationException(403, 'cluster_block_exception', 'blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];')

只好再下指令 unlock

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

再關掉index

curl -u admin:password -XPOST 'http://10.1.2.3:9200/graylog_4/_close'

在管理介面上就可以看到index了
可是這個時候在search的介面出問題而不能search 
因為下完之前的指令出現了二個open的index

以下是列出所有index的指令
curl -u admin:password 'http://10.1.2.3:9200/_cat/indices/graylog*?v'

所以關掉一個後就正常了

curl -u admin:password -XPOST 'http://10.1.2.3:9200/graylog_5/_close'

到此在log裡就沒有看到任何error

可是訊息還是沒看到而且process buffer一直在100%
用top去看 java也吃掉了大量的cpu
我在猜是不是extractor的問題
因為還要去處理別的問題
所以就先斷線了

後記

之後user有再連絡說log已經有進來了
可能是之前塞住的message消化完了
所以就再觀察看看

2019/09/01

如何在dns 上使用iptablse 阻擋惡意domain

/tmp/malice_domain_today 這個檔案是惡意domain的list

#!/bin/bash

IFS=.

while read line
do

        echo -n '/usr/sbin/iptables -A INPUT -p udp --dport 53 -m string --hex-string "'

        for i in $line
        do

                echo -n "\|"
                echo -n ${#i}
                echo -n "\|"
                echo -n $i

        done
        echo '" --algo bm -j DROP'
done < /tmp/malice_domain_today > /tmp/iptables_block_command

/usr/sbin/iptables -F
/usr/sbin/iptables -X

/usr/bin/bash /tmp/iptables_block_command




https://www.perturb.org/display/1186_Linux_Block_DNS_queries_for_specific_zone_with_IPTables.html?utm_source=linuxnewssite.com