Cisco 機器と IPsec その3

crypto isakmp profile にて match identity address 0.0.0.0を入れてしまうと、 該当外のIPSecもこの設定を利用してしまうため不都合があるので、 aggressive-mode を利用するほうが無難という。

Site2-A, Site2-B 共通

外へ出ていくIFが GigabitEthernet1/0 であるとしている。

crypto keyring <keyring-name>
  pre-shared-key address 0.0.0.0 0.0.0.0 key <shared-pass>

crypto isakmp profile <profile-name>
   keyring <keyring-name>
   match identity user-fqdn <User@FQDN.local>
   virtual-template <template number>

interface Virtual-Template <template number> type tunnel
 ip unnumbered GigabitEthernet1/0
 ip ospf 1 area 0
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile default

router ospf 1

Site2-A, Site2-B 共通

外へ出ていくIFが GigabitEthernet1/0 であるとしている。

crypto isakmp peer address <Site2-A Global IPAddress>
 set aggressive-mode password <shared-pass>
 set aggressive-mode client-endpoint user-fqdn <User@FQDN.local>

crypto isakmp peer address <Site2-B Global IPAddress>
 set aggressive-mode password <shared-pass>
 set aggressive-mode client-endpoint user-fqdn <User@FQDN.local>

interface Tunnel <tunnel number>
 ip unnumbered GigabitEthernet1/0
 ip ospf 1 area 0
 tunnel source GigabitEthernet1/0
 tunnel mode ipsec ipv4
 tunnel destination <Site2-A Global IPAddress>
 tunnel protection ipsec profile default

interface Tunnel <tunnel number>
 ip unnumbered GigabitEthernet1/0
 ip ospf 1 area 0
 tunnel source GigabitEthernet1/0
 tunnel destination <Site2-B Global IPAddress>
 tunnel protection ipsec profile default

router ospf 1

Cisco 機器と IPsec その2

crypto map を利用するやり方だと、冗長化構成が取れないので、 やはり virtual-template を使う方法に。

topology

f:id:paihu:20170604160223p:plain こんな感じ、余分なところを取って綺麗にしました。

設定

全体的に

virtual-template 使うと、 virtual-access というインターフェースが動的に生成されますが、 ここに対してstatic routeを入れる方法が分からなかったので とりあえず OSPF を動かしています。何らかのdynamic routing protocol動かさないと virtual-access インターフェースにトラフィックが向けられないような気がするのでそこがポイントかなと。

Site2側はmatch identity address 0.0.0.0 でどこからでも受けられるようになっているので、 Site3みたいな対向拠点をぽこぽこ増やしたいときもある程度対応できそうですね。

Site3側はSite2-AとSite2-B から同じコストで経路をもらうと、ロードバランスしてくれます。

Site2-A, Site2-B 共通

shared-pass を変えたい場合は変更すると良いかと。

crypto keyring <keyring-name>
  pre-shared-key address 0.0.0.0 0.0.0.0 key <shared-pass>

crypto isakmp profile <profile-name>
   keyring <keyring-name>
   match identity address 0.0.0.0
   virtual-template <template number>

interface Virtual-Template <template number> type tunnel
 ip unnumbered GigabitEthernet1/0
 ip ospf 1 area 0
 tunnel mode ipsec ipv4
 tunnel protection ipsec profile default

router ospf 1

Site3

crypto isakmp key <shared-pass> address <Site2-A Global IPAddress>
crypto isakmp key <shared-pass> address <Site2-B Global IPAddress>

interface Tunnel <tunnel number>
 ip unnumbered GigabitEthernet1/0
 ip ospf 1 area 0
 tunnel source GigabitEthernet1/0
 tunnel mode ipsec ipv4
 tunnel destination <Site2-A Global IPAddress>
 tunnel protection ipsec profile default

interface Tunnel <tunnel number>
 ip unnumbered GigabitEthernet1/0
 ip ospf 1 area 0
 tunnel source GigabitEthernet1/0
 tunnel mode ipsec ipv4
 tunnel destination <Site2-A Global IPAddress>
 tunnel protection ipsec profile default

router ospf 1

その他

シンプルな設定のみということで * crypto isakmp prfile * crypto ipsec prfile * crypto ipsec transform-set あたりはデフォルトのものを使うようにしてます。 本運用するのならちゃんと設定した方が良いかと

Cisco 機器と IPsec

IPsec、設定が面倒だなぁと思うものの一つです。

異機種間接続とかもう面倒で。

 

それはともかく、今回はCisco同士の話。

 

site to site VPNCisco機器同士ではりましょうという簡単なものです。

topology はこんな感じ。

 

f:id:paihu:20170603201320p:plain

現在、Site1とSite2 が 接続されている状態で、

Site2とSite3の間で新たに接続するという感じです。

 

Site1とSite2接続では、Site2側は Interface Tunnel 0 で接続されていて、

Site3を繋ぐにあたり、当然、切ってはいけない(パケットロスでもAlert上がるのでやめたい)

という状況です。

 

Site3側がIPアドレスが不定なため、トンネルインターフェースを作るのはあきらめ、

crypto map と access-listで何とかします。

 

Site2側は

 

 

crypto keyring <keyring-name>
    pre-shared-key address 0.0.0.0 0.0.0.0 key <shared-pass>

crypto isakmp profile <isakmp-profile-name>
   keyring <keyring-name>
   match identity address 0.0.0.0

crypto ipsec transform-set <set-name> esp-aes esp-sha-hmac

crypto dynamic-map <dynamic-map-name> 1
 set transform-set <set-name>
 set isakmp-profile <isakmp-profile-name>

crypto map <map-name> 1 ipsec-isakmp dynamic <dynamic-map-name>

interface <output interface>
    crypto map <map-name>


access-list 100 permit ip any <site3 network>

 

 

Site3側は

 

 

crypto isakmp key <shared-pass> address <site2 global-address>

crypto ipsec transform-set <set-name> esp-aes esp-sha-hmac

crypto map <map-name> 1 ipsec-isakmp
 set peer <site2 global-address>
 set transform-set <set-name>
 match address 100


interface <output interface>
    crypto map <map-name>

access-list 100 permit ip <site3 network> any

 

 

なお手軽構成です。

 

Site2とSite3で、 access-list の srcとdstが入れ替わったaclになってないと

接続できません、というのがポイントでしょうか。

 

 

どうでもいいですが、IPアドレスが動的でも、DNS登録されていれば、それ使って接続する方法もあって、

その方法だと Tunnel インターフェースが使えます。

(DDNSが書き換わってもそれを探しに行くので、

IPアドレス変更->DDNS登録変更->対向ホストでDNSキャッシュが切れて新しいIPアドレスが引けるようになる

という間は接続が切れますが、その後また自動復帰してくれるという)