{"id":6807,"date":"2014-04-23T08:07:38","date_gmt":"2014-04-23T08:07:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/how-can-i-fix-the-iptables-error-message-unable-to-initialize-table-filter-collection-of-common-programming-errors\/"},"modified":"2014-04-23T08:07:38","modified_gmt":"2014-04-23T08:07:38","slug":"how-can-i-fix-the-iptables-error-message-unable-to-initialize-table-filter-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/how-can-i-fix-the-iptables-error-message-unable-to-initialize-table-filter-collection-of-common-programming-errors\/","title":{"rendered":"How can I fix the iptables error message &ldquo;unable to initialize table &#39;filter&#39;&rdquo;?-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/709a11533e36376cf5c94d84a4724911?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser3215<\/p>\n<p>When I try to use iptables command on one of my Rackspace cloud server, I&#8217;m getting the following error.<\/p>\n<p>In an attempt to apply iptables rules with <code>iptables-apply -t 120 \/etc\/iptables.rules<\/code> and <code>iptables-restore &lt; \/etc\/iptables.rules<\/code> I got the next error:<\/p>\n<pre><code>FATAL: Could not load \/lib\/modules\/2.6.32.4-rscloud\/modules.dep: No such file or directory\niptables-restore v1.4.4: iptables-restore: unable to initialize table 'filter'\n\nError occurred at line: 2\nTry `iptables-restore -h' or 'iptables-restore --help' for more information.\n<\/code><\/pre>\n<p>How do I fix this?<\/p>\n<p><strong>EDIT 1<\/strong>:<\/p>\n<p><em>uname -r<\/em> :<\/p>\n<pre><code>2.6.32.4-rscloud\n<\/code><\/pre>\n<p><em>modprobe \/lib\/modules\/$(uname -r)\/kernel\/net\/ipv4\/netfilter\/iptable_filter.ko<\/em> :<\/p>\n<pre><code>FATAL: Could not load \/lib\/modules\/2.6.32.4-rscloud\/modules.dep: No such file or directory\n<\/code><\/pre>\n<p>ls \/lib\/modules\/$(uname -r)\/kernel\/net\/ipv4\/netfilter\/<\/p>\n<p>:<\/p>\n<pre><code>ls: cannot access \/lib\/modules\/2.6.32.4-rscloud\/kernel\/net\/ipv4\/netfilter\/: No such file or directory\n<\/code><\/pre>\n<p><strong>EDIT 2<\/strong>:<\/p>\n<p>apt-cache search linux-image-<\/p>\n<p>* :<\/p>\n<pre><code>alsa-base - ALSA driver configuration files\nlinux-image-2.6.31-14-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-14-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-14-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-302-ec2 - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-9-rt - Linux kernel image for version 2.6.31 on Ingo Molnar's full real time preemption patch\nlinux-image-rt - Rt Linux kernel image\nrt2400-source - source for rt2400 wireless network driver\nrt2500-source - source for rt2500 wireless network driver\nrt2570-source - source for rt2570 wireless network driver\nlinux-image - Generic Linux kernel image.\nlinux-image-2.6.31-15-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-15-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-15-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-16-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-16-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-16-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-17-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-17-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-17-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-19-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-19-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-19-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-20-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-20-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-20-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-21-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-21-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-21-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-304-ec2 - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-305-ec2 - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-306-ec2 - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-ec2 - Linux kernel image for ec2 machines\nlinux-image-generic - Generic Linux kernel image\nlinux-image-server - Linux kernel image on Server Equipment.\nlinux-image-virtual - Linux kernel image for virtual machines\nlinux-image-2.6.31-22-generic - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-22-server - Linux kernel image for version 2.6.31 on x86_64\nlinux-image-2.6.31-22-virtual - Linux kernel image for version 2.6.31 on x86\/x86_64\nlinux-image-2.6.31-307-ec2 - Linux kernel image for version 2.6.31 on x86\/x86_64\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e6875b9fee07521eed2e2c7e7214e531?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLekensteyn<\/p>\n<p>You need to load a kernel module for enabling the filter table. Run the next command as root:<\/p>\n<pre><code>modprobe \/lib\/modules\/$(uname -r)\/kernel\/net\/ipv4\/netfilter\/iptable_filter.ko\n<\/code><\/pre>\n<p>(<code>uname -r<\/code> gives the current kernel version)<\/p>\n<p>For a list of available modules for iptables, list the directory containing iptables modules:<\/p>\n<pre><code>ls \/lib\/modules\/$(uname -r)\/kernel\/net\/ipv4\/netfilter\/\n<\/code><\/pre>\n<p>To get information on all modules:<\/p>\n<pre><code>modinfo \/lib\/modules\/$(uname -r)\/kernel\/net\/ipv4\/netfilter\/*.ko\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bdae1bc502557d3e8b36ebfedf686313?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFrancis Turner<\/p>\n<p>Another way to get proper iptables support is to install xtables-addons, you need to have quite a lot of tools to get this working though (module-assistant, build-essential etc.), but the advantage is that at the end you have ipset as well as iptables and (IMHO) using ipset as well is much better for large complex rulesets<\/p>\n<pre><code>apt-get install xtables-addons-common\n\napt-get install xtables-addons-source\n\nm-a prepare\n\nm-a build xtables-addons\n\nm-a install xtables-addons\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6b92567199ee8a3e4a61c40a4406aff4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nThomas W.<\/p>\n<p>I also use the Rackspace Cloud, with kernel 2.6.35.4-rscloud. I have multiple instances with this kernel and iptables works fine on some and I have the same problem as you on a couple others.<\/p>\n<p>Therefore I believe this kernel does have the support it needs for iptables, and the issue is caused by something else (I&#8217;m still looking for the solution myself)<\/p>\n<p>EDIT: I solved my issue by <code>scp -r<\/code> copying the <code>\/lib\/modules\/2.6.35.4-rscloud<\/code> from the working <code>iptables<\/code> server to the non-working one.<\/p>\n<p>For some reason <code>uname -r<\/code> shows <code>2.6.35.4-rscloud<\/code> and <code>ls \/lib\/modules\/<\/code> only contained the previous version like <code>\/lib\/modules\/2.6.31-302-rs<\/code>.<\/p>\n<p>I&#8217;m not sure why this can fall out of synch, or what to do if you don&#8217;t have a working server to copy these files from, but hopefully this points you in the right direction.<\/p>\n<p>I did not need to recompile a kernel or anything like that.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/oAD7m.jpg?s=32&amp;g=1\" \/><br \/>\nMy Pet Ocean<\/p>\n<p>I had the same error, but I found a stray comment in an unrelated article (http:\/\/articles.slicehost.com\/2007\/11\/6\/ubuntu-gutsy-setup-page-1) that identified the silly molecular error that was at fault in my case. The problem was that I had created the <code>iptables.rules<\/code> file using a text editor (Notepad++), but because the file type wasn&#8217;t recognized, Notepad++ defaulted to using Windows <em>End-of-Line<\/em> and <em>End-of-File<\/em> characters. <code>iptables<\/code> rejects these characters, requiring their Unix equivalents, and was thus throwing an error upon the first occurrence: the end of the <code>*filter<\/code> line &#8212; giving the false impression that there was something wrong with the <code>*filter<\/code> syntax. Ah, the ever-present joys of character-encoding-related errors!<\/p>\n<p><strong>Two Solutions<\/strong><\/p>\n<ul>\n<li>The commenter I mentioned above installed (<code>sudo aptitude install tofrodos<\/code>) and ran (<code>fromdos \/etc\/iptables.rules<\/code>) a little conversion utility on the file.<\/li>\n<\/ul>\n<p>&#8212;OR&#8212;<\/p>\n<ul>\n<li>What I did was, in Notepad++, <code>Edit<\/code> &gt; <code>EOL Conversion<\/code> &gt; <code>UNIX Format<\/code>, and then <code>Save<\/code> and re-upload the file. That took care of the <em>End-of-Line<\/em> characters, but not the <em>End-of-File<\/em> character (despite what one might expect). So once I had it uploaded to the server, I opened it up in <code>nano<\/code> and created a newline at the end of the file and saved. Then everything worked perfectly.<\/li>\n<\/ul>\n<p>It <em>might<\/em> also be possible that merely opening the file in <code>nano<\/code> and resaving, without actually changing the characters manually, would do the trick, but I haven&#8217;t tested.<\/p>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/522c6a34bf3f37e901800915d7ae3d06?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPierre<\/p>\n<p>It is possible that the linux kernel you are using wasn&#8217;t built with loadable module support. A good way to find out if your kernel has module support is to check the existence of the file <code>\/proc\/modules<\/code>. If it is there but you don&#8217;t have a <code>\/lib\/modules\/$(uname -r)\/modules.dep<\/code> file, it means that your kernel has support for modules but that they were not correctly installed. It look like your kernel was built by your provider Rackspace, you should ask them about the kernel configuration.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>user3215 When I try to use iptables command on one of my Rackspace cloud server, I&#8217;m getting the following error. In an attempt to apply iptables rules with iptables-apply -t 120 \/etc\/iptables.rules and iptables-restore &lt; \/etc\/iptables.rules I got the next error: FATAL: Could not load \/lib\/modules\/2.6.32.4-rscloud\/modules.dep: No such file or directory iptables-restore v1.4.4: iptables-restore: unable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6807","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6807"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6807\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}