Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Steve Horsley <steve.horsley@gmail.com>
Cc: netfilter@vger.kernel.org
Subject: Re: nftables segv while trying to use nat redirection with map
Date: Sun, 18 Oct 2015 20:00:53 +0200	[thread overview]
Message-ID: <20151018180053.GA1826@salvia> (raw)
In-Reply-To: <56239149.2010805@gmail.com>

On Sun, Oct 18, 2015 at 01:32:09PM +0100, Steve Horsley wrote:
> I would like to do host redirection using nftables, and using
> maps for efficient host address lookup (thousands of entries).
> As a first step, I tried just natting the output from my laptop
> but the real use will be on the prerouting chain:
> 172.16.0.1 -> 8.8.8.8.
> The following works as intended:
>     nft add table nat
>     nft add chain nat output { type nat hook output priority 0 \; }
>     nft add rule nat output ip daddr 172.16.1.1 dnat 8.8.8.8
>     ping 172.16.1.1
> 
> But I can't get it to work using maps - this causes a segmentation error:
>     nft flush ruleset
>     nft add table nat
>     nft add chain nat output { type nat hook output priority 0 \; }
>     nft add rule ip nat output dnat ip daddr map { 172.16.1.1 : 8.8.8.8 }
>     nft list ruleset
> 
> I don't know if I just have the wrong syntax, if it's a bug in
> nft, or if it's just something I shouldn't be trying to do in the
> first place. I am using nftables 0.4 (ubuntu 15.10 beta) but had
> the same result on ubuntu 15.04.

This works here on nftables 0.5, I can load both this:

#!/usr/sbin/nft

flush ruleset
add table nat
add chain nat output { type nat hook output priority 0 ; }
add rule ip nat output dnat ip daddr map { 172.16.1.1 : 8.8.8.8 }

and this:

flush ruleset
table ip nat {
        chain output {
                type nat hook output priority 0; policy accept;
                dnat ip daddr map { 172.16.1.1 : 8.8.8.8} 
        }
}

  reply	other threads:[~2015-10-18 18:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-18 12:32 nftables segv while trying to use nat redirection with map Steve Horsley
2015-10-18 18:00 ` Pablo Neira Ayuso [this message]
2015-11-02 23:27   ` Steve Horsley
2015-11-03 12:08     ` Pablo Neira Ayuso
2015-11-03 18:24       ` Steve Horsley
2015-11-03 19:39         ` Arturo Borrero Gonzalez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151018180053.GA1826@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter@vger.kernel.org \
    --cc=steve.horsley@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox