FRPの4台構成(複数ホストを経由してトンネルを繋ぐカスケード構成/マルチホップ構成)ですね!
今回の構成は、以下のような形に通信を数珠繋ぎ(チェイン)していくイメージです。
`[4: frpc]` ➔ `[3: frps / frpc]` ➔ `[2: frps / frpc]` ➔ `[1: frps]` (最終的なSOCKS5出口)
全てのホスト間を `websocket + TLS` で暗号化し、SNI(google.com)およびオレオレ証明書(SAN付き)を適用したTOML設定を作成しました。
この複雑な多段トンネルのパケットの流れやポートの繋がりを直感的に理解できるように、各ノードの役割と通信経路を視覚的に操作・確認できるシミュレーター(仕様)を用意しました。設定ファイルと合わせて参考にしてください。
---
### 通信ポートと役割の前提(例)
* **1号機 (最上流):** IP `192.168.1.1` / 待ち受け: `4545`
* **2号機:** IP `192.168.1.2` / 待ち受け: `4546`
* **3号機:** IP `192.168.1.3` / 待ち受け: `4547`
* **4号機 (最下流/あなた):** 待ち受けは不要(クライアントのみ)
---
### 1号機:`frps.toml` (最上流サーバー)
2号機からの接続をポート `4545` で受け付け、ご指定通りリモートポート `1080` にSOCKS5を露出させます。
```toml
bindPort = 4545
transport.tls.force = true
transport.tls.certFile = "./frp.crt"
transport.tls.keyFile = "./frp.key"
```
---
### 2号機:`frps.toml` & `frpc.toml` (中間ノード A)
1号機へ接続しつつ、3号機からの接続を待つ役割です。
**2号機の `frpc.toml` (1号機へ接続する側)**
```toml
serverAddr = "192.168.1.1" # 1号機のIP
serverPort = 4545
transport.protocol = "websocket"
transport.tls.enable = true
transport.tls.serverName = "google.com"
transport.tls.trustedCaFile = "./frp.crt"
[[proxies]]
name = "to_node1"
type = "tcp"
remotePort = 1080 # ご指定通り1号機側の公開ポートは1080
[proxies.plugin]
type = "socks5" # 最終端のSOCKS5プラグイン
```
**2号機の `frps.toml` (3号機から接続される側)**
```toml
bindPort = 4546 # 3号機を待ち受けるポート
transport.tls.force = true
transport.tls.certFile = "./frp.crt"
transport.tls.keyFile = "./frp.key"
```
---
### 3号機:`frps.toml` & `frpc.toml` (中間ノード B)
2号機へ接続しつつ、4号機からの接続を待ちます。
**3号機の `frpc.toml` (2号機へ接続する側)**
```toml
serverAddr = "192.168.1.2" # 2号機のIP
serverPort = 4546
transport.protocol = "websocket"
transport.tls.enable = true
transport.tls.serverName = "google.com"
transport.tls.trustedCaFile = "./frp.crt"
[[proxies]]
name = "to_node2"
type = "tcp"
remotePort = 1081 # 2号機側で開けるポート(例)
[proxies.plugin]
type = "socks5"
```
**3号機の `frps.toml` (4号機から接続される側)**
```toml
bindPort = 4547 # 4号機を待ち受けるポート
transport.tls.force = true
transport.tls.certFile = "./frp.crt"
transport.tls.keyFile = "./frp.key"
```
---
### 4号機:`frpc.toml` (最下流クライアント)
3号機へ接続を開始する起点となるクライアントです。
```toml
serverAddr = "192.168.1.3" # 3号機のIP
serverPort = 4547
transport.protocol = "websocket"
transport.tls.enable = true
transport.tls.serverName = "google.com"
transport.tls.trustedCaFile = "./frp.crt"
[[proxies]]
name = "to_node3"
type = "tcp"
remotePort = 1082 # 3号機側で開けるポート(例)
[proxies.plugin]
type = "socks5"
```
---
### 🛠️ 4台構成マルチホップ・シミュレーター
各ホスト間のパケットの流れ、証明書の検証、ポートフォワーディングの依存関係を視覚的に学べるインタラクティブな図を作成しました。どのホストがどのポートで待っているかを切り替えてシミュレーションできます。