I'm facing strange problem with iptables right now. Simply, I want to redirect traffic from port 514 to port 5140. I'm using this IPTables command to achieve it:
iptables -t nat -A PREROUTING -p tcp --dport 514 -j REDIRECT --to-port 5140
But I still get error about no chain
iptables: No chain/target/match by that name.
There is definitelly PREROUTING chain in nat table, this is iptables -t nat -nL
root@VPS-LOGGER-TMP:~# iptables -t nat -nL
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
I'm using Debian Wheezy and I have loaded all needed modules:
root@VPS-LOGGER-TMP:~# lsmod |grep nat
iptable_nat 12928 0
nf_nat 18242 1 iptable_nat
nf_conntrack_ipv4 14078 4 nf_nat,iptable_nat
nf_conntrack 52720 4 xt_state,nf_conntrack_ipv4,nf_nat,iptable_nat
ip_tables 22042 2 iptable_filter,iptable_nat
x_tables 19118 9 ip_tables,iptable_filter,xt_multiport,ip6_tables,ip6table_filter,xt_state,xt_tcpudp,ipt_REJECT,iptable_nat
Can you tell me what I'm doing wrong? As far as I know this should work perfectly. Thanks a lot.
You need
set to y or m in your kernel configuration in order to use -j REDIRECT.
The module would be called xt_REDIRECT, and that seems to be missing on your machine.