I am trying to set up my Raspberry Pi as a Man In The Middle device to monitor devices on my home network. When I try to forward port 80 to port 8080 (to allow the webpage to be loaded on the device) I receive an error. Here is the command I'm running to forward the port.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

I receive the following error.

libkmod: ERROR ../libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file '/lib/modules/3.10.28+/modules.dep.bin'
iptables v1.4.14: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)

Can someone help me, did I not install a package correctly?


Add "sudo" to you command that it shoudl work:

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

  • But I am logged in as root, do I still have to use the sudo command with ipables? – user10394 Mar 6 '14 at 23:07

it doesn't look like you have the ports accepted. So, firstly try (line by line):

sudo iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT

sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Notice that eth0 is your ethernet adaptor, and wlan0 is your wireless adaptor (in case you have one) You can then type: sudo iptables -L. You should then see at least three entries. You can test, and you will have to save it somewhere and let your /etc/network/interfaces restore it when it boots. Optionally you can use iptables-persistent, which does the same really.

Here you have all info in Debian: https://wiki.debian.org/iptables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy