顯示具有 dns 標籤的文章。 顯示所有文章
顯示具有 dns 標籤的文章。 顯示所有文章

2026/05/23

最近一直有人反應 google寄google都會被送到垃圾信
看了一下原始郵件
發現spf沒有過

SPF: NONE,IP 209.85.220.41 

所以在dns 把spf設定到google去
既然要設了
就連m365一起

;spf for google
aa,bb.com.tw.  3600  IN   TXT   "v=spf1 include:_spf.google.com ~all"
qq.bb.com.tw.  3600  IN   TXT   "v=spf1 include:_spf.google.com ~all"

;spf for m365
ee.bb.com.tw.  3600  IN   TXT   "v=spf1 include:spf.protection.outlook.com -all"

2024/02/21

今天有個新需求要記錄dns 的client query 

試了半天
只有放在這個目錄

/var/named/chroot/var/log/

才能正常的log 輪換

在/etc/named.conf加上以下這段

logging {
channel query_log {
file "/var/named/chroot/var/log/query.log" versions 3 size 1m;
severity info;
print-time yes;
};
category queries {
query_log;
};
};


versions 3 size 1m;
表示每個檔案 1m 保留3個輪換的檔案


2023/12/02

最近這几天 規定要往上指的 DNS 發生故障
重點是 發生故障也不通知下層單位
真是有夠無言的
本來沒有在監控記錄 dns query 的 response time
想說來加一下好了 加在 librenms
搞了好久
最後發現不會自動帶入 Remote Host
要在 Parameters 下完整
最終沒問題的設定方式如下圖





2021/06/06

安裝jitsi的流程記錄一下 ubuntu 20.04

os安裝好後

apt update

apt upgrade -y

在DNS上設定好server的name

接下來 

apt install curl gnupg

curl https://download.jitsi.org/jitsi-key.gpg.key | sudo sh -c 'gpg --dearmor > /usr/share/keyrings/jitsi-keyring.gpg'

echo 'deb [signed-by=/usr/share/keyrings/jitsi-keyring.gpg] https://download.jitsi.org stable/' | sudo tee /etc/apt/sources.list.d/jitsi-stable.list > /dev/null

sudo apt-get -y update

sudo apt-get -y install jitsi-meet

如果要使用letsencrypt

apt install certbot

/usr/share/jitsi-meet/scripts/install-letsencrypt-cert.sh

重啟nginx
到 https://servername
就可以使用了

letsencrypt要記得每三個月renew一次
或使用crontab 
1 1 * * 6 /usr/bin/certbot renew

https://kafeiou.pw/2020/06/19/2489/
https://campus-xoops.tn.edu.tw/modules/tad_book3/page.php?tbdsn=1557

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來做了

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/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

2017/08/31

使用rsyslog 收資料時
預設會去反解來源的ip
可以修改以下參數停用
加上 -Q -x

範例

SYSLOGD_OPTIONS=”-c3 -Q -x”

https://ssorc.tw/1194

2015/05/08

在 mail server的log裡發現

postfix/smtp[1921]: 347A79E0739: to=<abc@gmail.com>, orig_to=<abc@bbb.edu.tw>, relay=alt1.gmail-smtp-in.l.google.com[74.125.25.27]:25, delay=239783, delays=239779/0.04/2.6/0.84, dsn=4.7.0, status=deferred (host alt1.gmail-smtp-in.l.google.com[74.125.25.27] said: 421-4.7.0 [2.3.4.5      15] Our system has detected an unusual rate of 421-4.7.0 unsolicited mail originating from your IP address. To protect our 421-4.7.0 users from spam, mail sent from your IP address has been temporarily 421-4.7.0 rate limited. Please visit 421-4.7.0 http://www.google.com/mail/help/bulk_mail.html to review our Bulk 421 4.7.0 Email Senders Guidelines. d5si4976585pdi.47 - gsmtp (in reply to end of DATA command))

被google擋信了
查了一下google的網頁說明
有三個方式可以處理
最方便的是在DNS設定spf

;spf for google
bbb.edu.tw.  3600  IN   TXT   "v=spf1 ip4:2.3.4.5 include:_spf.google.com ~all"

設定後重啟DNS
等cache更新後就ok了

2015/03/09

一直都是在user 的.profile把mail forward到gmail去
可是最近突然發現有些mail沒收到
check了一下mail log
發現以下的訊息

Mar  6 16:48:26 mail postfix/smtp[31508]: 206879E074E: to=<test@staff.edu.tw>, orig_to=<test2@mail.edu.tw>, relay=ASPMX.L.GOOGLE.COM[74.125.23.26]:25, delay=2, delays=0.01/0.01/0.54/1.4, dsn=5.7.1, status=bounced (host ASPMX.L.GOOGLE.COM[74.125.23.26] said: 550-5.7.1 [1.1.1.1      12] Our system has detected that this message is 550-5.7.1 likely unsolicited mail. To reduce the amount of spam sent to Gmail, 550-5.7.1 this message has been blocked. Please visit 550-5.7.1 http://support.google.com/mail/bin/answer.py?hl=en&answer=188131 for 550 5.7.1 more information. x1si13668566pdp.46 - gsmtp (in reply to end of DATA command))

居然被google視為spam而擋了
找了一下解決方法有三個 SPF DKIM DMARC
最快的是設定SPF
https://support.google.com/a/answer/178723?hl=zh-Hant

參考以下資料設定完成後
http://www.icst.org.tw/ArticlesDetail.aspx?seq=1351&lang=zh

目前沒有再出現被擋的訊息了
持續觀察中

不知道是不是太多人設forward了
XD

2012/12/21

之前裝了一台ubuntu 12.04
今天要update時發現找不到網站
dns沒解到
手動加到/etc/resolv.conf
重開後竟然又消失了
找了一下才發現必須加到
/etc/network/interfaces

auto eth0 
iface eth0 inet static  
address 192.168.1.2
netmask 255.255.255.0  
gateway 192.168.1.254
dns-nameservers 8.8.8.8 8.8.4.4

感覺上好像是因為一開始先使用dhcp後來再改成static ip的關係
為什麼之前一直沒發現
XD

2012/04/14

今天在snort的log發現來自外部的dns query ddos

所以寫了一支程式來block
要把query log打開
在/etc/named.conf裡加上



logging {


              channel query_log {


                      file "query.log" versions 1 size 20m;


                      severity info;


                      print-time yes;


                      print-category  yes;


              };


              category queries {


                      query_log;


              };


      };


restart dns