2023/06/05

朋友介紹的好用免費 P2V 軟体


https://www.starwindsoftware.com/starwind-v2v-converter

2023/05/24


/usr/sbin/iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 22 -j ACCEPT
/usr/sbin/iptables -A INPUT -p tcp -s 0/0 --dport 22 -j DROP
/usr/sbin/iptables -A INPUT -s 127.0.0.1 -j ACCEPT
/usr/sbin/iptables -A INPUT -s 192.168.0.0/16 -j ACCEPT
/usr/sbin/iptables -A INPUT -s 10.0.0.0/8 -j ACCEPT

/usr/sbin/iptables -A INPUT -m state --state  ESTABLISHED -j ACCEPT
在DROP前必須加上以上這行 封包才能出去

/usr/sbin/iptables -A INPUT -s 0/0 -j DROP

2023/05/05

一直以來都會定時去 graylog 撈 資料

會使用到多個 OR 的下法

accept AND ( 192.168.33.238 OR 192.168.34.215 OR 192.168.33.43 OR 192.168.34.142 OR 192.168.54.247 OR 192.168.7.253 OR 192.168.26.237 OR 192.168.26.228 OR 192.168.25.211 OR 192.168.25.206 OR 192.168.25.117 OR 192.168.26.104 OR 192.168.25.183 OR 192.168.31.241 OR 192.168.30.112 OR 192.168.30.80 OR 192.168.29.6 OR 192.168.29.3 OR 192.168.30.60 OR 192.168.30.58 OR 192.168.29.143 OR 192.168.30.57 OR 192.168.29.223 OR 192.168.29.164 OR 192.168.29.84 OR 192.168.30.200 OR 192.168.30.32 OR 192.168.29.29 OR 192.168.29.199 OR 192.168.29.205 OR 192.168.29.210 OR 192.168.29.200 OR 192.168.29.234 OR 192.168.30.220 OR 192.168.30.194 OR 192.168.29.83 OR 192.168.29.4 OR 192.168.30.108 OR 192.168.29.177 OR 192.168.29.107 OR 192.168.29.32 OR 192.168.30.33 OR 192.168.30.173 OR 192.168.30.247 OR 192.168.30.122 OR 192.168.30.55 OR 192.168.29.19 OR 192.168.29.10 OR 192.168.30.123 OR 192.168.30.201 OR 192.168.29.253 OR 192.168.30.85 OR 192.168.29.48 OR 192.168.30.37 OR 192.168.30.66 OR 192.168.9.100 OR 192.168.30.163 OR 192.168.30.114 OR 192.168.30.59 OR 192.168.30.199 OR 192.168.30.227 OR 192.168.30.41 OR 192.168.29.246 OR 192.168.29.161 OR 192.168.74.248 OR 192.168.74.12 OR 192.168.10.111 OR 192.168.10.104 OR 192.168.50.154 OR 192.168.52.1 OR 192.168.52.3 OR 192.168.50.243 OR 192.168.50.220 OR 192.168.50.179 OR 192.168.50.99 OR 192.168.50.138 OR 192.168.50.98 OR 192.168.50.182 OR 192.168.50.206 OR 192.168.50.234 )


但今天使用同樣的語法

出現以下的 error


While retrieving data for this widget, the following error(s) occurred:

OpenSearch exception [type=too_many_nested_clauses, reason=Query contains too many nested clauses; maxClauseCount is set to 1024].


問了bing


要修改 /etc/opensearch/opensearch.yml

加上 

indices.query.bool.max_clause_count: 10240

重啟 opensearch 目前正常

2023/05/03

因應centos 7 的EOS 
最近把 grafana 轉到 debian

grafana 安裝好後移轉資料


Install used plugin on new server

    grafana-cli plugins install grafana-image-renderer
    grafana-cli plugins install grafana-clock-panel
    grafana-cli plugins install grafana-worldmap-panel

Stop Grafana service on source and destination server

Copy /var/lib/grafana/grafana.db from old to new server

Check /etc/grafana/grafana.ini

    以上copy完後要注意檔案擁有者及權限問題

Restart Grafana

Regular connection to the grafana url

Dashboard, datasource, users, psw, team,… are the same


因為之前有在本机開 influxdb
所以移轉

influxd backup /tmp/backup
    
    只備分資料結構不備分資料

influxd restore -metadir /var/lib/influxdb/meta /tmp


本來有開API給遠端撈資料
在9版之後改成 service accounts
所以直接轉換

轉後去後遠端還是撈不到資料 本來以為是key的問題
查了log才發現要補一些package

