とあるところでgre tunnelを使ってsource addressベースの経路制御をしなければならなくなった。
pfでroute-toを使う手もあるにはあったが、制御しくった時にかなり痛い思いをすることがわかっているので、物は試して。
これに関しては、最終的に1本の記事にするつもりなので、ここには簡単なメモ書きだけ。
+---ProxyB---+ Dest ---(Internet)---+------------+---(ISP)---Router---Source +---ProxyC---+
ifconfig_xn0="inet Src(A)/24" ifconfig_xn0_alias0="inet Src(B)/24" ifconfig_xn0_alias1="inet Src(C)/24"
if_gre_load="YES" net.fibs=4
cloned_interfaces="gre0 gre1" ifconfig_xn0="inet Addr(Global)/masklen" ifconfig_xn1="inet Src(Router)/masklen" ifconfig_gre0="inet tun(Router) tun(ProxyB) netmask 255.255.255.252 tunnel Addr(Global) Addr(ProxyB) mtu 1436 fib 1" ifconfig_gre1="inet tun(Router) tun(ProxyC) netmask 255.255.255.252 tunnel Addr(Global) Addr(ProxyC) mtu 1436 fib 1" route_0="-fib 0 default Addr(ISP)" route_1="-fib 1 default tun(ProxyB)" route_2="-fib 2 default tun(ProxyC)" static_routes="0 1 2"
...(snip)... nat pass on xn0 from Src(A) to any -> (xn0) nat pass on gre0 from Src(B) to any -> tun(ProxyB) nat pass on gre0 from Src(C) to any -> tun(ProxyC) ...(snip)... pass in from any to any rtable 0 pass in from Src(B) to any rtable 1 pass in from Src(C) to any rtable 2
Sourceにloginして、
で確認できるはず。
pass in from any to any rtable 0
を記載する場所に気をつけること