[Server] Port forwarding (virtual server)

Nale Raphael
3 min readDec 19, 2017

--

本文以Asus wireless AC1750 router為例
當伺服器的ip不是一個直接的對外ip,而是由router分配的情況時,你會需要透過port forwarding讓外界進來的連線轉到伺服器開啟的服務port上。

開啟瀏覽器,登入router的設定頁面(以本機為例,登入頁面是router.asus.com)
點選左側`進階設定`,選擇上方`虛擬伺服器`分頁
在下方列表設定你要轉發的port

It’s a new feature Asus forgot to add to the changelog. It lets you specify a source IP that will be allowed to use the port forward. It allows you, for example, to setup a port foward to a computer’s Remote Desktop, and allowing only connections coming from your office’s IP to be forwarded.

Leave that field empty for the original “any source IP” behaviour.

  • 通訊埠範圍:
    設定成單一數值或一個範圍都可以,只是要對應到後面的本地通訊埠的數量
  • 本地ip:
    即你要轉發到某台電腦的ip (可以在該台電腦用ifconfig查詢其被分配到ip)
  • 本地通訊埠:
    該台電腦服務所開啟的port (可用nmap查詢該台電腦某項服務的使用的port)

以一台架有apache server (port: 80)的電腦來說,假設其ip為192.168.1.110,而整體的對外ip為211.72.200.161,這時若要讓外界透過211.72.200.161:1337去連到該台電腦的port: 80的設定如下

Source target: *.*.*.*
通訊埠範圍: 1337
本地ip: 192.168.1.110
本地通訊埠: 80

設定完成後,只要在瀏覽器上輸入 211.72.200.161:1337即可連到該台電腦

--

--