にほんブログ村
私の自宅では、インターネットルーターに Cisco ルーターを使用していますので、父親の家でも Cisco ルーターを使って、父親の家と私の自宅を IPSec VPN で接続してみようかなと考えました。
以前は、Buffalo ルーターを使って、父親の家と VPN 接続していたのですが、それが壊れてしまいました。これがきっかけです。
今回考えているのは、以下のような構成です。
単純にインターネット越しに 2つのサイトを VPN 接続するという構成です。
今回の動作確認で使用したのは、Cisco 1812J です。2台のルーターをバックトゥバックで接続しています。
サイト間 VPN の動作確認
自宅に 2台の Cisco ルーターを用意し、テスト構成を作成して、IPSec の設定を行いました。
テスト構成は、以下のアドレス体系としています。
以下のIPSecの設定は、暗号化マップを使った方式となります。
IPsec の設定
- まず、ISAKMP ポリシーを作成します。
- ここでは、「共通鍵を使用しますよ」と宣言を行います。
- 次に、IPSec 接続の際に使用するキーを指定し、そして、そのキーを使用して IPSec 接続する対向先のルーターの IPアドレスを指定します。
crypto isakmp policy 10 <<< 1
hash md5
authentication pre-share <<< 2
crypto isakmp key vpnuser address 10.0.0.253 <<< 3
10.0.0.253 が R2 の Fast Ethernet の IPアドレスです。これは、インターネット越しで到達可能な IPアドレスである必要があります。
つまり、「このインターフェースとの IPSec 接続には、このキーを使用しましょう」ということです。
次に、Transform セットを作成します。
ここでは、IPSec 接続の際に使用する暗号化の方式を定義します。
crypto ipsec transform-set myset esp-des esp-md5-hmac
ここで使用している「myset」が、このTransform セットの名前になります。
使用する暗号化方式は、「esp-des esp-md5-hmac 」です。
次に、Cryptoマップ(暗号化マップ)を作成します。
このマップ内では、
- どの IPアドレスが IPSec の接続先なのか
- どの通信を IPSec トンネルの対象にするのか(トンネルの中に通すのか)
- 使用する Transform セットの名前
を定義します。
crypto map mymap 10 ipsec-isakmp
set peer 10.0.0.253 <<< 1
set transform-set myset <<< 2
match address 100 <<< 3
- この Crypto マップの名前は「mymap」としています。
- set peer で指定しているのが、IPSec の張り先となるIPアドレスです。
- このマップを使用する時には、「myset」という Transform セットを使いなさいとします。
- match address でしてしている番号が、ACL の番号となります。この ACL で IPSec トンネルの中に入れる対象となるトラフィックはどれなのかを定義します。
最後に、ACL を作成します。
2台のルーターの、それぞれの LAN 側のセグメントを指定します。
access-list 100 permit ip 172.16.16.0 0.0.7.255 172.16.24.0 0.0.0.127
「R1 の LAN 側(172.16.16.0 /21) から、R2 の LAN 側(172.16.24.0 /25) へ向かうトラフィックを IPSec トンネルの中に入れますよ」ということです。
これで、IPSec の基本設定は完了です。
IPSec のCrypto マップを適用
仕上げとして、作成した Crypto マップを、対象となるインターフェースに適用しましょう。
適用するインターフェースは、WAN 側(インターネット側)に面しているインターフェースです。つまり、対向側ルーターが IPSec トンネルを張ってくる宛先となるインターフェースです。
先ほど作成した Crypto マップは「mymap」でしたね。
crypto map コマンドで、そのマップの名前を指定して、インターフェースに適用します。
interface FastEthernet0
ip address 10.0.0.254 255.255.255.0
duplex auto
speed auto
crypto map mymap
私が Crypto マップを適用しているのは、Fast Ethernet 0 インターフェースになります。
そうそう、このルーターはインターネットルーターですので、デフォルトルートは Fast Ethernet 0 (インターネットに面しているインターフェース)に向けておきましょう。
これを忘れると、インターネット向けの通信ができません。
ip route 0.0.0.0 0.0.0.0 FastEthernet0
これで、IPSec の設定適用は完了です。
これと同じことを、R2 側でも行います。IPSec トンネルの接続先が R1 になる点だけが異なります。
以下、IPSec 接続に必要な部分の設定のみを抜粋しています。
crypto isakmp policy 10
hash md5
authentication pre-share
crypto isakmp key vpnuser address 10.0.0.254
!
!
crypto ipsec transform-set myset esp-des esp-md5-hmac
!
crypto map mymap 10 ipsec-isakmp
set peer 10.0.0.254
set transform-set myset
match address 100
!
!
interface BRI0
no ip address
encapsulation hdlc
shutdown
!
!
interface FastEthernet0
ip address 10.0.0.253 255.255.255.0
duplex auto
speed auto
crypto map mymap
!
!
ip route 0.0.0.0 0.0.0.0 FastEthernet0
!
access-list 100 permit ip 172.16.24.0 0.0.0.127 172.16.16.0 0.0.7.255
IPSec の接続確認コマンド
実際に通信をして確認をしてみます。
- show crypto isakmp sa
R1#sh crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id status
10.0.0.253 10.0.0.254 QM_IDLE 2001 ACTIVE
ステータスが「QM_IDLE」になっていれば、ISAKMP 接続は完了です。
「QM_IDLE」以外のステータスの場合、このページが参考になります。
- show crypto ipsec sa
C1812-test#sh crypto ipsec sa
interface: FastEthernet0
Crypto map tag: M-ipsec, local addr 10.0.0.254
protected vrf: (none)
local ident (addr/mask/prot/port): (0.0.0.0/255.255.255.255/47/0)
remote ident (addr/mask/prot/port): (0.0.0.0/255.255.255.255/47/0)
current_peer 10.0.0.253 port 500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 97, #pkts encrypt: 97, #pkts digest: 97
#pkts decaps: 94, #pkts decrypt: 94, #pkts verify: 94
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 134, #recv errors 0
local crypto endpt.: 10.0.0.254, remote crypto endpt.: 10.0.0.253
path mtu 1500, ip mtu 1500, ip mtu idb FastEthernet0
current outbound spi: 0xD8FB69D5(3640355285)
PFS (Y/N): N, DH group: none
inbound esp sas:
spi: 0xD6CE8456(3603858518)
transform: esp-3des esp-md5-hmac ,
in use settings ={Tunnel, }
conn id: 1, flow_id: Onboard VPN:1, sibling_flags 80000046, crypto map: M-ipsec
sa timing: remaining key lifetime (k/sec): (4420763/2793)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE
inbound ah sas:
inbound pcp sas:
outbound esp sas:
spi: 0xD8FB69D5(3640355285)
transform: esp-3des esp-md5-hmac ,
in use settings ={Tunnel, }
conn id: 2, flow_id: Onboard VPN:2, sibling_flags 80000046, crypto map: M-ipsec
sa timing: remaining key lifetime (k/sec): (4420762/2793)
IV size: 8 bytes
replay detection support: Y
Status: ACTIVE
outbound ah sas:
outbound pcp sas:
カウンターの数値が上がっていれば、IPSec トンネルの中に通信が通過しています。
うまく接続できない時は、デバッグコマンドが役に立ちます。
- debug crypto isakmp
- debug crypto ipsec
設定内容
R1
R1#sh run
Building configuration...
Current configuration : 1842 bytes
!
! Last configuration change at 06:21:16 UTC Tue Feb 23 2021
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R1
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
!
!
!
!
!
dot11 syslog
ip source-route
!
!
!
!
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
!
!
!
license udi pid CISCO1812-J/K9 sn xxxxxxx
!
!
!
!
crypto isakmp policy 10
hash md5
authentication pre-share
crypto isakmp key vpnuser address 10.0.0.253
!
!
crypto ipsec transform-set myset esp-des esp-md5-hmac
!
crypto map mymap 10 ipsec-isakmp
set peer 10.0.0.253
set transform-set myset
match address 100
!
!
!
!
!
interface BRI0
no ip address
encapsulation hdlc
shutdown
!
!
interface FastEthernet0
ip address 10.0.0.254 255.255.255.0
duplex auto
speed auto
crypto map mymap
!
!
interface FastEthernet1
no ip address
duplex auto
speed auto
!
!
interface FastEthernet2
switchport access vlan 100
!
!
interface FastEthernet3
switchport access vlan 100
!
!
interface FastEthernet4
switchport access vlan 100
!
!
interface FastEthernet5
switchport access vlan 100
!
!
interface FastEthernet6
switchport access vlan 100
!
!
interface FastEthernet7
switchport access vlan 100
!
!
interface FastEthernet8
switchport access vlan 100
!
!
interface FastEthernet9
switchport access vlan 100
!
!
interface Vlan1
no ip address
!
!
interface Vlan100
ip address 172.16.23.254 255.255.248.0
!
!
router ospf 1
log-adjacency-changes
network 172.16.16.0 0.0.7.255 area 0
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
ip route 0.0.0.0 0.0.0.0 FastEthernet0
!
access-list 100 permit ip 172.16.16.0 0.0.7.255 172.16.24.0 0.0.0.127
!
!
!
!
!
!
control-plane
!
!
!
line con 0
line aux 0
line vty 0 4
login
!
end
R2
R2#sh run
Building configuration...
Current configuration : 1980 bytes
!
! Last configuration change at 06:07:15 UTC Sun Feb 13 2022
!
version 15.0
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname R2
!
boot-start-marker
boot-end-marker
!
!
no aaa new-model
!
!
!
memory-size iomem 25
!
!
dot11 syslog
ip source-route
!
!
!
!
ip cef
no ipv6 cef
!
multilink bundle-name authenticated
!
!
!
license udi pid CISCO1812-J/K9 sn xxxxxxx
!
!
vlan 100
name home-data
!
vlan 111
name MGMT
!
vlan 200
name PBR-test
!
!
!
crypto isakmp policy 10
hash md5
authentication pre-share
crypto isakmp key vpnuser address 10.0.0.254
!
!
crypto ipsec transform-set myset esp-des esp-md5-hmac
!
crypto map mymap 10 ipsec-isakmp
set peer 10.0.0.254
set transform-set myset
match address 100
!
!
!
!
!
interface BRI0
no ip address
encapsulation hdlc
shutdown
!
!
interface FastEthernet0
ip address 10.0.0.253 255.255.255.0
duplex auto
speed auto
crypto map mymap
!
!
interface FastEthernet1
no ip address
duplex auto
speed auto
!
!
interface FastEthernet2
switchport access vlan 100
!
!
interface FastEthernet3
switchport access vlan 100
!
!
interface FastEthernet4
switchport access vlan 100
!
!
interface FastEthernet5
switchport access vlan 100
!
!
interface FastEthernet6
switchport access vlan 100
!
!
interface FastEthernet7
switchport access vlan 100
!
!
interface FastEthernet8
switchport access vlan 100
!
!
interface FastEthernet9
switchport access vlan 100
!
!
interface Vlan1
no ip address
!
!
interface Vlan100
ip address 172.16.24.126 255.255.255.128
!
!
router ospf 1
log-adjacency-changes
network 172.16.24.0 0.0.0.127 area 0
!
ip forward-protocol nd
no ip http server
no ip http secure-server
!
!
ip route 0.0.0.0 0.0.0.0 FastEthernet0
!
access-list 100 permit ip 172.16.24.0 0.0.0.127 172.16.16.0 0.0.7.255
!
!
!
!
!
!
control-plane
!
!
!
line con 0
line aux 0
line vty 0 4
login
!
end
おもしろかったら、フォローしてください!
関連する記事:
- Cisco ルーターでリモートアクセス VPN の設定
- FHRP を学ぶ (0) FHRP の種類
- QNAP NASのポートトランキング設定ガイド
- Cisco EEMを用いた自動化: イベント管理をマスターする
- Cisco 認定資格 CCNP の更新時期が迫ってきた
- ダイナミックルーティングのためのGREトンネル
- CiscoルーターでのIPSec VPN設定ガイド
- Cisco ルーターでダイナミック DNS を使う
- 格安Cisco SFPの購入体験と設定ガイド
- 静音のCisco Catalyst 2960 POEスイッチのレビュー
最近の記事:
- 複数の宛先に ping を打つことができる「fping」
- ネイティブの英語 7 “A cup of joe”
- 死刑確定囚・野比のび太 – 第二十三話・昇華するのび太の鬱屈
- 死刑確定囚・野比のび太 – 第二十二話・静の怒りと武の苛立ち
- 死刑確定囚・野比のび太 – 第二十一話・夫婦間の亀裂とのび太の影響
- 死刑確定囚・野比のび太 – 第二十話・のび太の初出勤: 恐れと葛藤
- 死刑確定囚・野比のび太 – 第十九話・ジャイアンとのび太の絆
- 死刑確定囚・野比のび太 – 第十八話・引きこもりの息子と家族のジレンマ
- 死刑確定囚・野比のび太 – 第十七話・ドラえもんと30歳ののび太の葛藤
- 死刑確定囚・野比のび太 – 第十六話・剛田商店の成長と静香の貢献