Kernel – Can’t Initialize Iptables Table `filter’: Table Does Not Exist

iptableskernelmodproberaspberrypi

I'm trying to open up port 1900 for UDP in order for the Echo to be able to discover the HA Bridge using the following command but I get errors. What is the best solution to fix this?

pi@raspberrypi:~/hue $ sudo iptables -I INPUT -p udp --dport 1900 -j ACCEPT
modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/4.1.17-v7+/modules.dep.bin'
iptables v1.4.21: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
pi@raspberrypi:~/hue $ sudo depmod
depmod: ERROR: could not open directory /lib/modules/4.1.17-v7+: No such file or directory
depmod: FATAL: could not search modules: No such file or directory

pi@raspberrypi:~/hue $ sudo apt-get install --reinstall linux-image-4.1.17
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package linux-image-4.1.17
E: Couldn't find any package by regex 'linux-image-4.1.17'

pi@raspberrypi:~/hue $ uname -a
Linux raspberrypi 4.1.17-v7+ #838 SMP Tue Feb 9 13:15:09 GMT 2016 armv7l GNU/Linux

Best Answer

These commands solved the problem for me (change the versions respectively):

 601  ls -lha /lib/modules
  602  pwd
  603  cp -R /lib/modules/4.1.18+ /lib/modules/4.1.17+
  604  sudo cp -R /lib/modules/4.1.18+ /lib/modules/4.1.17+
  605  sudo cp -R /lib/modules/4.1.18-v7+/ /lib/modules/4.1.17-v7+
  606  sudo apt-get install rpi-update
  607  sudo iptables --list
  608  sudo iptables -I INPUT -p udp --dport 1900 -j ACCEPT