跳轉到內容
View in the app

A better way to browse. Learn more.

PHP論壇人

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

6.Debian預設防火牆更改為iptables防火牆 / 設置 rc.local 開機啟動

精選回覆

發表於

-------------------------------------------
Debian預設防火牆更改為iptables防火牆
-------------------------------------------

看看預設是否為 ufw 防火牆
ufw status

 

顯示 Status: active

這家主機商的Debian預設防火牆是安裝 ufw 防火牆

而有部份主機商或舊版Debian可能是 nftables 防火牆

 

 

由於我慣用iptables防火牆,因此移除ufw防火牆

apt remove ufw

 

安裝iptables防火牆
apt install iptables

 

看看iptables防火牆是否運作
iptables -L -v

 


------------------------------
設定防火牆規則
------------------------------

cd /usr/local/bin


vi firewall.sh

將iptables防火牆的規則,複製貼上到firewall.sh檔案裡

主要是 IN_TCP_PORTALLOWED="22,你的IP 888,你的IP 80 443"

這一行修改為你的IP,讓 22 port / 888 port 只讓你指定IP能連入

若使用在寶塔面板 xxxxx port,就是該 寶塔port 只能讓你連入,其餘IP都無法連

 


iptables防火牆的規則,放在附件中

firewall.sh

 

 

儲存並離開
:wq

 

變更權限
chmod +x /usr/local/bin/firewall.sh

 

測試防火牆
./firewall.sh

./firewall.sh start

 

 

-------------------------
設置 rc.local 開機啟動
-------------------------

網路找到 rc.local 開機啟動


cat /lib/systemd/system/rc-local.service

systemctl status rc-local

 

 

將底下代碼寫入到rc.local

vi /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.



exit 0
EOF

 


儲存並離開
:wq

 

執行 變更權限
chmod +x /etc/rc.local

 


啟動 rc-local 服務
systemctl enable --now rc-local

無視警告...

因為這個服務沒有任何依賴的系統服務,只是開機啟動 /etc/rc.local 腳本

將需要開機啟動的命令加到 /etc/rc.local 檔案中,放在 exit 0 前面即可,然後重開機


再次修改rc.local
vi /etc/rc.local

 

把這一行,放在 exit 0 前面即可

/usr/local/bin/firewall.sh start

 

儲存並離開
:wq

 

重開機
reboot

確認iptables防火牆的規則,有無成功執行,就是要看到你指定的IP有無出現

iptables -L

再次查看rc.local狀態
systemctl status rc-local.service 

已經是 active (exited)

本文章最後於,由Jack編輯

建立帳號或登入後發表意見

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.