
我在 Ubuntu 11.4 系統上使用以下命令保存了 iptable 設置
iptables-save >filename
然後我將Ubuntu系統替換為CentOS 6.5並嘗試使用恢復iptables
iptables-restore <filename
這導致了
iptables-restore v1.4.7: Can't set policy 'INPUT' on 'ACCEPT' line 4: Bad bilt-in chain name
第 4 行如下。
:INPUT ACCEPT [199972:10416012]
過去,我已經能夠將 Ubuntu 系統的 iptables 恢復到 Debian 系統,但 Debian 與 Ubuntu 的關係比 CentOS 更密切。使用 CentOS,我只需要手動新增規則嗎?
答案1
我做到了
iptables-save >iptables.original
在我的 CentOS 機器上,看到
:INPUT ACCEPT
iptables.original 中不存在該行。所以我註解掉了我在 Ubuntu 上保存的文件中的行
iptables-restore <filename
不再給出任何錯誤訊息。我隨後做了
iptables-restore --list-rules
規則看起來就是我想要的。