This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
сервис_nat [2024/04/08 16:37] val [nftables] |
сервис_nat [2024/04/23 14:00] val [nftables] |
||
---|---|---|---|
Line 70: | Line 70: | ||
<code> | <code> | ||
- | # apt install nftables | + | gate### apt install nftables |
- | ... | + | gate# man nft |
- | # nft add rule nat postrouting ip saddr 192.168.22.0/24 oif eth1 snat to 10.5.7.122 | + | |
- | # nft list ruleset | + | gate# nft add table nat |
- | # file /etc/nftables.conf | + | gate# nft 'add chain nat postrouting { type nat hook postrouting priority srcnat ; }' |
- | # systemctl enable nftables.service | + | 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> | </code> | ||