カーネル再構築後にiptablesでエラー

CentOS5.2のデフォルトカーネルカーネル2.6.18-92.el5-x86_64から最新カーネル2.6.28に変更してブートしたところ、iptablesで下記のエラーが発生。

iptables-restore: line 20 failed 

/etc/sysconfig/iptablesの中を見ると、20行目にCOMMITという文字が

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

色々と調査したところ、下記の記事がヒット
http://www.djatlantic.net/?p=254
http://help.lockergnome.com/linux/iptables-restore-barfs-COMMIT--ftopict282705.html


COMMITが悪いんじゃなくて、その前にある-mオプションで読み込むモジュールがカーネルに組み込まれてないのが原因でした。

とりあえず、再度コンパイル
cd /usr/src/kernels/linux-2.6.28/

make menuconfig
を実行して下記のように遷移してモジュールを有効にしていきます。

Networking support → Networking options 
→ Network packet filtering framework (Netfilter)
→ Core Netfilter Configuration

<M> Netfilter connection tracking support 
 [*]   Connection tracking flow accounting
 [*]   Connection mark tracking support
 [*]   Connection tracking security mark support
 [*]   Connection tracking events

<M>   "state" match support

ここでstateを有効にしたので、iptablesで指定した-m stateで起こった問題が解決しました。


それと、/etc/sysconfig/iptables-configで下記のモジュールを呼んでいるので、それもカーネルに組み込みが必要でした。

 IPTABLES_MODULES="ip_conntrack_netbios_ns"

make menuconfigで下記も有効に

Networking support → Networking options 
→ Network packet filtering framework (Netfilter)
→ IP: Netfilter Configuration

<M> IPv4 connection tracking support (required for NAT)
<M>   Packet filtering    
<M>     REJECT target support
<M>   LOG target support     
<M>   ULOG target support    
<M>   Full NAT
  <M>     MASQUERADE target support
<M>   Security table


これで再度コンパイルしたらiptablesが無事に稼動しました。やれやれ。