hain=srcnat => 離開路由器 chain=dstnat => 進入路由器

action=src-nat => 將來源地址偽裝成指定地址 action=dst-nat => 將目地地址偽裝成指定地址 action=masquerade => 將來源地址偽裝成本地地址(路由器) action=redirect => 將目的地址偽裝成本地地址(路由器)

src-address => 來源地址 dst-address => 目地地址 in-interface => 來源端口 out-interface => 目地端口

所以... chain=srcnat action=masquerade src-address=192.168.1.0/24 即為:將來源192.168.1.0/24連外(離開路由器)的ip,偽裝成路由器(本地)地址。

但這樣列會有很大問題,若路由器建了另一個網段192.168.2.0/24 因上面的規則命192.168.1.0/24連出都要先偽裝成路由器地址, 這樣192.168.2.0/24查連線進來的地址只會有路由器的地址,而非192.168.1.x的地址。

所以偽裝應該這樣做才算是佳: 方案1: chain=srcnat action=masquerade src-address=192.168.1.0/24 dst-address=!192.168.2.0/24 將目地192.168.2.0/24設為例外,這樣連接這個網段時就不會再偽裝成路由器ip。

方案2: chain=srcnat action=masquerade src-address=192.168.1.0/24 out-interface=pppoe-out1 當目地出口為pppoe-out1(網際網路),才將來源192.168.1.0/24的ip偽裝成路由器地址。

以上是對來源地址進行偽裝(action=src-nat); 反推對目的地址(action=dst-nat)進行偽裝,相信也很容易進行思考。

/interface pppoe-client disable pppoe-client-WAN :delay 2s /interface pppoe-client enable pppoe-client-WAN

sudo service cron reload

Ubuntu 22.04 and higher resolvectl flush-caches

雜項

API 測試

Open AI

LLaMA