FreeNAS 出現degraded 錯誤(smartd not running)
11.2 有時會發現 smartd 失效, 因此造成系統誤認是硬碟有問題
所以需要重開smartd是看看, ssh 登入系統後, 先執行
ps -ax|grep smartd
查看是否執行中,
以下指令可重啟smartd
service smartd onerestart
11.2 有時會發現 smartd 失效, 因此造成系統誤認是硬碟有問題
所以需要重開smartd是看看, ssh 登入系統後, 先執行
ps -ax|grep smartd
查看是否執行中,
以下指令可重啟smartd
service smartd onerestart
很方便, 也很簡單
1. docker volume create gitlab-config
2. docker volume create gitlab-logs
3. docker volume create gitlab-data
4.
docker run -d --hostname <主機名稱> -p<外部對應http>:80 -p
<外部對應https> :443 --name gitlab --restart always --volume gitlab-config:/etc/gitlab --volume gitlab-logs:/var/log/gitlab --volume gitlab-data:/var/opt/gitlab gitlab/gitlab-ce:latest
5. 設定檔案在 gitlab-config/gitlab.rb
若不需要http ,可加上external_url "https://主機名稱" ,
若不需要 leetsencrypt , 請加上 letsencrypt['enable'] = false
2019/10/07 後記
後來gitlab一直更新, 想說docker pull gitlab/gitlab-ce:latest
以前天真的以為這樣就好了, docker上面的gitlab就會自動變成最新版,
沒想到以前的latest跟現在的latest是不同的
所以我就很瀟灑的砍掉目前docker上正在跑的gitlab ,反正設定檔案都在volume
砍掉之後, 重新執行以上的第四步驟
發現起不來, 於是找了很久找到 log 裡面一個 reconfigure 的目錄, 看了一下目錄裡面最新的檔案,才發現gitlab的自動升級功能有提醒版本過舊, 但是我不知道舊的版本是啥.
最後終於找到以前gitlab的image id (可以使用docker images 指令找) , 再去docker上找出一樣的images id 就能知道版本了, 於是再慢慢升級, 因為 gitlab 無法跳躍式升級, 需要一版接一版, 最後就成功升級到最新版了
公司某天刷臉機器因停電造成時間錯誤, IT人員未即時更新(因為週六), 導致少數加班人員吃飯刷卡紀錄錯誤,少了11小時, 因此必須加回去原本的資料庫 , 可使用 dateadd(hour, 預加或減的小時數字, 欄位名稱) 的方式處理.
update dbo.KQZ_Card set CardTime= dateadd(hour,11,KQZ_card.CardTime) where DevID=9 and year(CardTime)=2019 and Month(CardTime)=4 and day(CardTime)=27;
朋友的電腦只有一顆1T傳統硬碟,有C,D槽.
因此我請他買一顆SSD硬碟預備當C槽, 沒想到居然遇到clonezilla失敗的狀況, 無法partition to partition.
最後祭出 EaseUS Todo Backup這套軟體, 使用系統克隆的方式將硬碟克隆到SSD去,
可是也失敗, 因為硬碟太大, 最後取巧將原系統的D槽磁碟機代號刪除, 讓 EaseUS 誤以為只有C槽, 就能順利進行系統克隆了, 記得勾選優化固態硬碟哦
公司使用鼎新tiptop 5.1版 , 用戶端用的登入程式是 VTCP
與tiptop連線的用戶端程式是 Genero Desktop Client (GDC)程式
關於GDC
目前已經更新到2.5.39版
tiptop伺服器上有些注意事項如下:
關於VTCP
登入tiptop所使用VTCP, 會帶出GDC , 因此參數可調整, 以下6401代表帶出GDC時候, 指定接聽6401
GDC\BIN\GDC.EXE -M -A 0 -D -p 6401
紅色的部份需要注意, 此外若出現 kafeiou.pw 請記得取代掉
#郵件過濾功能(mail gateway),請參考此文章
#2011年曾經寫過類似文章當時是CentOS6,應該大同小異
1. 修改 /etc/postfix/main.cf ,
############################################################### myhostname = mail.kafeiou.pw mydestination=/etc/postfix/local-host-names inet_interfaces = all # Enable IPv4, and IPv6 if supported inet_protocols = all mynetworks = 127.0.0.0/8,192.168.1.0/24 queue_directory = /var/spool/postfix mail_owner = postfix command_directory = /usr/sbin daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix unknown_local_recipient_reject_code = 550 home_mailbox = Maildir/ sendmail_path = /usr/sbin/sendmail.postfix newaliases_path = /usr/bin/newaliases.postfix mailq_path = /usr/bin/mailq.postfix setgid_group = postdrop html_directory = no manpage_directory = /usr/share/man ############################################################### smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_hostname, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_destination, smtpd_client_restrictions = permit_sasl_authenticated, smtpd_sender_restrictions = permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain ############################################################### message_size_limit = 150600000 mailbox_size_limit = 250600000 virtual_mailbox_limit = 250600000 disable_vrfy_command = yes strict_rfc821_envelopes = yes bounce_queue_lifetime = 1d ############################################################### smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes smtpd_sasl_local_domain = ############################################################### smtpd_helo_required = yes smtpd_delay_reject = yes smtpd_helo_restrictions = permit_mynetworks, permit ############################################################## virtual_mailbox_domains = /etc/postfix/domains virtual_mailbox_base = /home/vmail virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf # 1001 is id of user "vmail" created in linux virtual_uid_maps = static:1001 virtual_gid_maps = static:1001 virtual_alias_maps = hash:/etc/aliases,ldap:/etc/postfix/ldap-aliases.cf ############################################################## recipient_bcc_maps = hash:/etc/postfix/recipient_bcc sender_bcc_maps = hash:/etc/postfix/sender_bcc #inet_protocols = ipv4 smtpd_tls_security_level = may smtpd_tls_key_file = /etc/letsencrypt/live/mail.kafeiou.pw/privkey.pem smtpd_tls_cert_file = /etc/letsencrypt/live/mail.kafeiou.pw/fullchain.pem # smtpd_tls_CAfile = /etc/pki/tls/root.crt smtpd_tls_loglevel = 1 smtpd_tls_session_cache_timeout = 3600s smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_cache tls_random_source = dev:/dev/urandom tls_random_exchange_name = /var/lib/postfix/prng_exch # 強制使用TLS smtpd_tls_auth_only = yes smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes # # Disable SSLv2, SSLv3 # smtpd_tls_protocols = !SSLv2 !SSLv3 smtpd_tls_mandatory_protocols = !SSLv2 !SSLv3 smtp_tls_protocols = !SSLv2 !SSLv3 smtp_tls_mandatory_protocols = !SSLv2 !SSLv3 lmtp_tls_protocols = !SSLv2 !SSLv3 lmtp_tls_mandatory_protocols = !SSLv2 !SSLv3 dovecot_destination_recipient_limit = 1 #performance smtpd_error_sleep_time = 0 default_process_limit = 150 qmgr_message_active_limit = 40000 qmgr_message_recipient_limit = 40000 default_destination_concurrency_limit=100 default_destination_recipient_limit=100 default_process_limit=200 smtp_mx_session_limit=100 smtpd_client_connection_count_limit=100 smtp_destination_concurrency_limit=100 maximal_backoff_time = 1000s minimal_backoff_time = 300s
2. 修改 /etc/postfix/local-host-names , 加上主機名稱
mail.kafeiou.pw
3. 修改 /etc/postfix/domains , 加上網域
kafeiou.pw
4.新增使用者 vmail , 並紀錄該使用者id , 並更新到 main.cf 裡面的id(可參考步驟1)
groupadd vmail -g 1001; useradd vmail -u 1001 -g 1001
5. 綁定網域帳號
裡面的 mail=%s 代表郵件紀錄在網域的mail欄位
vi /etc/postfix/ldap-users.cf
server_host = <主機ip> search_base = ou=taipei,dc=kafeiou,dc=pw version = 3 query_filter = (&(objectclass=*)(mail=%s)) result_attribute = samaccountname #Account from DC result_format = %s/Maildir/ bind = yes bind_dn = cn=ldap,cn=Users,dc=kafeiou,dc=pw bind_pw = <cn=ldap的密碼>
6. 綁定aliases, 網域設定群組
vi /etc/postfix/ldap-aliases.cf
server_host = <主機ip> search_base = ou=aliases,dc=kafeiou,dc=pw #scope = sub query_filter = (memberOf:1.2.840.113556.1.4.1941:=CN=%s,ou=aliases,dc=kafeiou,dc=pw) result_attribute = mail result_format = %s version = 3 bind = yes bind_dn = cn=ldap,cn=Users,dc=kafeiou,dc=pw bind_pw = <cn=ldap的密碼>
7. 取得letsencrypt, 更新步驟1相關的證書
按此連結到本站能找到資源 , 記得輸入guest/guest
8. 設定收發備份
/etc/postfix/recipient_bcc 與 /etc/postfix/sender_bcc
william收發信都會備份到, public , 記得改完套用 postmap /etc/postfix/recipient_bcc 與 /etc/postfix/sender_bcc
william@kafeiou.pw public@kafeiou.pw
9. 設定submission(TLS加密,使用587 port)
vi /etc/postfix/master.cf
submission inet n - n - - smtpd -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_reject_unlisted_recipient=no # -o smtpd_client_restrictions=$mua_client_restrictions # -o smtpd_helo_restrictions=$mua_helo_restrictions # -o smtpd_sender_restrictions=$mua_sender_restrictions -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
10, 修改 /etc/sysconfig/saslauthd
# Directory in which to place saslauthd's listening socket, pid file, and so # on. This directory must already exist. SOCKETDIR=/run/saslauthd # Mechanism to use when checking passwords. Run "saslauthd -v" to get a list # of which mechanism your installation was compiled with the ablity to use. #MECH=pam MECH=ldap # Additional flags to pass to saslauthd on the command line. See saslauthd(8) # for the list of accepted flags. FLAGS="-O /etc/postfix/saslauthd.conf -c -r"
11. 修改 /etc/postfix/saslauthd.conf
ldap_servers: ldap://<網域伺服器IP>:389/ ldap_search_base: ou=taipei,dc=kafeiou,dc=pw ldap_auth_method: bind ldap_version: 3 ldap_bind_dn: cn=ldap,cn=Users,dc=kafeiou,dc=pw ldap_bind_pw: <cn=ldap的密碼> ldap_filter: (sAMAccountName=%u) #ldap_filter: (mail=%u)
以上應該就能夠讓smtp 綁定網域, 以及擁有TLS(port 587)功能
前一陣子偶花很多時間將 esxi 重心改成proxmox ve, 好不容易告一段落.
但是節神又丟出來 mail gateway 這個怪獸,
原來是 proxmox mail gateway(PMG) 開源了(open-source software license GNU AGPL,v3).
這很不得了!
早在 2007 咖啡偶就開始使用 mail gateway 這個概念來過濾郵件, 過濾後才丟到公司內部郵件伺服器.
偶們公司的 mail gateway 使用 linux + postfix + amavisd-new 的方式,
設定極其複雜, 當時還無法透過套件安裝 , 要自行下載甚至編譯 perl 相關模組, 才能使用,
過了幾年為了能達到公司 SSO(single sign on) 的要求, 還研究好久 , 讓 mail gateway 與公司的網域主控站結合,
慘的是公司網域使用工號登入, 工號與郵件名稱又不一樣, 設定起來夭壽雜亂, 設定好之後就不敢動, 也怕動.
但還有些好處, 新人來的時候, 可以拿這個威風一下, 瀟灑地把秘笈丟過去.
現在裝了proxmox mail gateway 5.2 (pmg) , 真想罵髒話(哎喲, 我是彰化人…) , 居然可以輕易取代公司目前使用的mg.
這裡記下一些設定上的眉角:
1. 綁定網域主控站( ldap )
但是要注意一些相關屬性, 例如Base DN(確認帳號是否存在), BaseDN for Groups(確認是否有此群組) , Email 存放在哪個屬性
2.1 設定Who Objects, 這將用來查詢帳號是否在ldap 裡面
新增一個who物件, 於這個物件中綁定步驟1的ldap設定 , 並且務必指定 Unknow LDAP address, 代表無此帳號的意思
2.2. 設定aliases, 因為原本mail gateway 並沒有aliases這個機制, 但公司的郵件伺服器有aliases, 這時候可以這樣做
2.3 設定危險內容(exe, java ,或是副檔名是vbs, shs, 偶是額外加上ace這個副檔名)
3. 新增規則
規則號碼越高,越優先執行,rules with higher priority are executed first
以下範例, 請依現況調整優先順序(但是aliases必須要在ldap之前),
Rule: 100 若符合aliases就通過
Rule: 99 若在ldap搜尋不到該email , 就阻擋
Rule: 98 若符合危險內容就阻擋
4. 設定Relay Domains
5.
5.設定轉寄到內部郵件伺服器
6.
6. 取消灰名單, 以前的經驗告訴偶, 不要啟用這東西, 因為跟公司往來的客戶或廠商, 並不見得有好的mail server
7. 取消寄發到使用者的報表,別讓使用者覺得困擾
8. 一般來說,初體驗會很high, 但是久了就淡了, 因此可以考慮取消各式各樣的報表 status report , 有空再來看就好了
systemctl stop pmgreport.timer
9. 設定 TLS 讓pmg的網頁, 與郵件傳輸使用TLS加密的方式傳輸
9.1 確認是否有DNS CAA
pmg網站需要設定一個對外ip, 與對應dns名稱, 並確保有Certificate Authority Authorization (CAA)功能, 請參閱這裡
9.2 ssh 登入pmg
9.3 取得憑證
安裝工具以便取得免費的證書 LetsEncrypt
apt-get install certbot
certbot certonly –standalone –preferred-challenges http -d <主機dns名稱>
ps. 成功後會在 /etc/letsencrypt/live/<主機名稱> 找到相關的證書, 需要有fullchain.pem , privkey.pem
9.4. 設定憑證
將 fullchain.pem , privkey.pem 合併成一個pem檔案, 並且取代/etc/pmg/pmg-tls.pem , /etc/pmg/pmg-apt.pem
新增並修改renew.sh內容如下
vi /etc/pmg/renew.sh
#!/bin/bash /usr/bin/certbot renew /bin/cat /etc/letsencrypt/live/<主機dns名稱>/fullchain.pem /etc/letsencrypt/live/<主機dns名稱>/privkey.pem > /etc/pmg/pmg-tls.pem /bin/cat /etc/letsencrypt/live/<主機dns名稱>/fullchain.pem /etc/letsencrypt/live/<主機dns名稱>/privkey.pem > /etc/pmg/pmg-api.pem /bin/chmod 600 /etc/pmg/pmg-tls.pem /bin/chmod 640 /etc/pmg/pmg-api.pem /bin/chown root:root /etc/pmg/pmg-tls.pem /bin/chown root:www-data /etc/pmg/pmg-api.pem /bin/systemctl restart pmgproxy
讓renew.sh變成可以執行的屬性 chmod +x /etc/pmg/renew.sh
9.5. 設定排程
我是設定1個月,但理論上3個月執行就可以了
crontab -e
輸入
0 0 1 * * /etc/pmg/renew.sh
9.6 啟用TLS
到pmg網頁, Configuration: Mail Proxo : TLS 勾選啟用
9.7.確認是否啟用startssl ,
請輸入 telnet localhost 25 , 再輸入 ehlo localhost , 即可查詢是否有starttls功能
9.8. 測試是否有加密連線
使用gmail寄信, 觀查 /var/log/mail.log 是否出現 starttls=1 字樣
Apr 16 17:43:24 pmg postfix/smtpd[13252]: disconnect from mail-pg1-f170.google.com[209.85.215.170] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7
10. /etc/postfix/main.cf 加上拒絕反查無主機名稱的郵件伺服器IP
smtpd_sender_restrictions = ... ... reject_unknown_reverse_client_hostname
然後重啟postfix ,
systemctl restart postfix
11. 還沒想到
是這樣的, 偶公司原本已經有一台網域主控站, 例如 test.com.tw
登入帳號的是 william
但是突然有需求要代管副網域, 假設是 kafeiou.pw
test.com.tw 與 kafeiou.pw 的差異頗大
策略就是在新增帳號時, 後面加上 @kafeiou.pw
這樣就能區分若是登入的帳號有 @ , 就代管的網域
這樣有個好處, 郵件伺服器(postfix), 可以彈性代管多個網域.
只是要注意, 我在windows 2012測試的時候, 發現使用這種方式新增帳號, 會出現@被取代成_的現象,
原本william@kafeiou.pw會變成 william_kafeiou.pw
後來發現可以利用屬性編輯的方式,先找到sAMAccountName , 然後強制把william_kafeiou.pw修改回william@kafeiou.p, 測試了一下, 運行良好, 而且輸入完整的email登入也正常, 可以算是個小技巧
偶的郵件伺服器使用postfix + amavisd-new+clamav
最近很不好意思的發現 clamav 很早以前就支援google Safe Browsing , 除了防毒外,還可以過濾掉一些不正當的連結, 作法如下:
1. 修改/etc/freshclam.conf , 加上:
SafeBrowsing yes
2. 重啟clamav service, 或是postfix 透過amavisd不需要重啟service, 只要執行freshclam這個指令即可