8

I'm trying to do some NAT on my Raspi 2 running Raspbian. But when I try to do anything with the nat table in iptables, I get the following error:

iptables v1.4.21: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.

And when I try modprobe:

pi@raspberrypi:~ $ sudo modprobe iptables
modprobe: ERROR: ../libkmod/libkmod.c:557 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.11-v7+/modules.dep.bin'

Version info:

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.4.11-v7+ #888 SMP Mon May 23 20:10:33 BST 2016 armv7l GNU/Linux
Cnly
  • 183
  • 1
  • 1
  • 4

1 Answers1

11

Quick guess: You've upgraded the OS and the system has been up for a very long time, or managed to upgrade it without replacing the kernel, because the 4.4.11-v7+ modules have already been removed from Raspbian.

If there is no such directory as /lib/modules/4.4.11-v7+ (look) you should run sudo apt update then sudo apt upgrade to ensure your kernel has been replaced, then reboot and check uname -r; it should give a version with a corresponding /lib/modules/ directory that does exist. The pi kernel can boot without any, however, so to check, try lsmod; if there's nothing, something is wrong. If there is, you can filter that lsmod | grep -P "ip|nf" to see the ones that are related to iptables/netfilter (and anything else that coincidentally contains those letter combinations).

The base module is actually ip_tables, but it should be loaded automatically. The base module for NAT is nf_nat but that should be loaded automatically as well.

goldilocks
  • 60,325
  • 17
  • 117
  • 234