小编Dav*_* M.的帖子

使用 nftables 进行端口转发和 NAT

我有一个 OpenWRT 网关(自建 19.07,内核 4.14.156),它位于我的专用网络前面的公共 IP 地址上。我正在使用 nftables(不是iptables)。

我想在公共地址上公开一个非标准端口,并将其转发到网关后面机器上的标准端口。我认为这曾经被称为端口转发:看起来您的网关机器正在提供,例如,http 服务,但它实际上是位于私有地址的网关后面的机器。

这是我的 nftables 配置。出于这些目的,我的“标准服务”在端口 1234 上,我希望允许公众在网关:4321 上访问它。

#!/usr/sbin/nft -ef
# 
# nftables configuration for my gateway
#

flush ruleset

table raw {
        chain prerouting {
                type filter hook prerouting priority -300;
                tcp dport 4321 tcp dport set 1234 log prefix "raw " notrack;
        }
}

table ip filter {
        chain output {
                type filter hook output priority 100; policy accept;
                tcp dport { 1234, 4321 } log prefix "output …
Run Code Online (Sandbox Code Playgroud)

firewall nat nftables

3
推荐指数
1
解决办法
5426
查看次数

标签 统计

firewall ×1

nat ×1

nftables ×1