netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rubén Méndez Hernández" <rmendezh@ies-sabadell.cat>
To: netfilter@vger.kernel.org
Subject: Problems getting started with dnat and port forwarding
Date: Sun, 12 Nov 2023 18:31:58 +0100	[thread overview]
Message-ID: <CAHpzd2o47vs=yA28FzMMjYvYfU1iPsDM_9fopXrwk9pWfLcHnw@mail.gmail.com> (raw)

Dear netfilter team.
I'm starting with nftables and trying to set an ssh port forwarding
from my firewall IP 192.168.1.252 to my dmz IP 10.0.0.2. But I get
this error:
-------
nft -cf nft/test.nft
nft/test.nft:30:62-65: Error: ip or ip6 must be specified with address
for inet tables.
add rule inet nat prerouting iifname $int_ext tcp dport 2222 dnat to 10.0.0.2:22
                                                             ^^^^
-------

I let you a piece of my nftables script.
-------
table inet nat {
  chain prerouting { type nat hook prerouting priority -400; policy accept; }
  chain postrouting { type nat hook postrouting priority srcnat;
policy accept; }
}
#--------------PREROUTING-----------------
add rule inet nat prerouting iifname $int_ext tcp dport 2222 dnat to 10.0.0.2:22
#--------------FORWARD----------------- #
add rule inet filter FORWARD iifname $int_ext oifname $int_dmz ip
daddr 10.0.0.2/24 tcp dport 22 accept
add rule inet filter FORWARD iifname $int_dmz oifname $int_ext ip
saddr 10.0.0.2/24 tcp sport 22 accept
-------

Thank you for your time.

             reply	other threads:[~2023-11-12 17:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 17:31 Rubén Méndez Hernández [this message]
2023-11-13  2:36 ` Problems getting started with dnat and port forwarding Kerin Millar

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='CAHpzd2o47vs=yA28FzMMjYvYfU1iPsDM_9fopXrwk9pWfLcHnw@mail.gmail.com' \
    --to=rmendezh@ies-sabadell.cat \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).