2つの異なるサーバーと対話するようにWireGuardクライアントを構成するにはどうすればよいですか?

2つの異なるサーバーと対話するようにWireGuardクライアントを構成するにはどうすればよいですか?

無人WireGuardクライアントを冗長WireGuardサーバーで使用したいと思います。

物理:

  • 米国にプロバイダAがあるVPSにプライマリデータベースサーバーがあります。
  • ヨーロッパのプロバイダBのVPSにあるスレーブサーバーで連続レプリケーションを実行しています。
  • 自宅のオフィスのWiFi LANに、レプリケーションスレーブとして実行されるバックアップデータベースサーバーがあります。

ネットワーク:

  • 米国のプライマリデータベースサーバーは、WireGuardサーバーバージョン10.20を実行します。20.1.
  • ヨーロッパのスレーブデータベースサーバーはWireGuardサーバーのバージョン番号10.20を実行します。10.1.

私のホームオフィスのバックアップデータベースは、マスターリモートWireGuardサーバーまたはスレーブリモートWireGuardサーバーと対話するように正常に構成されました。個別に

米国経由で接続するには、自宅で次のことを行う人が必要です。

suda wg-quick down wgEUR; suda wg-quick up wgUSA;

ヨーロッパ経由で接続するには、自宅で次のことを行う人が必要です。

suda wg-quick down wgUSA; suda wg-quick up wgEUR;

しかし! !

重要なことは、私がどこにいても、WireGuardサーバーを介してホームオフィスコンピュータにSSH経由で接続できることです。そのうちの1つがダウンしても、もう1つは引き続き使用できます。

許可するように Home Office WireGuard クライアントでルーティングを構成する方法同時に2つのリモートWireGuardサーバーのサブネットからアクセスしますか?


設定

ヨーロッパ(37.xxx.xxx.139:34567): wg0.conf

[Interface]
Address = 10.20.10.1/24
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0  -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0  -j MASQUERAD
ListenPort = 34567
PrivateKey = MNf4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiVg=

[Peer]
PublicKey = durAZO/EtWQnqwnbadbadbadzDa9+klqUmqCT6VplWc=
AllowedIPs = 10.20.10.16/32

アメリカ (185.xxx.xxx.36:34567): wg0.conf

[Interface]
Address = 10.20.20.1/24
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERAD
ListenPort = 34567
PrivateKey = EGdxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxp2Q=

[Peer]
PublicKey = durAZO/EtWQnbadbadbadMkTzDa9+klqUmqCT6VplWc=
AllowedIPs = 10.20.20.16/32

クライアント wgEUR.conf:

[Interface]
### PrivateKey_of_the_Client
PrivateKey = EBmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaXlE=
### IP VPN for the Client
Address = 10.20.10.16/24
### DNS Server
DNS = 8.8.8.8, 8.8.4.4

[Peer]
###Public of the WireGuard VPN Server
PublicKey = pTm/tJwOWJ3QRwEcbadbadbadWx/BbCthbFa52M2uVE=

### IP and Port of the WireGuard VPN Server
##### Syntax: IP_of_the_server:Port
Endpoint = 37.xxx.xxx.139:34567

### Allow all traffic
AllowedIPs = 0.0.0.0/0

クライアントwgUSA.conf:

[Interface]
### PrivateKey_of_the_Client
PrivateKey = EBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxXlE=
### IP VPN for the Client
Address = 10.20.20.16/24
### DNS Server
DNS = 8.8.8.8, 8.8.4.4

[Peer]
###Public of the WireGuard VPN Server
PublicKey = f/H+1b/jkkXvbhYPEbadbadbadkKMBMgEW1IvmOeCEE=

### IP and Port of the WireGuard VPN Server
##### Syntax: IP_of_the_server:Port
Endpoint = 185.xxx.xxx.36:34567

### Allow all traffic
AllowedIPs = 0.0.0.0/0

ベストアンサー1

この VPN は匿名でインターネットにアクセスするのではなく、プライベート リソースにアクセスする方法です。だから分割トンネル使用すべき

クライアント側で交換してください。

AllowedIPs = 0.0.0.0/0

必須リソースのみ:データベースを実行しているサーバー。

お客様の場合wgEUR.conf:

AllowedIPs = 10.20.10.1/32

お客様の場合wgUSA.conf:

AllowedIPs = 10.20.20.1/32

これで、両方のトンネルを同時に開始できます。wg-quickパスはハイジャックされません(Table = autoこれはデフォルト設定で発生し、AllowedIPs0.0.0.0/0または::/0と表示されます)、2つのトンネルは互いに競合しません。クライアントの一般的なインターネットアクセスはトンネルを通過しません。これは確かに改善されました。データベースサーバーはなぜそのようなサービスを提供するのですか?

おすすめ記事