Re: iptables to nftables question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I am trying to set up a test environment with nftables and I'm stuck. I
> have included the iptables equivalent to what I'm trying to do in the
> hopes someone can point me in the right direction.
>
> Here is the iptables rule I'm trying to recreate in nftables:
>
> iptables -A PREROUTING -i eth0 -s 138.68.14.134 -p tcp -m tcp --dport\
> 15150 -j DNAT --to-destination 192.168.0.2:15150

I'm struggling with nft myself but I _think_ you want to do something like this:

Create a nat table:

nft add table nat
nft add chain nat prerouting { type nat hook prerouting priority 0 ; }
nft add chain nat postrouting { type nat hook postrouting priority 100; }

Add a rule to match your prerouting requirements:

nft add rule nat prerouting iif eth0 tcp dport 15150 dnat 192.168.0.2
..or..
nft add rule nat prerouting ip saddr 138.68.14.134 tcp dport 15150
dnat 192.168.0.2

Add a couple rules for return traffic:

nft add rule nat postrouting masquerade
nft add rule nat postrouting ip saddr 192.168.0.2 oif eth0

Hope that helps/gets you closer!
-Derek



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux