os:freebsd:gre
no way to compare when less than two revisions
差分
このページの2つのバージョン間の差分を表示します。
最新のリビジョン | |||
— | os:freebsd:gre [2020/01/28 19:01] – 作成 seirios | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== FreeBSDでgreを動かす ====== | ||
+ | 「21世紀になってもう20年経とうとするのに今頃greかよ!」と言われるかもしれないが、greを使わなければならなくなったので、記録を。 | ||
+ | |||
+ | 重要なのは、greは4層のプロトコルではなく、3層のプロトコルであるということ。Firewall関係の処理で引っかかりやすいので注意が必要。 | ||
+ | |||
+ | ===== 事前準備 ===== | ||
+ | 今回登場する各ノード(RouterやNat box)は全てFreeBSDを利用しているものとする。 | ||
+ | |||
+ | * GRE routerになるNodeは、最低限以下の設定を行うこと | ||
+ | * ''/ | ||
+ | * '' | ||
+ | * Nat Boxにおいては、以下のようになっていること | ||
+ | * '' | ||
+ | * NAT設定はpfを利用するものとする | ||
+ | * natdやipfwなどでもできるのかもしれないが、pfしか知らないのでpfを仮定する | ||
+ | |||
+ | ===== 一番簡単な構成 ===== | ||
+ | 最も簡単な構成は、greで接続するRouterがそれぞれGlobal Addressを持っている場合である。 | ||
+ | この場合、'' | ||
+ | |||
+ | * ネットワーク図 | ||
+ | <code - 図1> | ||
+ | +--- RtrA --- (Internet) --- RtrB ---+ | ||
+ | | ||
+ | ---+--- NetA NetB ---+--- | ||
+ | </ | ||
+ | |||
+ | * RtrA の Global Address を RtrA(G) / RtrB の Global Address を RtrB(G) | ||
+ | * RtrA の NetA 側 Address を RtrA(A) / RtrB の NetB 側 Address を RtrB(B) | ||
+ | |||
+ | <code - RtrA> | ||
+ | # ifconfig gre0 create | ||
+ | # ifconfig gre0 inet RtrA(A) RtrB(B) | ||
+ | # ifconfig gre0 tunnel RtrA(G) RtrB(G) | ||
+ | # route add -net NetB RtrB(B) | ||
+ | </ | ||
+ | |||
+ | <code - RtrB> | ||
+ | # ifconfig gre0 create | ||
+ | # ifconfig gre0 inet RtrB(B) RtrA(A) | ||
+ | # ifconfig gre0 tunnel RtrB(G) RtrA(G) | ||
+ | # route add -net NetA RtrA(A) | ||
+ | </ | ||
+ | |||
+ | これだけ設定すれば、Firewallなどで通信が遮断されていないかぎり、通信できるはず。 | ||
+ | |||
+ | ===== 簡単なNAT超えの場合 ===== | ||
+ | |||
+ | * ネットワーク図 | ||
+ | <code - 図2> | ||
+ | +--- RtrA --- (Internet) --- Nat --(NatNW)-- RtrB ---+ | ||
+ | | ||
+ | ---+--- NetA NetB ---+--- | ||
+ | |||
+ | </ | ||
+ | |||
+ | * RtrA の Global Address を RtrA(G) / Nat の Global Address を Nat(G) | ||
+ | * RtrA の NetA 側 Address を RtrA(A) / RtrB の NetB 側 Address を RtrB(B) | ||
+ | * Nat の RtrB 側 Address を Nat(B) , Interface を NatIF / RtrB の Nat 側 Address を RtrB(N) | ||
+ | |||
+ | <code - RtrA> | ||
+ | # ifconfig gre0 create | ||
+ | # ifconfig gre0 inet RtrA(A) RtrB(B) | ||
+ | # ifconfig gre0 tunnel RtrA(G) Nat(G) | ||
+ | # route add -net NetB RtrB(B) | ||
+ | </ | ||
+ | |||
+ | <code - RtrB> | ||
+ | # ifconfig gre0 create | ||
+ | # ifconfig gre0 inet RtrB(N) RtrA(A) | ||
+ | # ifconfig gre0 tunnel RtrB(N) RtrA(G) | ||
+ | # route add -net NetA RtrA(A) | ||
+ | </ | ||
+ | |||
+ | <code - Nat> | ||
+ | # 以下 pf.conf の当該部分(NAT設定) | ||
+ | rdr pass on NatIF proto { gre } from any to Nat(G) -> RtrB(N) | ||
+ | </ | ||
+ | |||
+ | これで、gre over NATが動作するように見える。実際、tcpdumpでpingを観測してみると、greもicmpも見えるので問題ないと思われる。 | ||
+ | |||
+ | ===== 考察 ===== | ||
+ | * gre tunnel設定には、Src/ | ||
+ | * srcとdestの組み合わせで、複数のtunnelを制御することもできそう | ||
+ | * pfsyncと組み合わせ、冗長構成をとることもできるかもしれない | ||
+ | * IPsec over greを実装するのも比較的容易に見える |
os/freebsd/gre.txt · 最終更新: 2020/01/28 19:19 by seirios