pawlo.gom
By:
pawlo.gom

Problem with Iptables.

November 18, 2013 34.9k views
Hi. I have a problem with Iptables. I can`t use the command: sudo iptables -L, because the error is: FATAL: Could not load /lib/modules/3.2.0-55-virtual/modules.dep: No such file or directory iptables v1.4.12: can't initialize iptables table `filter': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. I have installed on my droplet (system ubuntu 12.04) Zpanel and fail2ban according to this guide: https://digitalocean.com/community/articles/how-to-protect-ssh-with-fail2ban-on-ubuntu-12-04 Please, help me. Thank for every piece of advice!
3 comments
16 Answers
@Leandro: You have to install the kernel that you're using:
sudo apt-get install linux-image-$(uname -r)


Once that's done, it should work. If it doesn't, try rebooting your droplet.
  • Thanks. Thats the one i needed.
    it solved my problem.
    Thanks a lot.

    just use the following command guys

    sudo apt-get install linux-image-$(uname -r)
    
You must install the kernel package corresponding to the kernel you set your droplet to boot from (using our control panel).
Did you update your kernel by chance?

I had a similar problem with playing around with new kernel. Any update would break UFW.

Never bothered to try to find correct answer just moved kernel back to default.


In your case it would be 3.2.0-55-virtual
in my case, uname said the kernel is 3.2.0-55-virtual .
and it is 3.2.0-55-virtual in my control panel - settings - kernel.
but still got the error:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE && iptables-save
FATAL: Could not load /lib/modules/3.2.0-55-virtual/modules.dep: No such file or directory
iptables v1.4.12: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
oh, I found the problem:
ls /lib/modules/
3.2.0-23-virtual

Hi Will, I´m having the same problem whit the same version, how do I update/upgrade the /lib/modules? In my case under this folder I have two folders (3.2.0-24-virtual and 3.2.0-48-virtual) and I´m using 3.2.0-55-virtual as you...
Kamal Nasser, Thank you for the no hassle solution. It worked, ufw started working again after a reboot.
I'm having the same issue. I've not changed the kernal from what was installed.
I moved it back to the default, but it still doesn't work.

uname -r
3.5.0-17-generic
ls /lib/modules/
drwxr-xr-x 4 root root 4096 May 1 11:03 3.5.0-17-generic

modprobe ip_tables
FATAL: Error inserting ip_tables (/lib/modules/3.5.0-17-generic/kernel/net/ipv4/netfilter/ip_tables.ko): Operation not permitted

FATAL: Error inserting ip_tables (/lib/modules/3.5.0-17-generic/kernel/net/ipv4/netfilter/ip_tables.ko): Operation not permitted
iptables v1.4.12: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
@chas.snider: It sounds like there is a mismatch between the kernel you have installed and the kernel selected in the DigitalOcean panel. Make sure the versions match.

sudo apt-get install linux-image-$(uname -r)

fixed the issue for me

Thanks @Kamal

sudo apt-get install linux-image-$(uname -r)

worked for me also! thanks!

What is the process for a solution for Centos 7?
Looks like I was in panic mode when I posted this question. I did correct the issue by injecting the new kernel from the management section and powered down and back up. Evidently the kernel is independently managed and I did not know that.

Another advice is to try reinstall kernel:
sudo apt-get install --reinstall linux-image-$(uname -r)

Have another answer? Share your knowledge.