自己在設定 Linux 防火牆規則時,都是習慣使用 iptables 指令,把規則寫在 Script 檔,設定成開機時執行,比較不習慣使用第三方的套件來建立,因為後續要修改時會比較麻煩。
不過在 Cubie Truck 的 Ubuntu Server 似乎預設就有安裝 ufw(Uncomplicated Firewall),利用 ufw 來建立防火牆規則。
但在執行 ufw 時會出現一些警告訊息
# ufw status verbose
WARN: /lib is group writable!
WARN: /etc is group writable!
WARN: /etc/default is group writable!
WARN: /usr is group writable!
Status: inactive
看起來似乎是警告這些目錄的權限是群組可以寫入的[@more@]檢查一些這些目錄的權限,預設權限是 775
# ls -ld /lib /etc /etc/default /usr
drwxrwxr-x 96 root root 4096 Oct 18 10:53 /etc
drwxrwxr-x 2 root root 4096 Oct 16 23:18 /etc/default
drwxrwxr-x 21 root root 4096 Oct 16 23:18 /lib
drwxrwxr-x 10 root root 4096 Sep 6 17:54 /usr
把這些目錄的權限改成 751
# chmod 751 /lib /etc /etc/default /usr
# ls -ld /lib /etc /etc/default /usr
drwxr-x–x 96 root root 4096 Oct 18 10:53 /etc
drwxr-x–x 2 root root 4096 Oct 16 23:18 /etc/default
drwxr-x–x 21 root root 4096 Oct 16 23:18 /lib
drwxr-x–x 10 root root 4096 Sep 6 17:54 /usr
再次執行 ufw 時,就不會出現警告訊息了!
# ufw status verbose
Status: inactive