部分執行yum update升級或自己編譯了Linux核心的系統,在完成升級以後,重啟或啟動iptables會出現“iptables-restore: unable to initialize table 'filter''”錯誤,中文翻譯是:iptables的恢複:無法初始化表“過濾器”。
詳細錯誤如下:
Applying iptables firewall rules: FATAL: Could not open 'kernel/net/ipv4/netfilter/ip_tables.ko': No such file or directoryiptables-restore v1.4.9: iptables-restore: unable to initialize table 'filter'Error occurred at line: 1Try `iptables-restore -h' or 'iptables-restore --help' for more information.
這個原因是可能在升級核心時,同時升級了iptables的系統模組,最新的模組未被載入,所以我們可以嘗試以下方法解決。
一、嘗試直接載入模組
modprobe ip_tablesmodprobe iptable_filter
手動載入 ip_tables 和 iptables_filter模組,若沒提示錯誤,表示模組載入沒問題,直接嘗試iptables重啟即可。
若提示以下錯誤(如)請嘗試第二步操作:
二、檢查當前核心中是否有iptables相關模組
ls -al /lib/modules/`uname -r`/kernel/net/ipv4/netfilter
SSH執行以上命令,並輸出以下結果
如果在輸出的結果中擁有以上兩個紅色框線所示內容,則表示系統中有相關模組,但可能沒被載入,需要手動載入。如果沒有框線所示內容,請嘗試重新編譯核心。
depmod -a
載入完畢後,再進行一次模組載入
modprobe ip_tablesmodprobe iptable_filter
SSH執行以上命令,重新分析並載入模組,執行完畢,嘗試啟動iptables,如則表示啟動成功。
三、附一個核心重編譯方法
cd /usr/src/linux #進入源碼目錄make install #進行安裝操作