記錄一下,在 FreeBSD 載入 ipfw 而不用重開機的方法:

  • 先編輯 /etc/rc.conf,主要就是加入 firewall_type 這個參數:
    # Define the firewall type in /etc/rc.conf.  Valid values are:
    #   open     - will allow anyone in
    #   client   - will try to protect just this machine
    #   simple   - will try to protect a whole network
    #   closed   - totally disables IP services except via lo0 interface
    #   UNKNOWN  - disables the loading of firewall rules.
    #   filename - will load the rules in the given filename (full path required)
    
  • 因為 kldload 不會去執行 /etc/rc.firewall,而預設規則是 block all,所以指令要「用同一行」這麼下:
    kldload ipfw; sh /etc/rc.firewall

    如此一來,才有可能讓 ipfw 載入 /etc/rc.firewall 所指到的,能夠讓我們再連進去的「入口」。

  • 指令下完後,SSH 會立刻斷線,但可以馬上再連進去。如果有用 screen 的話,可以恢復到原先的環境。
  • 可以在 /etc/loader.conf 加入下面這行,以便在重開機之後,自動載入 ipfw 模組:
    ipfw_load="YES"
    

也許該來研究一下 mod_security 怎麼用了。