2026年6月12日 星期五

wireguard 日誌記錄

 #!/bin/bash
LOG_FILE=/home/WGlog/202606
TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")

echo "=== Log entry at $TIMESTAMP ===" >> $LOG_FILE
# 抓取介面、Peer ID、端點 IP 以及最後交握時間

wg show all dump | awk 'NF>1 {print TIMESTAMP, $1, $2, $4, $5}' TIMESTAMP="$TIMESTAMP" >>$LOG_FILE

echo "" >> $LOG_FILE

LEAF設定 WireGuard

編輯 leaf.cfg加入
wireguard

編輯 /etc/modules 加入
wireguard

編輯  /etc/shorewall/interfaces 加入
wg0    wg0     tcpflags,nosmurfs,routefilter,routeback

編輯  /etc/shorewall/zones 加入
wg0             ipv4

編輯 /etc/shorewall/rules 加入
ACCEPT    net                     fw      UDP 51820
ACCEPT    wg0:192.168.226.1       wg0     TCP 22
ACCEPT    wg0     wg0:192.168.226.1       TCP 4119,4120,4122,22
DROP         wg0                     wg0     all
Ping(ACCEPT)    wg0                     fw

產生 設定檔
#!/bin/sh
nodenum=20

spri=$(wg genkey); spub=$(echo $spri|wg pubkey)

# wireguard server
Endpoint=192.168.228.2:51820

# configure file
wg0conf=wg0.conf-
client=client.conf-

:>${client}
cat <<EOF0 >$wg0conf
#pri=${spri}
#pub=${spub}
[Interface]
Address = 192.168.226.253/24
ListenPort = 51820
PrivateKey = ${spri}

EOF0

for i in `seq 1 $nodenum`;do
pri=$(wg genkey); pub=$(echo $pri|wg pubkey)

cat <<EOF >>$client
## node $i ##############################################
[Interface]
PrivateKey = ${pri}
Address = 192.168.226.${i}/24

[Peer]
PublicKey = $spub
AllowedIPs = 192.168.226.0/24
Endpoint = ${Endpoint}
PersistentKeepalive = 25

EOF

cat <<EOF0 >>$wg0conf
## node $i ##############################################
[Peer]
PublicKey = ${pub}
AllowedIPs = 192.168.226.$i/32

EOF0

done

2026年5月27日 星期三

Debian 13 安裝中文輸入法 Fcixt5

sudo apt install fcitx5 fcitx5-config-qt fcitx5-frontend-gtk2 fcitx5-frontend-gtk3 fcitx5-frontend-gtk4 fcitx5-frontend-qt5

sudo apt install fcitx5-table-extra
sudo apt install fcitx5-chinese-addons
sudo apt install fcitx5-chewing

sudo apt install fcitx5-table-extra fcitx5-table-other
sudo apt install fcitx5-table-boshiamy

Debian 13 安裝 Fcix5


sudo apt install fcitx5 fcitx5-config-qt fcitx5-frontend-gtk2 fcitx5-frontend-gtk3 fcitx5-frontend-gtk4 fcitx5-frontend-qt5

sudo apt install fcitx5-table-extra
sudo apt install fcitx5-chinese-addons
sudo apt install fcitx5-chewing

sudo apt install fcitx5-table-extra fcitx5-table-other
sudo apt install fcitx5-table-boshiamy

2026年5月15日 星期五

Linux script 載入 module

 _MODULES="overlay squashfs loop"

_USB_MODULES="xhci_pci xhci_hcd ehci_pci ohci_hcd uhci_hcd"
_USB_MODULES="$_USB_MODULES usb_storage uas"
_USB_MODULES="$_USB_MODULES sd_mod"
_USB_MODULES="$_USB_MODULES vfat exfat"

timeout 300 sh -c 'while true;do _t=1;for i in /modules/*;do insmod ${i}&&_t=0;done; [ ${_t} -gt 0 ]&&break; done;'

find /sys/devices -name modalias|xargs -n 1 cat|xargs -r modprobe -abq
for i in $_MODULES $_USB_MODULES;do modprobe ${i};done

2026年5月14日 星期四

/proc/cmdline 變數解析

 for i in $(cat /proc/cmdline);do case $i in *=*) eval $i;  ;; esac; done

inotify module 摘要

支援狀態
grep INOTIFY_USER /boot/config-$(uname -r)

通常為核心功能(Built-in)
modprobe inotify_user

事件類型
IN_ACCESS:檔案或目錄被存取時。
IN_MODIFY:檔案的內容被修改時。
IN_ATTRIB:檔案或目錄的屬性被改變時。
IN_OPEN:檔案被開啟時。
IN_CLOSE_WRITE:一個已開啟的檔案或目錄被關閉時。
IN_MOVED_FROM:被移動的檔案或目錄是來自於被監控的目錄。
IN_MOVED_TO:被移動的檔案或目錄被放置到被監控的目錄。
IN_DELETE:檔案或目錄被刪除時。
IN_CREATE:檔案或目錄建立時。

相關組態
/proc/sys/fs/inotify/max_queued_events
設定個別的實例可允許放入隊列中的監控事件(Event)最大個數,即表示每個實例所監控的檔案或目錄,異動的次數在一段時間內不能超過此組態所設定的值,檔案預設值為16384。

/proc/sys/fs/inotify/max_user_instances
每一個使用者最大可建立的實例個數,檔案預設值為128。

/proc/sys/fs/inotify/max_user_watches
每個實例最大能監控的檔案及目錄的個數,檔案預設值為8192。

inotify 相關軟體
inotify-tools、sersync、lrsyncd、fswatch