netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* snat with dynamic ip address
@ 2024-02-29 10:10 Lars Noodén
  2024-02-29 10:19 ` seentr
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Noodén @ 2024-02-29 10:10 UTC (permalink / raw)
  To: Linux Netfilter Users List

I have the following table within a NFTables rule set, but the address
given below (192.168.1.213) is assigned via DHCP and will change from
time to time.   How should I rewrite that line to do SNAT using whatever
the current IPv4 address happens to be at the moment?

/Lars

table ip nat {
         chain postrouting {
                 type nat hook postrouting priority srcnat; policy accept;
                 ip saddr 172.16.3.0/24 oif "wlan0" snat to 192.168.1.213
         }
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: snat with dynamic ip address
  2024-02-29 10:10 snat with dynamic ip address Lars Noodén
@ 2024-02-29 10:19 ` seentr
  2024-02-29 10:29   ` Lars Noodén
  0 siblings, 1 reply; 3+ messages in thread
From: seentr @ 2024-02-29 10:19 UTC (permalink / raw)
  To: Lars Noodén; +Cc: Linux Netfilter Users List

Have you tried masquerade? Seems like it is what you are looking for.

2024-02-29T10:11:15Z Lars Noodén <lars.nooden@gmx.com>:

> I have the following table within a NFTables rule set, but the address
> given below (192.168.1.213) is assigned via DHCP and will change from
> time to time.   How should I rewrite that line to do SNAT using whatever
> the current IPv4 address happens to be at the moment?
> 
> /Lars
> 
> table ip nat {
>          chain postrouting {
>                  type nat hook postrouting priority srcnat; policy accept;
>                  ip saddr 172.16.3.0/24 oif "wlan0" snat to 192.168.1.213
>          }
> }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: snat with dynamic ip address
  2024-02-29 10:19 ` seentr
@ 2024-02-29 10:29   ` Lars Noodén
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Noodén @ 2024-02-29 10:29 UTC (permalink / raw)
  To: Linux Netfilter Users List

On 2/29/24 12:19, seentr@at.encryp.ch wrote:
> Have you tried masquerade? Seems like it is what you are looking for.

Thanks.  Masquerade was it.

/Lars

table ip nat {
         chain postrouting {
                 type nat hook postrouting priority srcnat; policy accept;
                 ip saddr 172.16.3.0/24 oifname "wlan0" masquerade;
         }
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-29 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 10:10 snat with dynamic ip address Lars Noodén
2024-02-29 10:19 ` seentr
2024-02-29 10:29   ` Lars Noodén

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 NNTP newsgroup(s).