Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to apply the following:

/sbin/iptables -t nat -I PREROUTING --src 0/0 --dst [MY IP] -p tcp --dport 40 -j REDIRECT --to-ports 80

However I get the following error:

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

I am running CentOS 5.5. Can anyone please advise?

UPDATE

ifconfig output:

eth0      Link encap:Ethernet  HWaddr 00:18:51:A4:3E:E0
          inet addr:x.x.x.x  Bcast:173.201.16.255  Mask:255.255.255.0
          inet6 addr: fe80::218:51ff:fea4:3ee0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29678326 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13545931 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2604591444 (2.4 GiB)  TX bytes:6052013635 (5.6 GiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:34139502 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34139502 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5160432652 (4.8 GiB)  TX bytes:5160432652 (4.8 GiB)

lo:1      Link encap:Local Loopback
          inet addr:97.74.207.156  Mask:255.255.255.255
          UP LOOPBACK RUNNING  MTU:16436  Metric:1

lo:2      Link encap:Local Loopback
          inet addr:173.201.181.56  Mask:255.255.255.255
          UP LOOPBACK RUNNING  MTU:16436  Metric:1

uname -a output:

Linux ip-173-201-16-45.ip.secureserver.net 2.6.18-028stab070.14 #1 SMP Thu Nov 18 16:04:02 MSK 2010 i686 i686 i386 GNU/Linux

UPDATE 2

grep -v \# /etc/sysconfig/iptables-config output:

IPTABLES_MODULES=""

IPTABLES_MODULES_UNLOAD="yes"

IPTABLES_SAVE_ON_STOP="no"

IPTABLES_SAVE_ON_RESTART="no"

IPTABLES_SAVE_COUNTER="no"

IPTABLES_STATUS_NUMERIC="yes"

IPTABLES_STATUS_VERBOSE="no"

UPDATE 3

sudo /sbin/iptables -L output:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

sudo /sbin/lsmod | egrep -i iptables output: BLANK.

sudo /sbin/lsmod | egrep -i nat output: BLANK.

UPDATE 4

uname -a outputs:

Linux ip-173-201-16-45.ip.secureserver.net 2.6.18-028stab070.14 #1 SMP Thu Nov 18 16:04:02 MSK 2010 i686 i686 i386 GNU/Linux
share|improve this question
    
Please give us the output of ifconfig, lspci, and uname -a? –  quanta Aug 17 '11 at 15:13
    
@quanta - Hi. I have added ifconfig and uname - a output above, but lspci returns an error bash: lspci: command not found. I have tried using sudo lspci and /sbin/lspci but no luck. –  Christopher Aug 17 '11 at 15:19
    
Assuming the system is fully up to date, and the firewall config is free of syntax errors... what is the output of sudo /sbin/iptables -L sudo /sbin/lsmod | egrep -i iptables sudo /sbin/lsmod | egrep -i nat –  tagram Aug 17 '11 at 15:32
    
what is output for # "lsmod |grep nat" AND "grep -v \# /etc/sysconfig/iptables-config". do you start /etc/init.d/iptables ? –  Rikih Aug 17 '11 at 15:34
    
Try updating kernel unless haven't already. –  poige Aug 17 '11 at 15:35
show 18 more comments

2 Answers

up vote 1 down vote accepted

Judging by your kernel version you are running inside an OpenVZ container.

Either you are missing the NAT libraries in /lib/xtables and/or the OpenVZ kernel does not actually have the NAT kernel module loaded - I would wager that the latter is most likely the case; if you want NAT you will need to ask your VPS provider to load the module for you.

share|improve this answer
    
Hi. Yeah, looks like the only option now. I have now raised a ticket with Godaddy. Thank you. –  Christopher Aug 19 '11 at 8:50
    
Unfortunately, my VPS provider does not support NAT modules and cannot change my kernel. Thank you. –  Christopher Aug 22 '11 at 11:27
add comment

Modify your /etc/sysconfig/iptables-config as follows:

IPTABLES_MODULES="iptable_nat"
share|improve this answer
    
Hi. I have added that to the config and restarted iptables but the error still apppears.. –  Christopher Aug 17 '11 at 16:31
    
You should then preload the module: insmod iptable_nat –  Ochoto Aug 17 '11 at 16:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.