User Tools

Site Tools


сервис_nat

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
сервис_nat [2022/07/26 06:27]
val [Debian/Ubuntu (iptables)]
сервис_nat [2024/04/23 13:57]
val [nftables]
Line 63: Line 63:
 # netfilter-persistent save # netfilter-persistent save
 </​code>​ </​code>​
 +
 +==== nftables ====
 +
 +  * [[https://​wiki.nftables.org/​wiki-nftables/​index.php/​Performing_Network_Address_Translation_(NAT)|Performing Network Address Translation (NAT)]]
 +  * https://​wiki.debian.org/​nftables
 +
 +<​code>​
 +gate### apt install nftables
 +
 +gate# nft add table nat
 +
 +gate# nft 'add chain nat postrouting { type nat hook postrouting priority 100 ; }'
 +
 +gate# nft add rule nat postrouting ip saddr 192.168.X.0/​24 oif eth1 snat to 172.16.1.X
 +gate# nft add rule nat postrouting ip saddr 192.168.100+X.0/​24 oif eth1 snat to 172.16.1.X
 +
 +gate# nft list ruleset
 +
 +gate# nft flush ruleset
 +
 +gate# systemctl enable nftables.service --now
 +
 +gate# cat /​etc/​nftables.conf
 +</​code><​code>​
 +...
 +table ip nat {
 +        chain postrouting {
 +                type nat hook postrouting priority srcnat; policy accept;
 +                ip saddr 192.168.100+X.0/​24 oif "​eth1"​ snat to 172.16.1.X
 +        }
 +}
 +</​code><​code>​
 +gate# systemctl reload nftables.service
 +</​code>​
 +
 ==== CentOS (firewalld) ==== ==== CentOS (firewalld) ====
  
сервис_nat.txt · Last modified: 2024/05/06 16:17 by val