apt install libglib2.0-0
apt install libnss3
apt install libatk1.0-0
apt install libatk-bridge2.0-0
apt install libcups2
apt install libdrm2
apt install libxkbcommon0
apt install libxcomposite1
apt install libxdamage1
apt install libxfixes3
apt install libxrandr2
apt install libgbm1
apt install libpangocairo-1.0-0
apt install libasound2


目前看來是都正常了




2023/04/21

mobasshtunnel  local port forwarding 使用時机如下
有一台僅供內部使用的 proxy 或 server
想要透過 tunnel 使用
架構圖如下




synology在儲存管理員中修改以下二個設定 可以再增加一些效能












2023/04/20

graylog時不時就會出現以下的訊息




 


修改一下 config

預設值是1秒

#gc_warning_threshold = 1s

先改成5秒再觀察看看

新机器進來

把graylog升到5版順便搬進去

原本机器上的設定要移過去

之前都是一個一個做

今天才發現有 content pack 這個功能 超方便的 可以一次搬好

首先進入舊几上的 content pack













建一個新的 content pack

 





填寫必要欄位 名稱不能使用純數字 否則會有問題












往下拉選擇那些要匯出












選完後下一步下一步就會建立一個新的 content pack  叫 test


在 more actions 可以 download






接下來在新机上一樣進到 content pack 就可以upload









上傳後直接install 就可以了




proxmox安裝almalinux 9 時會出現以下的問題無法開几

 










cpu不能使用預設的kvm64

要改成host才行

2023/04/14

為了因應centos 7 EOS

今天在轉移程式到 almalinux 9 時 mutt 一直無法寄信

mail server 的log如下

Apr 14 10:09:09 mail postfix/smtpd[523701]: connect from unknown[10.0.0.1]

Apr 14 10:09:09 mail postfix/smtpd[523701]: lost connection after STARTTLS from unknown[10.0.0.1]

看來almalinux 9的mutt 預設會使用 STARTTLS

在 .muttrc 加上以下這行

set ssl_force_tls = no


目前寄信正常了


20240308 後記


轉換到新mail server後 有些mutt又出現不能寄信的狀況

以下是log


Mar  8 06:13:01 mail postfix/smtpd[27212]: warning: TLS library problem: error:0A000126:SSL routines::unexpected eof while reading:ssl/record/rec_layer_s3.c:320:

Mar  8 06:13:01 mail postfix/smtpd[27212]: lost connection after STARTTLS from unknown[10.0.0.1]


必須在.muttrc再加上 set ssl_starttls = no 
包括之前說明的共二行如下

set ssl_force_tls = no
set ssl_starttls = no

目前正常了 再觀察看看

2023/04/09

在 proxmox backup server 中使用 api 撈取相關資料

先建立 API token 要記住 token













再設定權限















使用 curl 撈取相關資料 範例如下

curl --location --insecure --request GET 'https://10.0.0.1:8007/api2/json/nodes/{localhost}/tasks' --header 'Authorization: PBSAPIToken=root@pam!abc:your_token'|jq

API相關資料路徑可參考以下原廠連結


2023/03/02

使用curl  撈取 loki 資料的語法 

依需求需要更改之處

job="abc"

查詢的關鍵字 192.168.1.2

查詢的區間


curl -G -s "http://10.0.0.1:3100/loki/api/v1/query_range" --data-urlencode 'query={job="abc"} |~ "192.168.1.2"' --data-urlencode "start=$(date -u +'%Y-%m-%dT%H:%M:%SZ' -d '-8 hour')" --data-urlencode "end=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"


curl -G -s "http://10.0.0.1:3100/loki/api/v1/query_range" --data-urlencode 'query={job="abc"} |~ "192.168.1.2"' --data-urlencode "start=$(date -u +'%Y-%m-%dT%H:%M:%SZ' -d '-7 day')" --data-urlencode "end=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"|jq

2023/02/28

今天早上三點多開始收到ntopng的告警

進主几看了一下 process不見了

重開也沒用

看了一下log

ntopng果然有更新

更新後起不來

接下來看ntopng的log

發現本次更新後必須使用到 libbpf.so.0


Feb 28 08:09:17 W-ntopng-ubuntu-2004 ntopng[3247]: /usr/bin/ntopng: error while loading shared libraries: libbpf.so.0: cannot open shared object file: No such file or directory

Feb 28 08:09:22 W-ntopng-ubuntu-2004 ntopng[3272]: /usr/bin/ntopng: error while loading shared libraries: libbpf.so.0: cannot open shared object file: No such file or directory

