VPN(IPSec+ACL)
VPN構築(IPsec)
access-list number [permit/deny] [protocol] [source_ip/network] [wildcard] [port] [dest_ip/network] [wildcard] [option]
設定内容 | ACLの設定 |
---|---|
192.168.1.1 から 10.1.1.1 へのIP通信を許可 | access-list 100 permit ip host 192.168.1.1 host 10.1.1.1 |
192.168.1.0/24 から 10.1.1.0/24 へのIP通信を許可 | access-list 100 permit ip 192.168.1.0 0.0.0.255 10.1.1.0 0.0.0.255 |
192.168.1.0/24 から 10.1.1.1 へのIP通信を拒否 | access-list 100 deny ip 192.168.1.0 0.0.0.255 host 10.1.1.1 |
192.168.1.0/24 から全ての宛先へのIP通信を拒否 | access-list 100 deny ip 192.168.1.0 0.0.0.255 any |
全ての送信元から 10.1.1.1 へのHTTP通信を許可 | access-list 100 permit tcp any host 10.1.1.1 eq 80 |
10.1.1.1 のWebサーバから全ての宛先への通信を許可 | access-list 100 permit tcp host 10.1.1.1 eq 80 any |
192.168.0.0/24 から 10.1.1.1 へのTFTP通信を拒否 | access-list 100 deny udp 192.168.0.0 0.0.0.255 host 10.1.1.1 eq 69 |
192.168.1.0/24 から 10.1.1.1 へのtelnet通信を拒否 | access-list 100 deny tcp 192.168.1.0 0.0.0.255 host 10.1.1.1 eq 23 |
全てのICMP通信を許可 | access-list 100 permit icmp any any |
192.168.1.1 から 10.1.1.0/24 へのICMP通信を許可 | access-list 100 permit icmp host 192.168.1.1 10.1.1.0 0.0.0.255 |
全てのIP通信を許可 | access-list 100 permit ip any any |
全てのIP通信を拒否 | access-list 100 deny ip any any(最終行に自動で追加されるので使わない) |
2.IKEポリシーの定義
(config)#crypto isakmp policy [policy_num] ポリシー番号:1~10000(1が最優先)
パラメータの定義
◆認証方式 (共通鍵と公開鍵があるが共通鍵が一般的)
(config-isakmp)#authentication [pre-share/rsa-encr/ rsa-sig]
◆暗号化アルゴリズム (3desが一般的)
(config-isakmp)#encryption [3des/aes/des]
◆Diffie-Hellmanグループ (数字が大きい方が安全だがオーバーヘッド大、デフォルト値:group 1)
(config-isakmp)#group [1/2/5]
◆ハッシュアルゴリズム(shaが一般的)
(config-isakmp)#hash [md5/sha]
◆有効期限(デフォルト値:86400)
(config-isakmp)#lifetime [seconds]
◆認証の設定(共通鍵とIPアドレスの関連付け)
パスワードは任意だが、対向ルータと一致させる必要がある。
(config)#crypto isakmp key [password] address [peer_router_ip]
3.トランスフォームセットの定義(IPSec通信設定)
◆トランスフォームセットの名前定義
(config)#crypto ipsec transform-set [name] [オプション]
◆IPsec通信モードの指定
トランスポートモードとトンネルモードのどちらかを指定。
(cfg-crypto-trans)#mode [transport/tunnel]
ルータを介してVPNを構築する場合、「transport」モードを指定。
4.IPSecポリシーの定義
◆crypto mapの定義
トランスフォームとは異なる名前を定義
シーケンス番号:1~65535
(config)#crypto map [name] [seq_num] ipsec-isakmp
◆アクセスリストの選択
(config-crypto-map)#match address [access_list_num/access_list_name]
(config-crypto-map)#set peer [hostname/ip_address]
◆トランスフォームセットの指定
(config-crypto-map)#set transform-set [transform_name]
◆IPSec SAの生存時間の指定
IPSec SAの生存時間を指定し、どちらかの条件(キロバイト数 or 秒数)に早く合致したほうで処理される。
デフォルト値
(config-crypto-map)#set security-association lifetime [kilobytes/seconds] [value]
5.インタフェースへのIPSecポリシーの適用
(config)#interface [interface] (config-if)#crypto map [crypto map_name]
具体的な設定例
172.16.x.xから172.17.x.xの通信のみを許可する
拡張アクセスリストにしないとエラーが出る
標準アクセスリスト:1~99
拡張アクセスリスト:100~199
(config)# access-list 100 permit ip 172.16.0.0 0.0.255.255 172.17.0.0 0.0.255.255
2.IKEポリシーの定義
設定項目 | パラメータ |
---|---|
policy優先度 | 1 |
鍵認証方式 | pre-share(共通鍵) |
暗号化アルゴリズム | 3des |
Diffie-Hellmanグループ | 1 |
ハッシュアルゴリズム | sha |
有効期限 | 86400s(1日) |
パスワード | cisco |
R1 (config)#crypto isakmp policy 1 (config-isakmp)#authentication pre-share (config-isakmp)#encryption 3des (config-isakmp)#group 1 (config-isakmp)#hash sha (config-isakmp)#lifetime 86400 (config-isakmp)#exit (config)#crypto isakmp key cisco address 200.200.200.2
3.トランスフォームセットの定義(IPSec通信設定)
トランスフォームの名前をIPSECとする。
(config)#crypto ipsec transform-set IPSEC esp-3des esp-sha-hmac (cfg-crypto-trans)#mode tunnel
4.IPSecポリシーの定義
map名をMAP-IPSECに設定。 1行目で下記のようなエラーが出るが気にしないでOK
This new crypto map will remain disabled until a peer and a valid access list have been configured.
(config)#crypto map MAP-IPSEC 1 ipsec-isakmp (config-crypto-map)#match address 100 (config-crypto-map)#set peer 200.200.200.2 (config-crypto-map)#set transform-set IPSEC (config-crypto-map)#set security-association lifetime seconds 3600 (config-crypto-map)#exit
5.インタフェースへのIPSecポリシーの適用
(config)# interface Ethernet 0/0 (config-if)#crypto map MAP-IPSEC
以上でVPNの設定は終了
最後に、PC1とPC2のルーティングをスタティックで行う
R1 (config)#ip route 172.17.0.0 255.255.0.0 200.200.200.2 R2 (config)#ip route 172.16.0.0 255.255.0.0 200.200.200.1
これでPC1とPC2の間でpingが通る