我正在尝试应用以下内容:
/sbin/iptables -t nat -I PREROUTING --src 0/0 --dst [MY IP] -p tcp --dport 40 -j REDIRECT --to-ports 80
但是,我得到以下错误:
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.
我正在运行CentOS 5.5。 任何人都可以请指教?
UPDATE
ifconfig输出:
eth0 Link encap:Ethernet HWaddr 00:18:51:A4:3E:E0 inet addr:xxxx 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输出:
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
更新2
grep -v \# /etc/sysconfig/iptables-config输出:
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"
更新3
sudo /sbin/iptables -L输出:
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 sudo /sbin/lsmod | egrep -i iptables输出:BLANK。
sudo /sbin/lsmod | egrep -i nat sudo /sbin/lsmod | egrep -i nat输出:BLANK。
更新4
uname -a输出:
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
根据你的内核版本来判断,你是在一个OpenVZ容器中运行的。
要么你错过了/ lib / xtables中的NAT库和/或OpenVZ内核实际上没有加载NAT内核模块 – 我打赌后者很可能是这种情况; 如果你想要NAT,你需要问你的VPS提供商为你加载模块。
修改你的/ etc / sysconfig / iptables-config,如下所示:
IPTABLES_MODULES="iptable_nat"