2020/06/22

弱掃開始

202002版的kali linux
預設的 user pwd
改成了

kali
kali


安裝openvas

sudo apt update

sudo apt install openvas

裝完後手動下

sudo openvas-setup

經過漫長的等待後會出現開好 admin這個user及一組密碼
千萬要記得複制下來


https://127.0.0.1:9392

登入後第一件事就是改時區及密碼


接下來就開始執行scan 了



























看來cpu還要再給多一點 用 16 個來跑差不多

問題來了
本次的弱掃報告每個 host 都出現以下的訊息




但是kali linux也沒有提供更新了
如果不能接受
就要另外想辦法了

2020/06/20

記錄一下proxmox lxc的使用情況

最近在測試 adguard
裝在lxc 上 感覺效能不能
1個cpu 512M ram
每天五百萬次的query 沒問題

但測試只有上線一台
這几天proxmox要升kernel
host必須得重開
可是lxc無法在短時間 migrate 而且一定要shutdown 再 reboot
本來想說把storage搬到nfs上可以解決
migrate是加快了 可是還是得 reboot
但最大的問題來了
搬到nfs後要backup時 lxc 必需要 suspend

WTF

看來還是只能使用kvm的guest來做了

2020/06/18

今天更新ocs inventory的 agent
從上一版開始就分為 x32跟x64二個版本
在處理完x32後發生以下的問題







看來是少了 visual c 的dll

把這三個檔手動補到ocs的目錄內就可以了




2020/06/11

最近二次升級完graylog後
都發生原本的log server資料吐不過來的情況
明明daemon都還在
目前的處理方式就是把log server上的rsyslog重啟
或直接重開 log server
還找不出原因

2020/06/06

因為被要求要偵測空間裡的CO2含量
所以就想用 raspberry加上一個模組來完成
另外由於是佈建在各個點
所以考量日後維護,佈線及電源的方便度
最後決定使用respberry的poe hat來供電
但卻碰到了一件超鳥的事

poe有供電但網路不會通
WTF
第一次碰到這種
查了半天
最後發現竟然是OS語系的問題
因為在安裝的第一步就是要選語系及時區和keyboard
可是時區沒法單獨選
所以我把語系選成taiwan
這樣時區也就會自動改
也因為醬
所以才造成上面的問題
如果要使用poe hat
請特別小心


https://www.raspberrypi.org/forums/viewtopic.php?t=222293

2020/06/01

2020/04/16

ubuntu 18.04 安裝 jupyter 讓遠端可以開browser使用


sudo apt install python3 python3-pip

sudo apt install python3-matplotlib (畫圖使用 視需求安裝)

pip3 install jupyter

sudo apt install jupyter-core

sudo apt install jupyter-notebook

jupyter notebook --generate-config

Writing default config to: /home/user/.jupyter/jupyter_notebook_config.py


加上登入密碼

jupyter notebook password
Enter password:
Verify password:
[NotebookPasswordApp] Wrote hashed password to /home/user/.jupyter/jupyter_notebook_config.json

修改  /home/user/.jupyter/jupyter_notebook_config.py
檔案尾端加上

c = get_config()
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5678
c.NotebookApp.notebook_dir = '/tmp'

啟動 jupyter

jupyter notebook


就可以在別台几器上開browser
http://server_ip:5678
http://server_ip:5678
登入


簡單記一下ipython 跟 notebook的安裝設定過程 讓遠端可以存取

先安裝

sudo apt install -y ipython ipython-notebook ipython-notebook-common

產生 config file
ipython profile create nbserver

使用ipython產生密碼 hash

In [1]: from notebook.auth import passwd
In [2]: passwd()

Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

修改

/home/user/.ipython/profile_nbserver/ipython_notebook_config.py

在檔案最後加上

c = get_config()
c.NotebookApp.ip = ‘*’
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5678
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'


啟動server
ipython notebook

接下來就可以在遠方使用browser

http://server_ip:5678

登入使用了

2020/04/08

又是librenms的問題

/opt/librenms/daily.sh
出現

Fatal error: require(): Failed opening required '/opt/librenms/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/librenms/vendor/composer/autoload_real.php on line 69
PHP Fatal error:  require(): Failed opening required '/opt/librenms/vendor/composer/../symfony/polyfill-mbstring/bootstrap.php' (include_path='.:/usr/share/pear:/usr/share/php') in /opt/librenms/vendor/composer/autoload_real.php on line 69

跑一下

/opt/librenms/validate.php

[FAIL]  Missing dependencies!
[FIX]:
/opt/librenms/scripts/composer_wrapper.php install --no-dev

執行 /opt/librenms/scripts/composer_wrapper.php install --no-dev

/opt/librenms/scripts/composer_wrapper.php install --no-dev
> LibreNMS\ComposerHelper::preInstall
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 3 installs, 38 updates, 0 removals
  - Installing symfony/polyfill-mbstring (v1.15.0): Downloading (100%)       
  - Updating symfony/polyfill-intl-idn (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating egulias/email-validator (2.1.11 => 2.1.17): Downloading (100%)       
  - Updating erusev/parsedown (1.7.3 => 1.7.4): Downloading (100%)       
  - Updating symfony/polyfill-ctype (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating phpoption/phpoption (1.5.2 => 1.7.3): Downloading (100%)       
  - Updating vlucas/phpdotenv (v3.6.0 => v3.6.2): Downloading (100%)       
  - Updating symfony/css-selector (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/var-dumper (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/routing (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/process (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/polyfill-php73 (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating symfony/mime (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/http-foundation (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/event-dispatcher (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating psr/log (1.1.2 => 1.1.3): Downloading (100%)       
  - Updating symfony/debug (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/error-handler (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/http-kernel (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/finder (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/console (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating symfony/polyfill-iconv (v1.12.0 => v1.15.0): Downloading (100%)       
  - Updating ramsey/uuid (3.8.0 => 3.9.3): Downloading (100%)       
  - Updating opis/closure (3.4.1 => 3.5.1): Downloading (100%)       
  - Updating symfony/translation (v4.4.0 => v4.4.7): Downloading (100%)       
  - Updating nesbot/carbon (2.27.0 => 2.32.2): Downloading (100%)       
  - Updating monolog/monolog (1.25.2 => 1.25.3): Downloading (100%)       
  - Updating league/flysystem (1.0.57 => 1.0.66): Downloading (100%)       
  - Updating laravel/framework (v5.8.35 => v5.8.37): Downloading (100%)       
  - Updating fico7489/laravel-pivot (3.0.3 => 3.0.4): Downloading (100%)       
  - Updating fideloper/proxy (4.2.1 => 4.3.0): Downloading (100%)       
  - Updating guzzlehttp/guzzle (6.4.1 => 6.5.2): Downloading (100%)       
  - Updating martinlindhe/laravel-vue-i18n-generator (0.1.42 => 0.1.46): Downloading (100%)       
  - Installing phpseclib/phpseclib (2.0.26): Downloading (100%)       
  - Updating php-amqplib/php-amqplib (v2.0.2 => v2.11.1): Downloading (100%)       
  - Updating phpmailer/phpmailer (v6.1.3 => v6.1.5): Downloading (100%)       
  - Removing dnoegel/php-xdg-base-dir (0.1)
  - Installing dnoegel/php-xdg-base-dir (v0.1.1): Downloading (100%)       
  - Updating psy/psysh (v0.9.9 => v0.9.12): Downloading (100%)       
  - Updating symfony/dotenv (v3.4.35 => v3.4.39): Downloading (100%)       
  - Updating symfony/yaml (v4.4.0 => v4.4.7): Downloading (100%)       
  - Installing doctrine/cache (1.10.0): Downloading (100%)       
Generating optimized autoload files
Deprecation Notice: Class HTMLPurifier_Language_en_x_test located in ./vendor/ezyang/htmlpurifier/library/HTMLPurifier/Language/classes/en-x-test.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Crypt_CHAP_MD5 located in ./vendor/dapphp/radius/lib/Pear_CHAP.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Crypt_CHAP_MSv1 located in ./vendor/dapphp/radius/lib/Pear_CHAP.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Crypt_CHAP_MSv2 located in ./vendor/dapphp/radius/lib/Pear_CHAP.php does not comply with psr-0 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///opt/librenms/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: darkghosthunter/larapoke
Discovered Package: fideloper/proxy
Discovered Package: laravel/laravel
Discovered Package: laravel/tinker
Discovered Package: martinlindhe/laravel-vue-i18n-generator
Discovered Package: nesbot/carbon
Discovered Package: oriceon/toastr-5-laravel
Discovered Package: spatie/laravel-cors
Discovered Package: tightenco/ziggy
Package manifest generated successfully.
26 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> LibreNMS\ComposerHelper::postInstall
> Illuminate\Foundation\ComposerScripts::postInstall
> @php artisan vue-i18n:generate --multi-locales --format=umd

再跑一次 validate.php

[librenms@librenms ~]$ ./validate.php
====================================
Component | Version
--------- | -------
LibreNMS  | 1.62-28-g5f2eab0
DB Schema | 2020_03_25_165300_add_column_to_ports (161)
PHP       | 7.2.27
MySQL     | 5.5.64-MariaDB
RRDTool   | 1.4.8
SNMP      | NET-SNMP 5.7.2
====================================

[OK]    Composer Version: 1.10.1
[OK]    Dependencies up-to-date.
[OK]    Database connection successful
[OK]    Database schema correct
[FAIL]  Some folders have incorrect file permissions, this may cause issues.
[FIX]:
sudo chown -R librenms:librenms /opt/librenms
sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
Files:
/opt/librenms/storage/framework/views/95a740c2fd790034ee55f5aee95726c8


chown -R librenms:librenms /opt/librenms
setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/
chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/


跑完後就ok了

2020/03/27

最近某台設備持續出現如下的訊息

Mar 25 22:52:50 192.168.250.50 128: 000124: Mar 25 22:52:50 GMT+8: %PM-4-ERR_DISABLE: storm-control error detected on Gi1/0/5, putting Gi1/0/5 in err-disable state

之前出現的原因都是因為下接的L2 switch 有loop產生
但這次在L2 swtich上都沒發現相關的log

原本的設定是 pps 500時會把port 直接關掉

storm-control broadcast level pps 500
storm-control action shutdown

先改成限制

storm-control broadcast level pps 500 150

再觀察看看

2020/03/21

之前發過一篇如何在graylog2啟用Geo的文章

升到graylog3後有些變化
以下記錄一下
首先是geoip的資料必需要先註冊才能取得
如果要自動更新 需要先產生license key
產生後下載 GeoIP.conf
https://www.maxmind.com/en/accounts/current/license-key
接下來依照說明進行安裝更新

https://github.com/maxmind/geoipupdate

https://dev.maxmind.com/geoip/geoip2/geolite2/

取得資料後把 GeoLite2-City.mmdb 放在 /etc/graylog/server 裡
接下來到 sysem - configurations


















勾選 enable enable 然後 save save 就好了

步驟比之前少了很多


graylog原本有解析出ip的欄位就會多了以下三個欄位











再來就可以利用解析出來的資料畫出以下的圖形了





2020/03/19

https://github.com/raryelcostasouza/pyTranscriber/

超好用的聲音轉文字軟体
有逐字稿跟上字幕需求的
大力推薦

2020/02/27

收到librenms 更新錯誤的訊息

Updating to latest codebase                        FAIL
error: Your local changes to the following files would be overwritten by merge:
        html/js/lang/de.js
        html/js/lang/en.js
        html/js/lang/fr.js
        html/js/lang/ru.js
        html/js/lang/uk.js
        html/js/lang/zh-TW.js
Please, commit your changes or stash them before you can merge.
Aborting

解決方法如下

/opt/librenms/scripts/github-remove -d

再重跑一次 daily.sh

2020/02/24

最近想拿raspberry pi 來當thin client
本來是想用spice
但mouse 一直有 lag的問題
改用rdp

raspberry用的是raspbian

碰到了開机要叫起rdesktop的問題
查了很多方法都不成功
最後記一下可行的方法


/etc/xdg/lxsession/LXDE-pi/autostart
最後一行加上
@lxterminal


在 /home/pi/.bashrc 最後一行加上

rdesktop -u user 10.0.0.1 -f -r sound:local -p1234

方法二

vi /home/pi/rdp.sh

rdesktop -u user 10.0.0.1 -f -r sound:local -p1234

cp /etc/xdg/lxsession/LXDE-pi/autostart /home/pi/.config/lxsession/LXDE-pi/autostart

vi /home/pi/.config/lxsession/LXDE-pi/autostart
在最後加上

@lxterminal -e '/home/pi/rdp.sh'


若win10的使用者未設定密碼
需要更改原則才能連線
而且開啟連線未登入
15秒就會自動斷線
所以建議user要設定密碼

持續測試發現一個問題
如果我把vm關掉
rdesktop會整個畫面卡住 不會自己關掉

於是使用xfreerdp

xfreerdp /v:10.0.0.1 /u:user /p:1234 /cert-ignore /f

xfreerdp /v:10.0.0.1 /u:user /p:1234 /cert-ignore /f /sound

再看看有什麼問題

2020/01/08

目前在suricata設定白名單的做法

在/etc/suricata/rules新增 pass.rules
內容如下

pass ip 10.0.0.1 any -> any any (msg:"pass all traffic from 10.0.0.1"; sid:9999999;)
pass ip 10.0.0.2 any -> any any (msg:"pass all traffic from 10.0.0.2"; sid:9999998;)

修改紅字部分
注意 sid 不可重複

在 /etc/suricata/suricata.yaml 把上面的rules引用進來

systemctl restart suricata
最近几次cacti的更新都一直有問題
所以都要倒回之前的備份
手動修改後
再做一次
這次是要把
/usr/share/cacti/install/upgrades/1_2_8.php
內的這行刪掉
db_install_execute('ALTER TABLE host_snmp_cache MODIFY COLUMN snmp_index VARCHAR(255) NOT NULL default ""');

查了一下好像目前的mariadb的版本沒辦法醬操作 要升版

今天先把mariadb升級
先保留php-5.4.16-46.1.el7_7.x86_64
下次cacti升級再看看有什麼問題
再來處理

新增以下檔案
/etc/yum.repos.d/mariadb.repo

內容如下
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
改好後直接 yum -y update
mariadb就會直接升了

再來要 mv /etc/my.cnf /etc/my.cnf_old 不然db會起不來

接下來照文件改

Add variables in the [mysqld] section.

collation-server = utf8mb4_unicode_ci
character-set-server=utf8mb4
max_heap_table_size = 64M
tmp_table_size = 64M
join_buffer_size = 64M
innodb_file_format = Barracuda
innodb_large_prefix = 1
innodb_flush_log_at_timeout = 3
innodb_buffer_pool_size = 1GB
innodb_buffer_pool_instances = 10
# Based on what type for storage you use. The below values are for SSD drives.
# Change it if Cacti reports issues during the installation
innodb_read_io_threads = 32
innodb_write_io_threads = 16
innodb_io_capacity = 5000
innodb_io_capacity_max = 10000

db重啟就好了 

再把這個補上去
ALTER TABLE host_snmp_cache MODIFY COLUMN snmp_index VARCHAR(255) NOT NULL default ""


https://www.itzgeek.com/how-tos/linux/centos-how-tos/monitor-network-using-cacti-with-centos-7-rhel-7.html
snort suricata
gryalog 的 extractor

suricata

%{WORD:source} %{WORD:UNWANTED}\[%{DATA:UNWANTED}\]: \[%{DATA:suricata_sig_id}\] %{DATA:suricata_msg} \[Classification\: %{DATA:suricata_classification}\] \[Priority\: %{DATA:suricata_priority}\] \{%{DATA:protocol}\} %{IPV4:src_ip}\:%{DATA:srcport} \-\> %{IPV4:dst_ip}\:%{DATA:dstport}$


snort

\[%{DATA:snort_sig_id}\] %{DATA:snort_msg} \[Classification\: %{DATA:snort_classification}\] \[Priority\: %{DATA:snort_priority}\] \{%{DATA:protocol}\} %{IPV4:src_ip}\:%{DATA:srcport} \-\> %{IPV4:dst_ip}\:%{DATA:dstport}$

2020/01/04

目前手边還有一台 graylog2 的 ova
因為是 ubuntu 14.04的版本
而且 elasticsearch 也EOL
之前就一直想upgrade
只是一直沒動作

因為有10T的資料
不太可能花時間去搬
目前想保留然後再架一台新的graylog3 ova

graylog2改ip要重跑 graylog-ctl reconfigure

但跑了二次 跑完後就掛了

所以改用另一個方式
在graylog2上起一個output output 把資料送到 graylog3
同時保留二份
然後graylog2再慢慢砍資料
最後把graylog2 關几
把graylog3改成graylog2的ip
graylog3改ip只要重開几就好
不用再其他設定 很方便

找出最舊index並刪除的 shell 如下

#!/bin/bash

i=`/usr/bin/curl -u admin:passwd 'http://10.0.0.1:9200/_cat/indices/graylog*?v'|grep close|awk '{print $2}'|sort -rn -t_ -k 2|tail -n 1`
echo $i
/usr/bin/curl -XDELETE "http://10.0.0.1:9200/$i/"


另外 graylog3 ova 使用的是 ubuntu 18.04
預設的網路設定方式是 netplan
用的實在不順
如果要改回 /etc/network/interfaces
要先安裝 ifupdown

sudo apt install ifupdown

設定好 /etc/network/interfaces

再 rm -rf /etc/netplan/*

重開几即可

2020/01/03

proxmox 預設使用 mtu 1500
在10G的環境要改為 9000
在以下檔案加上紅色的那行

/etc/network/interfaces

auto vmbr0
iface vmbr0 inet static
        address 10.0.0.1
        netmask 255.0.0.0
        gateway 10.0.0.254
        bridge_ports enp11s0
        bridge_stp off
        bridge_fd 0
        mtu 9000

如果是在 1G 10G 混用的環境下要注意
目前發現調完後會出現無法掛載某些nfs的情況

2019/12/28

又到了半年一度的弱掃時間
使用的是kali linux 2019.4 的版本
本來是想裝完後直接 apt install openvas
可是用 Kali Linux Light 64-Bit 這個iso裝完後
竟然找不到 openvas
算了
只好再繼續用virtualbox的image
安裝執行都OK

這次的問題是出現了不少FP
所以必須在管理介面上調整

首先點進 scan - report
再點進要調整的report
就會看到所有的細項報告
接下來點撃該細項報告最右方的圖示






就可以調整new severity



2019/12/05

今天偶然發現librenms好像好久沒更新了
一看果然從6月後都沒更新
查了一下官網
最新版本是11月
馬上下指令
daili.sh
也沒有更新的訊息
再去communuty看了一下
現在要醬下指令更新了

su - librenms
git pull
./daily.sh

之前只要更新大多有問題
這次做完還好
再觀察看看

https://community.librenms.org/

2019/11/28

這几天在玩MHN

感覺還不錯
不過有些地方要注意
試了好久

首先裝server
依照官網的說明沒什麼問題
我是用 ubuntu 18.04

再來是佈署 sensor

網頁介面上有提供deploy的script

官網上有提到有些sensor可以裝在centos
不過網頁介面上的都是for ubuntu跟 respberry pi
有很多sensor可以選擇
不同sensor有不同的功能
不過不是每個都可以用
這地方試了好久

最後我選了 Dionaea
官網上是說只能裝在 Ubuntu 14.04/Centos 7
其他版本有問題
不過我裝在ubuntu 18.04是ok的
只是安裝過程中碰到以下的問題

E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/libe/libemu/libemu2_0.2.0+git20120122-1.2build1_amd64.deb  403  Forbidden [IP: 91.189.88.173 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

最後解決的方法是直接下載這個檔然後 dpkg -i
之後就沒問題了
介面還可以接受
資料是放在mongodb裡
也提供 rest可以撈
不過沒找到完整文件
另外就是直接使用mongoexport把資料撈出來
要注意的是mongodb時間是ISODate
如果用bash shell要記得轉換時間

date -u -Ins

每十分鐘從mongodb撈出資料

#!/bin/bash

date -d '10 mins ago' -u -Ins |cut -d ',' -f 1 > /tmp/time
echo "DBQuery.shellBatchSize = 3000000" > /tmp/get10min.js
echo "use mnemosyne" >> /tmp/get10min.js
echo 'db.session.find({"timestamp":{$gt:ISODate("'`cat /tmp/time`'")}})' >> /tmp/get10min.js

mongo < /tmp/get10min.js > /tmp/mhn_10min_data


https://github.com/pwnlandia/mhn

https://github.com/pwnlandia/mhn/wiki/List-of-Supported-Sensors

https://github.com/pwnlandia/mhn/wiki/MHN-REST-APIs

https://github.com/pwnlandia/mhn/wiki/Exporting-Honeypot-Data-from-MHN

https://www.itread01.com/content/1545640216.html

2019/11/22

今天在下grep 指令時出現以下的訊息

Binary file /tmp/test matches

查了一下說是因為檔案是binary file 無法執行grep 指令
明明就是text file
解決方式是強制指定為txt
指令

grep -a abc /tmp/test

2019/11/21

目前有三台ES
在graylog上設定 

shards = 3
replicas = 1

在index set看到每天的量大約 100G左右

對應到每一台ES的空間大約是 70G

所以算法就是

100G * 2 = 200 G

然後再分配到3台

200G / 3 就大約等於 70G 因為還要加上 index 所以會大一些

2019/11/13

今天在使用mutt時一直出現以下的錯誤
找了半天還是沒有答案

mutt -s 'test' abc@de.com -a /tmp/test < test

SMTP session failed: 500 5.5.2 Error: bad UTF-8 syntax
Could not send the message.

改用

/usr/bin/mail -a /tmp/test1 -a /tmp/test2 -S smtp="10.0.0.1:25" -r "from@dde.com" -s 'test' to@de.com < test

https://www.binarytides.com/linux-mailx-command/

2019/11/06

剛剛在設定.muttrc從hinet寄信的時候

設ip不能寄
set smtp_url = "smtp://168.95.4.10:25/"

要設fqdn才能寄
set smtp_url = "smtp://msa.hinet.net:25/"

什麼怪事都有

http://nengfang.blogspot.com/2014/07/hinet-isp-smtp-server.html

2019/11/01

今天模擬在一台graylog server 三個ES node的環境
然後當有一台ES fail時要怎麼處理

首先我們先看一下目前ES的狀況
有三個node
status也是green

curl -XGET http://192.168.12.201:9200/_cluster/health?pretty
{
  "cluster_name" : "graylog",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 11,
  "active_shards" : 14,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

再來看一下目前所有shards的狀況

curl -XGET 192.168.12.203:9200/_cat/shards
gl-events_0        3 p STARTED 0 230b 192.168.12.202 es-node-02
gl-events_0        2 p STARTED 0 230b 192.168.12.201 es-node-1
gl-events_0        1 p STARTED 0 230b 192.168.12.203 es-node-03
gl-events_0        0 p STARTED 0 230b 192.168.12.202 es-node-02
graylog_3          2 r STARTED 1  7kb 192.168.12.203 es-node-03
graylog_3          2 p STARTED 1  7kb 192.168.12.201 es-node-1
graylog_3          1 r STARTED 1  7kb 192.168.12.202 es-node-02
graylog_3          1 p STARTED 1  7kb 192.168.12.201 es-node-1
graylog_3          0 p STARTED 1  7kb 192.168.12.202 es-node-02
graylog_3          0 r STARTED 1  7kb 192.168.12.203 es-node-03
gl-system-events_0 3 p STARTED 0 230b 192.168.12.203 es-node-03
gl-system-events_0 2 p STARTED 0 230b 192.168.12.202 es-node-02
gl-system-events_0 1 p STARTED 0 230b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED 0 230b 192.168.12.203 es-node-03



我們關掉其中一個ES node 192.168.12.202 模擬故障

查看整個cluster狀況
nodes變成2
status也變為red

curl -XGET http://192.168.12.201:9200/_cluster/health?pretty
{
  "cluster_name" : "graylog",
  "status" : "red",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 8,
  "active_shards" : 9,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 5,
  "delayed_unassigned_shards" : 5,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 64.28571428571429
}

再來看一下shards的狀況
192.168.12.202這個node己經不見了
而且上面的shards 變成 UNASSIGNED

curl -XGET 192.168.12.203:9200/_cat/shards
gl-system-events_0 3 p STARTED    0 261b 192.168.12.203 es-node-03
gl-system-events_0 2 p UNASSIGNED                       
gl-system-events_0 1 p STARTED    0 261b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED    0 261b 192.168.12.203 es-node-03
graylog_3          2 r STARTED    1  7kb 192.168.12.203 es-node-03
graylog_3          2 p STARTED    1  7kb 192.168.12.201 es-node-1
graylog_3          1 r STARTED    1  7kb 192.168.12.203 es-node-03
graylog_3          1 p STARTED    1  7kb 192.168.12.201 es-node-1
graylog_3          0 p STARTED    1  7kb 192.168.12.203 es-node-03
graylog_3          0 r STARTED    1  7kb 192.168.12.201 es-node-1
gl-events_0        3 p UNASSIGNED                       
gl-events_0        2 p STARTED    0 261b 192.168.12.201 es-node-1
gl-events_0        1 p STARTED    0 261b 192.168.12.203 es-node-03
gl-events_0        0 p UNASSIGNED


找一台机器重裝ES後並重新加入cluster


先看一下狀況
nodes己經回來變成3了
可是status還是red

curl -XGET http://192.168.12.201:9200/_cluster/health?pretty
{
  "cluster_name" : "graylog",
  "status" : "red",
  "timed_out" : false,
  "number_of_nodes" : 3,
  "number_of_data_nodes" : 3,
  "active_primary_shards" : 8,
  "active_shards" : 11,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 3,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 78.57142857142857
}

再來看shards的狀況
還是 UNASSIGNED 並沒有復原

curl -XGET 192.168.12.203:9200/_cat/shards
gl-system-events_0 3 p STARTED    0 261b 192.168.12.203 es-node-03
gl-system-events_0 2 p UNASSIGNED                       
gl-system-events_0 1 p STARTED    0 261b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED    0 261b 192.168.12.203 es-node-03
graylog_3          2 r STARTED    1  7kb 192.168.12.203 es-node-03
graylog_3          2 p STARTED    1  7kb 192.168.12.201 es-node-1
graylog_3          1 r STARTED    1  7kb 192.168.12.203 es-node-03
graylog_3          1 p STARTED    1  7kb 192.168.12.201 es-node-1
graylog_3          0 p STARTED    1  7kb 192.168.12.203 es-node-03
graylog_3          0 r STARTED    1  7kb 192.168.12.201 es-node-1
gl-events_0        3 p UNASSIGNED                       
gl-events_0        2 p STARTED    0 261b 192.168.12.201 es-node-1
gl-events_0        1 p STARTED    0 261b 192.168.12.203 es-node-03
gl-events_0        0 p UNASSIGNED


查了資料說可以 reroute share
但實作上有問題無法執行


目前試出來的做法是先關掉graylog server

systemctl stop graylog-server.service

接下來把所有的 UNASSIGNED 砍了

curl -XDELETE '192.168.12.201:9200/gl-system-events_0/'

curl -XDELETE '192.168.12.201:9200/gl-events_0'

砍完後再去看shards

curl -XGET 192.168.12.203:9200/_cat/shards
graylog_3 2 r STARTED 1 7kb 192.168.12.203 es-node-03
graylog_3 2 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 1 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 1 p STARTED 1 7kb 192.168.12.201 es-node-1
graylog_3 0 r STARTED 1 7kb 192.168.12.202 es-node-02
graylog_3 0 p STARTED 1 7kb 192.168.12.203 es-node-03

這個是原本的資料檔
而且有設定 Index replicas

重啟graylog server

graylog會把剛剛砍掉的 gl-system-events_0 gl-events_0 建回來
收集的資料是放在 graylog_* 所以不會有影響

再看一次shards
全部都正常了

curl -XGET 192.168.12.203:9200/_cat/shards
gl-system-events_0 3 p STARTED 0 230b 192.168.12.203 es-node-03
gl-system-events_0 2 p STARTED 0 230b 192.168.12.202 es-node-02
gl-system-events_0 1 p STARTED 0 230b 192.168.12.201 es-node-1
gl-system-events_0 0 p STARTED 0 230b 192.168.12.203 es-node-03
graylog_3          2 r STARTED 1  7kb 192.168.12.203 es-node-03
graylog_3          2 p STARTED 1  7kb 192.168.12.201 es-node-1
graylog_3          1 r STARTED 1  7kb 192.168.12.202 es-node-02
graylog_3          1 p STARTED 1  7kb 192.168.12.201 es-node-1
graylog_3          0 r STARTED 1  7kb 192.168.12.202 es-node-02
graylog_3          0 p STARTED 1  7kb 192.168.12.203 es-node-03
gl-events_0        3 p STARTED 0 230b 192.168.12.202 es-node-02
gl-events_0        2 p STARTED 0 230b 192.168.12.201 es-node-1
gl-events_0        1 p STARTED 0 230b 192.168.12.203 es-node-03
gl-events_0        0 p STARTED 0 230b 192.168.12.202 es-node-02


所以記得 Configure Index Set 要設定Index replicas 至少為1
Index shards的數量就根据你ES node的數量來設定
如果ES node 有三個 就設定為3




2019/10/26

Load Balancing in NGINX

今天有人問graylog的三個node怎麼做load balance
想到之前玩過haproxy
可是查了一下資料
haproxy不支援UDP的load balance
nginx目前已經有支援了
設定方法如下

udp loadbalance

# Load balance UDP‑based DNS traffic across two servers
stream {
    upstream dns_upstreams {
        server 192.168.1.1:53;
        server 192.168.1.2:53;
    }

    server {
        listen 53 udp;
        proxy_pass dns_upstreams;
        proxy_timeout 1s;
        proxy_responses 1;
        error_log logs/dns.log;
    }
}

=============================================================

tcp load balance

upstream mytest {
server 192.168.2.1 weight=3;
server 192.168.2.2 weight=2;
}
server {
listen 443 ssl;
server_name my.test.tw;
access_log /var/log/nginx/my.test.tw.access.log main;
error_log /var/log/nginx/my.test.tw.error.log warn;
ssl_certificate my.test.tw.crt;
ssl_certificate_key my.test.tw.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
proxy_pass http://mytest;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}


https://blog.dtask.idv.tw/Nginx/2018-07-31/

https://www.nginx.com/blog/announcing-udp-load-balancing/
proxmox mail gateway 的 clamav-daemon
時不時就會出現fail的狀況
因為pmg本來就有自我檢查機制
所以想說不管他
可是今天看到後
手動去重啟
又馬上fail
覺得很怪
查了一下log


Oct 26 06:39:53 mg kernel: [765738.983038] Memory cgroup stats for /lxc/124/ns/system.slice/clamav-freshclam.service: cache:1696KB rss:1100KB rss_huge:0KB shmem:0KB mapped_file:0KB dirty:528KB writeback:1056KB swap:660KB inactive_anon:720KB active_anon:356KB inactive_file:4KB active_file:4KB unevictable:0KB
Oct 26 06:39:53 mg kernel: [765738.983052] Memory cgroup stats for /lxc/124/ns/system.slice/clamav-daemon.service: cache:1508KB rss:1760KB rss_huge:0KB shmem:0KB mapped_file:0KB dirty:0KB writeback:660KB swap:0KB inactive_anon:0KB active_anon:0KB inactive_file:0KB active_file:0KB unevictable:0KB
Oct 26 06:39:53 mg kernel: [765738.983088] Memory cgroup stats for /lxc/124/ns/system.slice/clamav-daemon.service: cache:68KB rss:44KB rss_huge:0KB shmem:0KB mapped_file:0KB dirty:396KB writeback:0KB swap:0KB inactive_anon:0KB active_anon:0KB inactive_file:0KB active_file:0KB unevictable:0KB
Oct 26 06:39:53 mg kernel: [765738.983097] Memory cgroup stats for /lxc/124/ns/system.slice/clamav-daemon.service: cache:0KB rss:92KB rss_huge:0KB shmem:0KB mapped_file:0KB dirty:396KB writeback:0KB swap:132KB inactive_anon:0KB active_anon:0KB inactive_file:0KB active_file:0KB unevictable:0KB
Oct 26 06:39:53 mg kernel: [765739.020710] oom_reaper: reaped process 4167 (clamd), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Oct 26 06:39:53 mg systemd[1]: clamav-daemon.service: Main process exited, code=killed, status=9/KILL

找了相關文章
都說是ram不夠的問題
目前是2G
先加到4G看看吧

2019/10/25

graylog上的三個node 總有一個會時出現時不出現
查了一下log
發現一直出現以下的訊息

Did not find meta info of this node. Re-registering.

搜尋了一下
几乎講的都是因為server沒有對時的關係
所以如果有建cluster環境的
切記要注意對時

但是在vmware的環境中
設完chrony對時
還是一直會出現秒差
只能去修改參數

stable_master_timeout = 60000

預設值為2000 就是 2秒
目前先改為60秒 再觀察看看
重啟graylog

後來想起來 vmware一直有時間不準的問題
想不到到現在還沒改善

2019/10/22

使用LXC的proxmox mail gateway 發生不能logratate的解法

options features 裡的 nesting要打開

https://forum.proxmox.com/threads/logrotate-issue-in-buster-lxc.56726/
今天整理graylog的時候發現一件事

目前我在index set的設定是留180天
超過的delete
不過我會手動去close index
只留約一個月的資料 查詢效率比較好
可是今天發現index超過了180天但系統並沒有去delete
我不確定是不是因為我手動去close的關係
如果真的是如此的話 那政策就要改成定時close
然後再手動去delete了
手動砍的shell如下
每天找出最舊的index再砍掉

#!/bin/bash

del_idx=`/usr/bin/curl -u admin:password 'http://127.0.0.1:9200/_cat/indices/graylog*?v'|grep close|awk '{print $2}'|sort -rn -t_ -k 2|tail -n 1`

/usr/bin/curl -XDELETE "http://localhost:9200/$del_idx/"

用crontab 來做吧

2019/10/21

proxmox mail gateway

預設不會去記錄信件主旨
因此要查找的時候有些不方便
修改方法如下

在 /etc/postfix/main.cf最後增加一行如下

header_checks = regexp:/etc/postfix/header_checks

建立 /etc/postfix/header_checks 這個檔 內容如下

/^Subject:/      WARN

接下來重啟服務
systemctl restart postfix

之後就可以在 /var/log/mail.log看到如下的log

Oct 21 06:43:49 mg postfix/cleanup[19866]: 74A29109C: warning: header Subject: Congratulate Jimmy (Gin-der) Peng for... from mailc-ab.linkedin.com[108.174.3.162]; from=<s-2f4oc1y30l5mpjzdxdjdkon8civu58akgxu9lf1h23ha66tmdhfi46d4@bounce.linkedin.com> to=<abc@de.com> proto=ESMTP helo=<mailc-ab.linkedin.com>

以上的方法在几器重開後 config就會被改回來

找到另一個方法
直接去改pmg的perl

First, add this somewhere between the 'use' statements at the beginning of the file:

use PVE::Tools;

Then search for this line:

$self->log (3, "$queue->{logid}: new mail message-id=%s", $queue->{msgid});

Add the following below that line:

$self->log (3, "$queue->{logid}: Subject: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($entity->head->get('subject'))) || 'No Subject');
my @fromarray = split('\s*,\s*', $entity->head->get('from') || $msginfo->{sender});
$self->log (3, "$queue->{logid}: From: %s", PMG::Utils::decode_rfc1522(PVE::Tools::trim($fromarray[0])) );

https://forum.proxmox.com/threads/how-to-log-subjects-of-all-incoming-email.54191/

第二種方法會把subject放在獨立行
不方便查找

官方其實有提供解法方法

You can find the default templates in /var/lib/pmg/templates/. Please do not modify them directly, because your modification would get lost on the next update. Instead, copy the template you wish to change to /etc/pmg/templates/, then apply your changes there.

Templates can access any configuration setting, and you can use the pmgconfig dump command to get a list of all variable names:

# pmgconfig dump
...
dns.domain = yourdomain.tld
dns.hostname = pmg
ipconfig.int_ip = 192.168.2.127
pmg.admin.advfilter = 1
...
The same tool is used to force regeneration of all template based configuration files. You need to run that after modifying a template, or when you directly edit configuration files

# pmgconfig sync --restart 1

https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html#_service_configuration_templates

2019/10/20

今天在使用gnuplot
發現一個問題
當先進入gnuplot後再下指令畫圖
可以跳出另一個視窗
可是如果使用
gnuplot -e 的方式
畫面一閃就不見了
只能夠output到檔案

gnuplot -e "set terminal png; set output '/tmp/1.png'; plot '/tmp/33' with line"

另外如果在python 呼叫 gnuplot
也不能在視窗上顯示
只能夠output到檔案

語法如下

import Gnuplot

g = Gnuplot.Gnuplot()
g("set terminal png")
g("set output '/tmp/1.png'")
g.plot("'/tmp/33' with line")

記得要先 apt install  python-gnuplot

看圖指令
eog /tmp/1.png






















http://yurinfore.blogspot.com/2007/05/python.html

2019/10/19

proxmox mail gateway的問題

今天在使用 tracking center 找資料的時候出現


















結果找了一下問題
竟然是要把ublock關掉才會正常
XD

https://forum.proxmox.com/threads/connection-error-in-tracking-center.41293/

2019/10/18

proxmox mail gateway 今年 opensource
因為之前都是用fortiget來處理spam的問題
所以也沒想要換
不過因為保固到期 新的合約沒有買到spam這個授權
而且最近也把mail server 換到centos 8
所以就想說來試看看
如果本來就是用 proxmox ve
那就可以直接使用LXC的template
我就是直接用template
安裝很快 裝完template也就可以砍了
再來說明一下裝完後有那些要改
首先是登入的root密碼
接下來使用iptables去管制能夠連到管理介面的來源ip

mail filter

一直以來我們的處理方式都是在主旨加上tag 而不是去隔離信
所以這裡要改
至於要不要通知管理者 就自行決定了
如果需要黑白名單 也是在這裡加














configuration

管理者的mail要記得改
















mail proxy

relaying
relay domains
transports
請依自己的環境修改
如果使用greylist 白名單是加在這裡 要注意 不是在mail filter














options

紅框是我覺得一定要改的
信件大小是跟著gmail的規則
網路上看到都說不要開greylist 可是我認為要開 可以少掉很多spam
SMTPD banner 如果不改 會顯示proxmox
站在安全的角度 我不想讓人知道我用什麼產品
其他就視需要自行決定了


















未加greylist



















加上greylist



















spam跟virus的更新系統會自動做
至於其他就自己看看

文件上的這張圖怪怪的


















實体上不是直接放在mail server 前面
而是要在DNS設定MX
外面進來的信先進到PMG
處理完後再轉到mail server
所以我目前的做法是在mail server上用iptable管制特定ip才能連到25
而且出去的信我也是從mail servre直接出去
不再經過PMG
到目前大約運作十多天
看起來效果還不錯

https://www.proxmox.com/en/proxmox-mail-gateway
https://pmg.proxmox.com/pmg-docs/pmg-admin-guide.html

2019/10/17

今天從proxmox下載新的lxc centos 7 template回來
create後發現root不能登入

pct enter 107

直接進去後再改密碼還是一樣

應該是template有問題了
而且centos 8的template已經上架
直接捉回來用 沒問題

2019/10/16

因為centos 8的php已 經升到7了
所以試看看裝 ocs 2.6有沒有問題

先補一下需要的rpm

dnf --enablerepo=PowerTools install perl-MIME-Types
dnf --enablerepo=PowerTools install perl-Digest-SHA1 -y
dnf --enablerepo=PowerTools install perl-Switch -y

epel-release
make
mariadb
mariadb-server
mod_perl
perl-Apache2-SOA
perl-Apache-DB
perl-Apache-DBI
perl-DBI
perl-Digest-SHA
perl-Net-IP
perl-SOAP-Lite
perl-XML-Entities
perl-XML-Simple
php
php-curl
php-gd
php-json
php-mbstring
php-mysqlnd
php-soap
php-xml
tar
httpd
zlib

大約是這些
如果有漏的
在跑setup時再補一下
centos 8還不錯 所有需要的東西都可以直接用dnf install 來裝

裝好mariadb記得先改一下root的密碼

mysqladmin -u root password 'passwd'

setup跑完後
改以下二個檔的帳號跟密碼

/etc/httpd/conf.d/z-ocsinventory-server.conf

/usr/share/ocsinventory-reports/ocsreports/dbconfig.inc.php

改權限

chmod -R 766 /usr/share/ocsinventory-reports
chown -R apache:apache /usr/share/ocsinventory-reports/
chown -R apache:apache /var/lib/ocsinventory-reports/

登入
http://server-hostname-or-IP/ocsreports
預設是admin admin
記得改掉

php在這個版本有個獨立的daemon

php-fpm

如果在/var/log/httpd/裡沒有看到錯誤
記得到
/var/log/php-fpm
查看看

要重啟daemon要重啟三個

systemctl restart httpd mariadb.service php-fpm.service

https://otx.alienvault.com 是一個公開的情資交換平台
只要註冊帳號(免費) 就可以接收跟發布相關的情資
速度相當快
不要忘記訂閱自己感興趣的user
如 AlienVault
註冊完後有相關的訊息也會mail到註冊的信箱

而且也提供相關的API可以使用
因為目前寫python的几會比較多
所以簡單說明
首先要到https://github.com/AlienVault-OTX/OTX-Python-SDK下載
下載後直接執行
python setup.py install
就安裝完成了
再來我是直接到github找相關程式
以下這個是我覺得還不錯的
https://github.com/Neo23x0/signature-base/blob/master/threatintel/get-otx-iocs.py

下載後在執行前只要改以下二個地方
otx key只要註冊後就可以拿到

OTX_KEY = 'yout otx key'

以下改成拿回來的資料要放那裡
parser.add_argument('-o', metavar='dir', help='Output directory', default='/tmp')

改好後執行
/usr/bin/python Get-OTX-IOCs.py

就會在/tmp裡看到
otx-c2-iocs-ipv4.txt
otx-c2-iocs-ipv6.txt
otx-c2-iocs.txt
otx-filename-iocs.txt
otx-hash-iocs.txt
這些檔案
接下來就可以拿來應用了

也有人針對ip整理過 可以直接拿來用

不過最大的問題是 拿到這麼多的資料 一般firewall是不可能全部吃進去的
一定要找別的設備才能處理

2019/10/15

一般如果要找出二個檔案不同的地方而且印出來
最常使用的方式就是用grep了

grep -v -f a b

就可以找出在b檔案內不包含a檔案的內容
但有個問題
如果二個檔案內容是几千或几萬筆
那就要花很..................久的時間

這時就可以使用comm
前提是二個檔案必須先排序
sort a > aa
sort b > bb

再來就可以找出b有但a沒有的內容 快非常多
comm -1 -3 aa bb

2019/10/11

一樣是升級centos 8 postfix 後的問題
這次希望能有判別spam的功能
請出老牌的 spamassassin
網路上的很多文章都提到與mailscanner 或 amavisd-new 整合
但我希望能直接用postfix
做法如下

dnf install spamassassin

好在有放進list可以直接用

加group跟user

groupadd spamd

useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd

改權限
chown spamd:spamd /var/log/spamassassin

再來修改 /etc/postfix/master.cf

找到 
smtp      inet  n       -       n       -       -       smtpd

改成
smtp      inet  n       -       n       -       -       smtpd -o content_filter=spamassassin

在最後加上
spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

systemctl restart spamassassin
systemctl restart postfix
systemctl enable spamassassin

更新rule
sa-update -D --nogpg

會出現有缺東西的情況 能補就補
最後有二個dnf也沒法補
目前是不影響功能

Oct 11 07:36:44.595 [24809] dbg: diag: [...] module not installed: Net::Patricia ('require' failed)
Oct 11 07:36:44.595 [24809] dbg: diag: [...] module not installed: Net::DNS::Nameserver ('require' failed)

寫個crontab定時做
1 7,19 * * * /usr/bin/sa-update -D --nogpg;/usr/bin/systemctl restart spamassassin

如果想要能夠學習
建 whitelist , blacklist 二個user 分別把誤判及未判的信轉過去

然後再寫個crontab定時做

#!/bin/bash

/usr/bin/sa-learn --no-sync --ham /home/whitelist/Maildir/{cur,new}
rm -rf /home/whitelist/Maildir/*

/usr/bin/sa-learn --no-sync --spam /home/blacklist/Maildir/{cur,new}
rm -rf /home/blacklist/Maildir/*


2019/10/05

最近把mail server升到 centos 8
可是
預設卻找不到 postgrey
XD

只好手動來了
首先到 https://postgrey.schweikert.ch/ 下載
直接解開就可以用了 不用編譯
只是要補一些東西

dnf install -y perl-NetAddr-IP perl-Net-Server perl-BerkeleyDB

groupadd nogroup
adduser postgrey

mkdir /var/spool/postfix/postgrey
touch /var/spool/postfix/postgrey/socket
chown -R postgrey.nogroup /var/spool/postfix/postgrey

cd /etc/postfix

下載官方白名單
wget https://postgrey.schweikert.ch/pub/postgrey_whitelist_clients

再產生一個 /etc/postfix/postgrey_whitelist_recipients 視需要修改內容

啟動postgrey

./postgrey --unix=/var/spool/postfix/postgrey/socket --delay=60 -d

記得加入 /etc/rc.local開几執行

修改 /etc/postfix/main.cf

在原來的
smtpd_recipient_restrictions =
加上
   check_policy_service unix:/var/spool/postfix/postgrey/socket

重啟postfix
systemctl restart postfix

接下來看看/var/log/maillog 有沒有類似以下的訊息
如果有
就表示ok了

Oct  5 11:21:57 mail postfix/smtpd[10103]: NOQUEUE: reject: RCPT from nedm.ubot.com.tw[125.227.165.70]: 450 4.2.0 <abc@test.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/mail.nkuht.edu.tw.html; from=<UBOT@nedm.ubot.com.tw> to=<shangpao@mail.nkuht.edu.tw> proto=ESMTP helo=<nedm.ubot.com.tw>

postgrey有一個報表工具 postgreyreport
如果要使用要再補上

dnf install -y perl-Net-DNS

指令如下

Depending on how busy your server is, the report can get quite large. To get only the top 20 sources getting greylisted out - you can use something like this :

cat /var/log/maillog | postgreyreport | awk '{print $1}' | sort | uniq -c | sort -nr | head -n20

To get a list of the top 20 email address that the greylisted sources are sending email to :

cat /var/log/maillog | postgreyreport | awk '{print $4}'  | sort  | uniq -c | sort -nr | head -n20


https://wiki.centos.org/HowTos/postgrey#head-70ed10e62fb7da94deb39a987e1e4e205c2ae2c5

2019/10/03

最近才發現cisco 6504吐出來的netflow沒有包含 tcp flags的資料
昏到

https://www.cisco.com/c/en/us/support/docs/switches/catalyst-6500-series-switches/70974-netflow-catalyst6500.html