このチュートリアルでは、Yamaha RTX840 および RTX1300 シリーズルーターを、IPsec トンネル経由で Cloudflare WAN(旧称 Magic WAN)に接続する方法を説明します。
次のファームウェアバージョンの Yamaha RTX840 および RTX1300 シリーズで、これらの設定を検証しました。
- RTX840 series: 23.02.02
- RTX1300 series: 23.00.17
Cloudflare ダッシュボードから、Cloudflare アカウントに IPsec トンネルと静的ルートを追加します。
作業の前に、アカウントに割り当てられた anycast IP があることを確認します。Cloudflare ダッシュボードの Address Space > Leased IPs ↗ で確認できます。
-
トンネルを追加する の手順に従い、必要な IPsec トンネルを作成します。IPsec トンネルを作成するときは、次の設定を必ず指定します。
- Tunnel name: トンネル名を入力します。この例では
RTX840-vpn01です。 - Interface address: IPsec トンネルの Cloudflare 側の内部トンネル IP を入力します。この例では
172.30.223.2/31です。 - Customer endpoint: RTX ルーターの WAN IP アドレスを入力します。この例では
194.xx.xx.xxです。ISP からインターネット回線向けに割り当てられた固定の公開 IPv4 アドレスです。 - Cloudflare endpoint: アカウントに割り当てられた Cloudflare anycast IP アドレスの 1 つです。
- Health check rate: Medium。
- Health check type: Request。
- Health check direction: Bidirectional。
- Health check target: Default。
- Pre-shared key: Use my own pre-shared key を選び、自分で用意した安全なキーを貼り付けます。
- Replay protection: 無効のままにするため、ボックスはチェックしません。
- Tunnel name: トンネル名を入力します。この例では
-
トンネルを作成すると、Cloudflare ダッシュボードにアカウントのトンネル一覧が表示されます。作成したばかりの IPsec トンネルを選び、次の設定を確認します。
- FQDN ID: この ID をコピーして保存します。RTX ルーターで IPsec トンネルを設定するときに使います。
IPsec トンネル経由で到達するネットワークには、静的ルートが必要です。この例では、ネットワークは 172.16.2.0/24 の 1 つです。
静的ルートを設定する の手順に従い、静的ルートを作成します(ここにない設定はデフォルトのままで構いません)。
- Description:
RTX840-lan01 - Prefix:
172.16.2.0/24 - Tunnel/Next hop: RTX840-vpn01
これらの設定は CLI で行います。
ip route default gateway tunnel 1
ip route <Cloudflare Anycast IP> gateway <ISP provided Gateway IP>
ip route < ISP's DNS server IP > gateway <ISP provided Gateway IP>ip lan1 address 172.16.2.254/24ip lan2 address 194.xx.xx.xx/29
ip lan2 nat descriptor 1000tunnel select 1
ipsec tunnel 1
ipsec sa policy 1 1 esp aes256-cbc sha256-hmac anti-replay-check=off
ipsec ike version 1 2
ipsec ike duration ipsec-sa 1 3600
ipsec ike duration isakmp-sa 1 28800
ipsec ike encryption 1 aes256-cbc
ipsec ike group 1 modp2048
ipsec ike hash 1 sha256
ipsec ike keepalive log 1 off
ipsec ike keepalive use 1 on rfc4306 10 6
ipsec ike local address 1 194.xx.xx.xx
ipsec ike log 1 key-info message-info payload-info
ipsec ike local name 1 <Cloudflare Magic IPsec Tunnel FQDN IP> fqdn
ipsec ike pfs 1 on
ipsec ike proposal-limitation 1 on
ipsec ike pre-shared-key 1 text <Pre-shared key>
ipsec ike remote address 1 <Cloudflare Anycast IP>
ipsec ike remote name 1 <Cloudflare Anycast IP> ipv4-addr
ip tunnel address 172.30.223.3/31
ip tunnel tcp mss limit auto
tunnel enable 1
ipsec auto refresh on
! Note: 172.30.223.3/31 is internal tunnel IP on the RTX side.nat descriptor type 1000 masquerade
nat descriptor address outer 1000 primary
nat descriptor masquerade static 1000 1 194.xx.xx.xx udp 500
nat descriptor masquerade static 1000 2 194.xx.xx.xx espdhcp service server
dhcp server rfc2131 compliant except remain-silent
dhcp scope 1 172.16.2.2-172.16.2.191/24dns host lan1
dns server select 1 <ISP's DNS server IP> any .
dns private address spoof onYamaha RTX ルーターの CLI で、show ipsec sa と show status tunnel を実行し、IPsec VPN の状態を確認できます。
Total: isakmp:1 send:1 recv:1
sa sgw isakmp connection dir life[s] remote-id
------------------------------------------------------------------------------------------
1 1 - ike - 27384 (Cloudflare Anycast IP)
2 1 1 tun[0001]esp send 2185 (Cloudflare Anycast IP)
3 1 1 tun[0001]esp recv 2185 (Cloudflare Anycast IP)TUNNEL[1]:
Description:
Interface type: IPsec
Current status is Online.
from 2025/12/08 13:14:20.
20 minutes 56 seconds connection.
Maximum Transmission Unit(MTU):
IPv4: 1280 octets
IPv6: 1280 octets
Received: (IPv4) 171847 packets [58823472 octets]
(IPv6) 0 packet [0 octet]
Transmitted: (IPv4) 154224 packets [19191955 octets]
(IPv6) 0 packet [0 octet]
IKE keepalive:
[Type]: rfc4306
[Status]: OK
[Next send]: 1 sec after