From: "Kamil Jońca" <kjonca@op.pl>
To: netfilter@vger.kernel.org
Subject: Re: using sets as snat targets in nat tables
Date: Mon, 25 Apr 2022 19:54:37 +0200 [thread overview]
Message-ID: <875ymxkq02.fsf@alfa.kjonca> (raw)
In-Reply-To: <CAF358wSzMHJQahvxXLofKF-bMc-xev10xjPbGCcZSpie1BMQhQ@mail.gmail.com> (Maximiliano Estudies's message of "Mon, 25 Apr 2022 17:08:08 +0200")
Maximiliano Estudies <maxiestudies@gmail.com> writes:
> Hi,
> I'm trying to use a set as a snat target and failing. This is my config:
>
> table ip nat { # handle 73
> set dc-cidr-nat { # handle 3
> type ipv4_addr
> flags interval
> elements = { <internal-network> }
> }
>
> set external-ip-net { # handle 4
> type ipv4_addr
> elements = { <public-ip> }
> }
>
> chain POSTROUTING { # handle 1
> type nat hook postrouting priority srcnat; policy accept;
> ip saddr @dc-cidr-nat oif "enp1s0f0" snat to @external-ip-net comment
> "internet gateway" # handle 7
> }
>
> This fails wtth "Error: syntax error, unexpected string, expecting ll
> or nh or th". Using an anonymous set doesn't work either, but hard
> coding the <external-ip> does. I can't find any hint in the wiki if
> sets are allowed in this context.
Set can have 0 elements or more than 1. What your poor computer should
do in these cases? where it should snat to?
IMO you shoould use kind of map:
table ip nat {
map dhcp_snat {
type iface_index : ipv4_addr
}
set dhcp_ifaces {
type iface_index
}
chain POSTROUTING {
type nat hook postrouting priority srcnat; policy accept;
oif @dhcp_ifaces rt ipsec missing snat to oif map @dhcp_snat
}
}
here, when dhcp script put
{ "wlan0" } into dhcp_ifaces
and
{ "wlan0" : 192.168.1.1 } into dhcp_snat
traffic outgoing via wlan0 will be snat-ed to 192.168.1.1
KJ
--
http://wolnelektury.pl/wesprzyj/teraz/
next prev parent reply other threads:[~2022-04-25 17:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-25 15:08 using sets as snat targets in nat tables Maximiliano Estudies
2022-04-25 17:54 ` Kamil Jońca [this message]
2022-04-26 7:38 ` Maximiliano Estudies
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=875ymxkq02.fsf@alfa.kjonca \
--to=kjonca@op.pl \
--cc=netfilter@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.