Feb 28 08:09:28 W-ntopng-ubuntu-2004 ntopng[3294]: /usr/bin/ntopng: error while loading shared libraries: libbpf.so.0: cannot open shared object file: No such file or directory

 

apt install libbpf0

目前正常了 再觀察看看

2023/02/22

昨天有朋友問我說proxmox的guest開不了几

不知是什麼問題

連進去看了一下

發現一個guest開了好几個HD

而且每個HD都開到2T

而且還做了好几個snapshot

導致實際上guest的HD 膨脹 到5T或更大

把空間全部吃滿了

所以無法開几

因為是使用qcow2格式

所以snapshot會長在原來的檔案上

我是覺得奇怪

guest開那麼多個2T的檔案

user不會覺得效能不好嗎

解決的方式就是把舊的snapshot砍一砍

再觀察看看

2023/02/13

今天早上要進ntop管理介面的時候

打完帳號密碼登不進去

進os看了一下HD滿了

然後再看log

出現一堆如下的訊息 把HD塞爆了

Feb 13 08:14:29 W-ntopng ntopng[286]: 13/Feb/2023 08:14:29 [SQLiteAlertStore.cpp:151] ERROR: SQL Error: database disk image is malformed

Feb 13 08:14:29 W-ntopng ntopng[286]: INSERT INTO flow_alerts (alert_id, interface_id, tstamp, tstamp_end, severity, ip_version, cli_ip, srv_ip, cli_port, srv_port, vlan_id, is_cli_attacker, is_cli_victim, is_srv_attacker, is_srv_victim, proto, l7_proto, l7_master_proto, l7_cat, cli_name, srv_name, cli_country, srv_country, cli_blacklisted, srv_blacklisted, cli_location, srv_location, cli2srv_bytes, srv2cli_bytes, cli2srv_pkts, srv2cli_pkts, first_seen, community_id, score, flow_risk_bitmap, alerts_map, cli_host_pool_id, srv_host_pool_id, cli_network, srv_network, probe_ip, input_snmp, output_snmp, json, info) VALUES (26, 3, 1676247257, 1676247266, 3, 4, '192.168.40.66', '192.168.0.65', 44983, 80, 0, 0, 0, 0, 0, 6, 7, 0, 5, '', '', '', '', 0, 0, 0, 0, 126, 120, 2, 2, 1676247257, '1:rj5vzKw7WQX8TONTQ++bh3BkBh8=', 10, 70368744177664, X'04000000', 0, 0, 65535, 65535, '0.0.0.0', 0, 0, '{"ntopng.key":12345678,"hash_entry_id":23456789,"alert_generation": {"script_key":"ndpi_unidirectional_traffic","subdir":"flow","flow_risk_info":"{\"46\":\"No client to server traffic\"}"},"proto": {"http": {},"confidence":0}}', '');


google了一下是 sqllite 因為斷電導致有問題

果然

斷一次電事情一堆

看是有recovery sqlite的方法

算了

直接倒回事發前一天晚上的備分好了

倒回後目前正常

再觀察看看


https://blog.csdn.net/wolfking0608/article/details/71076588 


2023/02/11

今天下午几房斷電
有一台graylog啟動後
三個 service都有起來
但從管理介面看log全都卡住
過了一個小時還是沒有消化
想說應該是 elasticsearch 有問題了
看了log

[2023-02-11T20:27:56,520][WARN ][o.e.c.r.a.AllocationService] [localhost.localdomain] failing shard [failed shard, shard [graylog_666][2], node[0l7asmrIRFeIxc3FyAB14Q], [P], recovery_source[existing store recovery; bootstrap_history_uuid=false], s[INITIALIZING], a[id=yqeR9a7CSUC4ZIIz-a07Gw], unassigned_info[[reason=ALLOCATION_FAILED], at[2023-02-11T12:27:55.997Z], failed_attempts[4], failed_nodes[[0l7asmrIRFeIxc3FyAB14Q]], delayed=false, details[failed shard on node [0l7asmrIRFeIxc3FyAB14Q]: failed recovery, failure RecoveryFailedException[[graylog_666][2]: Recovery failed on {localhost.localdomain}{0l7asmrIRFeIxc3FyAB14Q}{AHesmcGhQvGWAw7Gxl2V6A}{10.10.0.1}{10.10.01:9300}{dimr}]; nested: IndexShardRecoveryException[failed to recover from gateway]; nested: EngineCreationFailureException[failed to create engine]; nested: NoSuchFileException[/mnt/elasticsearch/nodes/0/indices/soJ39cmwT5-UlEyVIPvfAg/2/index/_x63f.fdt]; ], allocation_status[deciders_throttled]], message [failed recovery], failure [RecoveryFailedException[[graylog_666][2]: Recovery failed on {localhost.localdomain}{0l7asmrIRFeIxc3FyAB14Q}{AHesmcGhQvGWAw7Gxl2V6A}{10.10.0.1}{10.10.0.1:9300}{dimr}]; nested: IndexShardRecoveryException[failed to recover from gateway]; nested: EngineCreationFailureException[failed to create engine]; nested: NoSuchFileException[/mnt/elasticsearch/nodes/0/indices/soJ39cmwT5-UlEyVIPvfAg/2/index/_x63f.fdt]; ], markAsStale [true]]
org.elasticsearch.indices.recovery.RecoveryFailedException: [graylog_666][2]: Recovery failed on {localhost.localdomain}{0l7asmrIRFeIxc3FyAB14Q}{AHesmcGhQvGWAw7Gxl2V6A}{10.10.0.1}{10.10.0.1:9300}{dimr}

果然

手動 rotate active write index

有消化了
再觀察看看

2023/02/08

nftables 雖然是很久的東西了 還是記一下

安裝
dnf install nftables

清空所有
nft flush ruleset

設定新table
nft add table inet filter

新增一個chain 並預設規則
nft add chain inet filter INPUT { type filter hook input priority 0 \; counter \; policy accept \; }

在chain加上新規則

nft insert rule inet filter INPUT ip saddr 192.168.12.85 tcp dport 22 drop

列出規則
nft list table inet filter

列出規則 顯示 handle 號 以利刪除
nft -an list table inet filter

列出所有table的規則
nft -an list ruleset

刪除規則
nft delete rule inet filter INPUT handle 2

nft加的規則 iptables 去看會不完整
但是有作用的


下完 nft flush ruleset 後
再下 nft -an list ruleset 是看不到資料的
但如果再下iptables -L 
下完後
再 nft -an list ruleset
就會看到如下的ruleset

table ip filter { # handle 3
        chain INPUT { # handle 1
                type filter hook input priority 0; policy accept;
        }

        chain FORWARD { # handle 2
                type filter hook forward priority 0; policy accept;
        }

        chain OUTPUT { # handle 3
                type filter hook output priority 0; policy accept;
        }
}


預設所有下的指令 重開几就會清掉 如果要重開几自動執行

nft list ruleset >> /etc/sysconfig/nftables.conf 


先匯出成檔案
nft list ruleset > /etc/nftables/nft_policy.nft


然後再 /etc/sysconfig/nftables.conf 

include "/etc/nftables/nft_policy.nft"

重開後撈進來


如果確定不再需要 iptables 
移除
dnf remove iptables



2023/02/07

sshpass

範例

sshpass -p passwd ssh root@10.0.0.1 date


2023/02/04

今天在檢查 pbs 時又出現 GC (garbage collection) warning 的log
再去看前一天的備分
是顯示備份完成且沒有錯誤的
不知道為什麼備分完成沒有錯誤但GC時會出現如下的錯誤

2023-02-02T00:00:22+08:00: WARN: warning: unable to access non-existent chunk 4d9f87572f2ff8d9f324aef1263e1ab47181a764aac801918b6dd5567fdfdde9, required by "/mnt/nfs418/ct/112/2023-01-31T16:00:47Z/catalog.pcat1.didx"
2023-02-02T00:00:22+08:00: WARN: warning: unable to access non-existent chunk e82ad3ac9b4b29c55420a44c29029c1a69ebd2cae156994c7e6a4f6a3b44524d, required by "/mnt/nfs418/ct/112/2023-01-31T16:00:47Z/catalog.pcat1.didx"
2023-02-02T00:00:22+08:00: WARN: warning: unable to access non-existent chunk 7eeadcfafebe86f0244ab4b07167644784be8485da119208d91e078efb48a7de, required by "/mnt/nfs418/ct/112/2023-01-31T16:00:47Z/root.pxar.didx"

而且問題來了
再接下來每一次備分都會顯示備分完成無異常
但GC就會一直錯誤
而且一旦GC有錯誤這個備分就無法還原
目前pbs在GC有錯誤時無法主動發mail 告警
所以解決方法就是寫個程式每天檢查GC是否有錯誤
如果有
就要把有錯誤相關的備分砍了
讓接下來的備分能正常

2023/02/03

atftp

sudo apt install atftpd
mkdir /tftp_data
chmod -R 777  /tftp_data
atftpd --daemon --port 69 /tftp_data