「UFW」:修訂間差異

出自Gea-Suan Lin's Wiki
跳至導覽 跳至搜尋
本頁面具有訪問限制。如果您看見此訊息,這代表您沒有訪問本頁面的權限。
 
(未顯示同一使用者於中間所作的 4 次修訂)
行 3: 行 3:
== 設定 ==
== 設定 ==


可以 修改<code>/etc/rsyslog.d/20-ufw.conf</code> 內的設定,關閉阻擋的log寫到dmesg裡面
UFW會產生大量的log寫進netfilter log,然後進到dmesg,目前只有關閉UFW的log 可以 避免<ref>{{Cite web |url=https://askubuntu.com/questions/10836/is-there-a-way-to-keep-ufw-logging-out-of-dmesg |title=Is there a way to keep UFW logging out of dmesg? |language=en |accessdate=2021-03-11}}</ref>:


<syntaxhighlight lang="cfg">
<syntaxhighlight lang="bash">
# Log kernel generated UFW log messages to file
sudo ufw logging off
:msg,contains,"[UFW " /var/log/ufw.log
 
# Uncomment the following to stop logging anything that matches the last rule.
# Doing this will stop logging kernel generated UFW log messages to the file
# normally containing kern.* messages (eg, /var/log/kern.log)
& stop
</syntaxhighlight>
</syntaxhighlight>


行 28: 行 22:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo ufw enable
sudo ufw enable
</syntaxhighlight>
== 快速設定 ==
給我自己用的。
<syntaxhighlight lang="bash">
sudo ufw logging off; sudo ufw allow from 114.34.121.114; sudo ufw allow from 35.234.52.75; sudo ufw enable
</syntaxhighlight>
</syntaxhighlight>


行 33: 行 35:


* [[iptables]]
* [[iptables]]
== 參考資料 ==
{{Reflist|2}}


== 外部連結 ==
== 外部連結 ==

於 2024年2月20日 (二) 11:58 的最新修訂

UFW是一套在Linux上常見的防火牆管理軟體,底層通常是iptables

設定

UFW會產生大量的log寫進netfilter log,然後進到dmesg,目前只有關閉UFW的log可以避免[1]

sudo ufw logging off

範例

建議先設定:

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

然後再啟用:

sudo ufw enable

快速設定

給我自己用的。

sudo ufw logging off; sudo ufw allow from 114.34.121.114; sudo ufw allow from 35.234.52.75; sudo ufw enable

相關連結

參考資料

  1. Is there a way to keep UFW logging out of dmesg?. [2021-03-11] (English). 

外部連結