PaloAlto でのマルチホームの実現
プロバイダーのトラブルなどで回線が片方切れてもインターネット接続を維持できるようにマルチホームの構成をとりたい。(バックアップルートが切れたときは諦めます)
仮想ルータが 1つでもできますが、分けた方が制御が自由になります。
How to Configure ISP Redundancy and Load Balancing
まぁ、これのまるパクリ。アプリケーションを指定した pbf はできません。なぜならファース (tcp syn) トパケットの時点で PaloAlto はアプリケーションが分からないため、ポリシーにマッチさせようがありません。
Getting Started: Policy Based Forwarding
これの最初にあるように、メトリックでバックアップルートを作成することもできます。(フロスタ) これで、お互いをバックアップルートにすることもできます。(が、今回はやらない)
PBF の注意としては PaloAlto 自身発のトラフィックは曲がりません。
Policy-based forwarding doesn't work for traffic sourced from the Palo Alto Networks firewall
これは一般的なルーターの PBR も同様です。
ネットワークの構成
自宅の中に作ったのですこしややこしいですが、以下のような構成とした。
最初に、バックアップルートをデフォルトルートにしておきます。
機器 | バージョン |
---|---|
L3-SW | CML の x86_64_crb_linux_l2-adventerprisek9-ms.iol |
PPPoE-Server | VyOS 2025.09.17-0018-rolling |
RT_MAIN | VyOS 2025.09.17-0018-rolling |
PaloAlto | PAN-OS 11.1.6-h7 |
※EVE-NG 上で作成しています
PaloAlto の初期設定
管理ポートほか
- タイムゾーン、ロケール
- ホスト名、ドメイン
- 管理ポートのアドレス (ルーティングさせないためデフォルトルートを自分に向ける)
- DNS, NTP
- 検証用なのでテレメトリを停止
CLI も載せておきます。
オペレーションモードから configure でコンフィグレーションモードになって投入しする。
set deviceconfig system timezone Asia/Tokyo
set deviceconfig system locale ja
set deviceconfig system hostname fw01
set deviceconfig system domain my.home
set deviceconfig system type static
set deviceconfig system ip-address 192.168.0.99
set deviceconfig system netmask 255.255.255.0
set deviceconfig system default-gateway 192.168.0.99
set deviceconfig system permitted-ip 192.168.0.0/24 description manage-LAN
set deviceconfig system ipv6-enable no
set deviceconfig system dns-setting servers primary 192.168.0.252
set deviceconfig system ntp-servers primary-ntp-server ntp-server-address 192.168.0.251
set deviceconfig system ntp-servers primary-ntp-server authentication-type none
set deviceconfig system ntp-servers secondary-ntp-server ntp-server-address 192.168.0.252
set deviceconfig system ntp-servers secondary-ntp-server authentication-type none
set deviceconfig system device-telemetry device-health-performance no
set deviceconfig system device-telemetry product-usage no
set deviceconfig system device-telemetry threat-prevention no
set deviceconfig system device-telemetry region jp
ゾーンを作成
- trust : LAN 側
- untrust-1 : メイン回線
- untrust-2 : バックアップ回線
名前を書いて、タイプを L3 にします。(他はそのままで構いません。)
キャプチャしたタイミングが遅く、インターフェース名や、ゾーンプロテクションが載っていますがここでは指定しない。
ゾーンの色分け
見分けやすいようにゾーンに色を付ける
左下の「追加」をクリックすると以下のウィンドウが出てくる。
名前とカラーをプルダウンから選択する。
set zone trust network layer3
set zone untrust-1 network layer3
set zone untrust-2 network layer3
set tag trust color color17
set tag untrust-1 color color6
set tag untrust-2 color color21
仮想ルータの作成
default ルーターだけなので、構成に合わせて RT-1st と RT-2nd にする (名前を入力するだけ。設定はあとで)
delete network virtual-router default
set network virtual-router RT-1st
set network virtual-router RT-2nd
インターフェース (仮想ルータ, ゾーン)
- eth1/1 : 100.64.10.2/24 (RT-1st, untrust-1)
- eth1/2 : PPPoE (RT-2nd, untrust-2)
- eth1/4 : 172.16.0.254/24 (RT-2nd, trust)
untrust-N は管理プロファイルで ping のみ許可。
trust は ping, ssh, https, 使わないだろうけども snmp にもチェックをつけてみた。(ping 以外は管理インターフェースでやった方が良い)
set network profiles interface-management-profile ping ping yes
set network profiles interface-management-profile manage https yes
set network profiles interface-management-profile manage ssh yes
set network profiles interface-management-profile manage snmp yes
set network profiles interface-management-profile manage ping yes
set network interface ethernet ethernet1/1 layer3 ip 100.64.10.2/24
set network interface ethernet ethernet1/1 layer3 interface-management-profile ping
set network interface ethernet ethernet1/2 layer3 pppoe username user02
set network interface ethernet ethernet1/2 layer3 pppoe password pass02
set network interface ethernet ethernet1/2 layer3 pppoe authentication auto
set network interface ethernet ethernet1/2 layer3 interface-management-profile ping
set network interface ethernet ethernet1/4 layer3 ip 172.16.0.254/24
set network interface ethernet ethernet1/4 layer3 interface-management-profile manage
set network interface ethernet ethernet1/1 layer3 ndp-proxy enabled no
set network interface ethernet ethernet1/2 layer3 ndp-proxy enabled no
set network interface ethernet ethernet1/4 layer3 ndp-proxy enabled no
set zone trust network layer3 ethernet1/4
set zone untrust-1 network layer3 ethernet1/1
set zone untrust-2 network layer3 ethernet1/2
set network virtual-router RT-1st interface ethernet1/1
set network virtual-router RT-2nd interface [ ethernet1/2 ethernet1/4 ]
set import network interface [ ethernet1/1 ethernet1/2 ethernet1/4 ]
set network lldp enable yes
set network interface ethernet ethernet1/1 layer3 lldp enable yes
set network interface ethernet ethernet1/2 layer3 lldp enable yes
set network interface ethernet ethernet1/4 layer3 lldp enable yes
ndp-proxy enabled no : IPv6 を無効化
必要があれば PPPoE のアクセスコンセントレーターを指定
set network interface ethernet ethernet1/2 layer3 pppoe access-concentrator VyOS-PPPoE
仮想ルータ (ルーティング)
default route は上位のルーター、LAN 側へは 172.16.0.0/12 とする。
172.16.0.0/12 に pppoe クライアントのアドレスが範囲に含まれるが、通信する必要はないので無視する。
RT-1st (メイン回線側)
default : next-hop に上位のルーター
LAN 側 (172.16/12): next-vr にRT-2nd
RT-2nd (バックアップ回線側)
default : PPPoE で自動設定
LAN 側 (172.16/12): next-hop に 172.16.0.1
set network virtual-router RT-1st routing-table ip static-route default nexthop ip-address 100.64.0.1
set network virtual-router RT-1st routing-table ip static-route default interface ethernet1/1
set network virtual-router RT-1st routing-table ip static-route default destination 0.0.0.0/0
set network virtual-router RT-1st routing-table ip static-route NET_172.16 nexthop next-vr RT-2nd
set network virtual-router RT-1st routing-table ip static-route NET_172.16 destination 172.16.0.0/12
set network virtual-router RT-2nd routing-table ip static-route NET_172.16 nexthop ip-address 172.16.0.1
set network virtual-router RT-2nd routing-table ip static-route NET_172.16 interface ethernet1/4
set network virtual-router RT-2nd routing-table ip static-route NET_172.16 destination 172.16.0.0/12
セキュリティーポリシー
trust から untrust-N はすべて許可
宛先ゾーン : untrust-1, untrust-2 両方
サービス (ポート番号)、EDL・URL カテゴリフィルタ : すべて
アクション : Allow
プロファイル (UTM,アンチウィルス,アンチスパイウェア, WildFire...) : なし
ログ設定 : セッション終了時にログ (これがないと monitor でトラフィックログが見えない)
設定後の絵
set rulebase security rules open to [ untrust-1 untrust-2 ]
set rulebase security rules open from trust
set rulebase security rules open source any
set rulebase security rules open destination any
set rulebase security rules open source-user any
set rulebase security rules open category any
set rulebase security rules open application any
set rulebase security rules open service any
set rulebase security rules open action allow
set rulebase security rules open log-end yes
intrazone-default と interzone-default のログを取得する。
intrazone-default : 同じゾーン内の通信を許可する
interzone-default : 異なるゾーン間の通信を拒否する (暗黙の deny 的なもの)
最初からあるこの下の 2つのポリシーはデフォルトでログを採取しないので、ログを取得するよう変更する。
Overriding or Reverting a Security Policy Rule
ゾーン内ルールとゾーン間ルール
先ず intrazone-default
の行を選択し、下部の「オーバーライド」をクリック
「セッション終了時にログ」にチェックを入れて「OK」
interzone-default
も同様に選択して「オーバーライド」、「セッション終了時にログ」にチェックを入れる
set rulebase default-security-rules rules intrazone-default action allow
set rulebase default-security-rules rules intrazone-default log-start no
set rulebase default-security-rules rules intrazone-default log-end yes
set rulebase default-security-rules rules interzone-default action deny
set rulebase default-security-rules rules interzone-default log-start no
set rulebase default-security-rules rules interzone-default log-end yes
NATポリシー
untrust-1, untrust-2 の両方を作成
送信元、宛先ゾーン、宛先インターフェースを指定
untrust-2 用には 宛先ゾーン : untrust-2, 宛先インターフェース e1/2 とする
src NAT なので、src アドレスをインターフェースアドレスに変換する
untrust-2 も同様に設定し、src アドレスは PPPoE なので指定しない
set rulebase nat rules to_untrust-1 from trust
set rulebase nat rules to_untrust-1 to untrust-1
set rulebase nat rules to_untrust-1 source any
set rulebase nat rules to_untrust-1 destination any
set rulebase nat rules to_untrust-1 service any
set rulebase nat rules to_untrust-1 to-interface ethernet1/1
set rulebase nat rules to_untrust-1 source-translation dynamic-ip-and-port interface-address interface ethernet1/1
set rulebase nat rules to_untrust-1 source-translation dynamic-ip-and-port interface-address ip 100.64.10.2/24
set rulebase nat rules to_untrust-2 from trust
set rulebase nat rules to_untrust-2 to untrust-2
set rulebase nat rules to_untrust-2 source any
set rulebase nat rules to_untrust-2 destination any
set rulebase nat rules to_untrust-2 service any
set rulebase nat rules to_untrust-2 to-interface ethernet1/2
set rulebase nat rules to_untrust-2 source-translation dynamic-ip-and-port interface-address interface ethernet1/2
緩いゾーンプロテクションを設定
ping を打ち続けると PaloAlto でフィルタされるので開けておく
set network profiles zone-protection-profile open flood tcp-syn enable no
set network profiles zone-protection-profile open flood udp enable no
set network profiles zone-protection-profile open flood icmp enable no
set network profiles zone-protection-profile open flood icmpv6 enable no
set network profiles zone-protection-profile open flood other-ip enable no
set network profiles zone-protection-profile open net-inspection rule
set network profiles zone-protection-profile open discard-tcp-syn-with-data no
set network profiles zone-protection-profile open discard-tcp-synack-with-data no
set network profiles zone-protection-profile open tcp-reject-non-syn no
set network profiles zone-protection-profile open asymmetric-path bypass
set zone trust network zone-protection-profile open
Commit
この設定で commit。
monitor トラフィック
中にある Windows からインターネットへアクセスしてトラフィックログを見る。
Windows からのパケットは e1/2, untrust-2 から出ていきます。
この時点では RT-1st はトラフィックに何の影響もない。
PBR でトラフィックを曲げる (正しくは「ポリシーベースフォワーディング」)
LAN (172.16.0.0/12) 以外のトラフィックを RT-1st の e1/1 から送出する。
RT-1st の上流が切れたら PBF を無効にする。
低速パス、高速パス、オフロードされたパケットの違い
によると、
CPU によってのみ処理され、オフロードされないタイプのトラフィックもあります。
- ネクストホップのないPBFセッション
とあるので指定できるのであれば next-hop の指定をすること
転送条件:宛先
LAN (172.16.0.0/12) 以外
下の「Negate」にチェックを忘れない。
転送先設定
先ほどの条件に一致すればインターフェース e1/1 から next-hop 100.64.10.1 へ送出。
192.168.0.254 への ping が通らなくなったらこの転送設定は無効。
チェック間隔は default (NETWORK > ネットワークプロファイル > モニター) 3秒間隔 5回
5回連続で失敗した時に PBF の経路を削除 (12~15秒で検知し切り替わり実施)
set rulebase pbf rules default-route from zone trust
set rulebase pbf rules default-route source any
set rulebase pbf rules default-route destination 172.16.0.0/12
set rulebase pbf rules default-route negate-destination yes
set rulebase pbf rules default-route application any
set rulebase pbf rules default-route service any
set rulebase pbf rules default-route action forward egress-interface ethernet1/1
set rulebase pbf rules default-route action forward nexthop ip-address 100.64.10.1
set rulebase pbf rules default-route action forward monitor profile default
set rulebase pbf rules default-route action forward monitor ip-address 192.168.0.254
モニター用の static route を追加
192.168.0.254 への ping は、このままだと RT-1st と RT-2nd のどちらから出ていくか分からないのでルーティングを追加する。(PaloAlto はポリシーにある転送先インターフェースからチェックしてくれるように思えますが、念のために)
static route を設定する前に commit して RT-1 でパケットをキャプチャすると、e1/1 から ping が出ているの。
vyos@RT-1:~$ sudo tcpdump -i eth1 icmp
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
03:00:27.473799 IP 100.64.10.2 > 192.168.0.254: ICMP echo request, id 1, seq 55, length 64
03:00:27.474681 IP 192.168.0.254 > 100.64.10.2: ICMP echo reply, id 1, seq 55, length 64
03:00:30.473589 IP 100.64.10.2 > 192.168.0.254: ICMP echo request, id 1, seq 56, length 64
03:00:30.474459 IP 192.168.0.254 > 100.64.10.2: ICMP echo reply, id 1, seq 56, length 64
03:00:33.473360 IP 100.64.10.2 > 192.168.0.254: ICMP echo request, id 1, seq 57, length 64
03:00:33.474314 IP 192.168.0.254 > 100.64.10.2: ICMP echo reply, id 1, seq 57, length 64
03:00:36.475788 IP 100.64.10.2 > 192.168.0.254: ICMP echo request, id 1, seq 58, length 64
03:00:36.476689 IP 192.168.0.254 > 100.64.10.2: ICMP echo reply, id 1, seq 58, length 64
03:00:39.473850 IP 100.64.10.2 > 192.168.0.254: ICMP echo request, id 1, seq 59, length 64
03:00:39.474720 IP 192.168.0.254 > 100.64.10.2: ICMP echo reply, id 1, seq 59, length 64
RT-2nd に 192.168.0.254 のルーティングを追加
set network virtual-router RT-2nd routing-table ip static-route monitor-route-1 nexthop next-vr RT-1st
set network virtual-router RT-2nd routing-table ip static-route monitor-route-1 destination 192.168.0.254/32
テスト (RT-1st 側を切って、バックアップルートが有効になるか)
RT-1 (メイン回線のルータ) で
set interfaces ethernet eth0 disable
,'commit'
delete interfaces ethernet eth0 disable
,'commit'
を実施
中の Windows から traceroute 的な
C:\Users\abc123\Desktop>MultiRoute.exe 192.168.10.254
Starting multiroute to 192.168.10.254 with max TTL 7
Press Ctrl+C to stop
03:12:57.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:12:58.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:12:59.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:13:00.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
---------- このあたりで disable
03:13:01.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:02.559|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:03.560|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:04.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:05.560|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:06.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:07.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:08.560|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:09.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:10.545|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:11.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:12.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:13.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:14.560|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:15.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:16.559|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:17.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:18.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:19.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:20.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:21.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:22.559|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:23.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:24.560|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:25.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:26.544|172.16.1.1 |172.16.0.254 |* |* |* |* |* |
03:13:27.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:28.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:29.560|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:30.559|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
---------- このあたりで delete disable
03:13:31.559|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |* |192.168.10.254 |192.168.10.254 |
03:13:32.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:33.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:34.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:35.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |* |
03:13:36.560|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:37.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:38.560|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:39.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:40.545|172.16.1.1 |172.16.0.254 |100.64.0.0 |* |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:41.544|172.16.1.1 |172.16.0.254 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |192.168.10.254 |
03:13:42.561|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:13:43.559|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:13:44.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:13:45.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |* |
03:13:46.544|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:13:47.560|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:14:01.071|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:14:01.545|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
03:14:02.559|172.16.1.1 |172.16.0.254 |100.64.10.1 |100.64.0.0 |192.168.0.254 |192.168.10.254 |192.168.10.254 |
Multiroute stopped.
C:\Users\abc123\Desktop>
メインルートが切れてから 26秒、戻りに 12秒 (セッション管理されているので、戻りの時間は「回線が切り替わり」かつ「セッションが新しくなった」時の時刻)
何故か RT-1 (メイン回線のルータ) の eth0 を切ったのに、eth1 からも応答が無くなっている???
通常は PBF が優先される。
回線の切断を検知すると PBF が無効になり static route に従って転送される。
自身が送信するパケットには PBF は効かない
トラフィックログを見ると自身 172.16.0.254 が送信したパケットは PBR が効かず RT-2nd のデフォルトルート (PPPoE で受け取る) からパケットが送信される。