I'm trying to route the trafic that goes through eth0 on port 24 to a device connected to a local eth1 network on the same port.
I've tried to do it using iptables through an SSH session using the command:
iptables -t nat -A PREROUTING -p tcp --dport 24 -j DNAT --to-destination 192.168.22.1:24
i get the following message:
iptables v1.4.21: can't initialize iptables table 'nat': Table does not exist (do you need insmod?) Perhaps iptables on your kernel needs to be upgraded.
does anyone have an idea how I could go on fixing this? Is my approach even the right one?
First things first: what version of the OS is reported by MAX? Or, from the ssh console, run uname -a and post that.
Now, before you trek down this path of learning and discovery, I think it warrants some clarification: what you want to achieve is to take inbound traffic to your NI Linux RT system, destined for a particular port (24), and send that traffic onward to another target (192.168.22.1), is that correct? This is basically the same sort of functionality offered on consumer routers to allow access to a machine on your home LAN from the internet (on a port-by-port basis). I will assume that this is the intended result.
Moving on, no matter what kernel you are using, NI's not traditionally enabled NAT (it's not a common use-case to need port-forwarding or masquerading). You can double-check this by checking the configuration that the kernel exposes (zcat /proc/config.gz | grep NAT). That's the bit of the message that's asking "do you need insmod?", basically indicating that the kernel module is not inserted and cannot be when attempting to load that module.
I'm afraid that you'd need to rebuild the kernel that's appropriate for your OS image to enable the NAT module. I've put together some videos that work through doing just this sort of thing, specifically the second video Working with the Linux Kernel on NI LabVIEW RT targets - Exercise 2
Thank you very much for the detailed answer. You are correct in assuming my goal and I have checked the configuration to find out that indeed the NAT options are not set so I will look into your series and try to rebuild the kernel.