IPSecとNPAT併用時の注意点
久しぶりにIPSecとNAPTを併用した環境を作ったら動作に違和感を覚えたので書き出しておきます。
PC01(172.16.0.1)からPC02(172.16.10.1)にPing疎通時、以下のACLによってIPSecの暗号化トラフィック対象としていた場合、IPSecのセッションが形成され疎通可能になります。
crypto map CMAP 1 ipsec-isakmp
set peer 210.154.183.2
set transform-set TSET
match address 101
crypto map CMAP
!
access-list 101 permit ip 172.16.0.0 0.0.0.255 172.16.10.0 0.0.0.255
環境作成当初、誤ってNAPTされる対象トラフィックも同一の値を設定してしまい、IPSecが形成されませんでした。
ip nat inside source list 100 interface Dialer1 overload
!
access-list 100 permit ip 172.16.0.0 0.0.0.255 172.16.10.0 0.0.0.255
CERT01とWANのポイントをキャプチャすると以下のようなログが出ており、PC01のIPアドレスがCERT01のDialer interfaceのIPにNAPTされていることがわかりました。
あれ、、、CiscoってIPSecを設定している場合、ルータの処理順って暗号化トラフィックの指定のほうが早いんじゃなかったけ、、、と思って処理順序を調べてみました。
よく見るとIPSecのACLチェックは1番だけど暗号化は14番ですね、、だから暗号化前にNAPTさされてしまい、暗号化されず出力されるんですね、、、勉強になりました。
当然NAPT用のACLを変更し、IPSecの暗号化トラフィックは対象外にすれば問題なく通信が出来ました。
CERT01#show crypto isakmp sa
dst src state conn-id slot status
210.154.183.2 210.154.182.1 QM_IDLE 1002 0 ACTIVE
最終設定時の各コンフィグは以下となります。
hostname CERT01
!
crypto isakmp policy 1
encr aes
hash md5
authentication pre-share
group 2
crypto isakmp key hy address 210.154.183.2
!
crypto ipsec transform-set TSET esp-aes
!
crypto map CMAP 1 ipsec-isakmp
set peer 210.154.183.2
set transform-set TSET
match address 101
!
interface FastEthernet0/0
pppoe enable
pppoe-client dial-pool-number 1
!
interface FastEthernet0/1
ip address 172.16.0.254 255.255.255.0
ip nat inside
!
interface Dialer1
ip address negotiated
ip nat outside
ip virtual-reassembly
encapsulation ppp
dialer pool 1
dialer-group 1
ppp authentication chap callin
ppp chap hostname hy@hy.com
ppp chap password 0 hy
crypto map CMAP
!
ip route 0.0.0.0 0.0.0.0 Dialer1
!
ip nat inside source list 100 interface Dialer1 overload
!
access-list 100 deny ip 172.16.0.0 0.0.0.255 172.16.10.0 0.0.0.255
access-list 100 permit ip any any
access-list 101 permit ip 172.16.0.0 0.0.0.255 172.16.10.0 0.0.0.255
dialer-list 1 protocol ip permit
hostname CERT02
!
crypto isakmp policy 1
encr aes
hash md5
authentication pre-share
group 2
crypto isakmp key hy address 210.154.182.1
!
crypto ipsec transform-set TSET esp-aes
!
crypto map CMAP 1 ipsec-isakmp
set peer 210.154.182.1
set transform-set TSET
match address 101
!
interface FastEthernet0/0
ip address 172.16.10.254 255.255.255.0
ip nat inside
!
interface FastEthernet0/1
pppoe enable
pppoe-client dial-pool-number 1
!
interface Dialer1
ip address negotiated
ip nat outside
encapsulation ppp
dialer pool 1
dialer-group 1
ppp authentication chap callin
ppp chap hostname hy1@hy.com
ppp chap password 0 hy1
crypto map CMAP
!
ip route 0.0.0.0 0.0.0.0 Dialer1
!
ip nat inside source list 100 interface Dialer1 overload
!
access-list 100 deny ip 172.16.10.0 0.0.0.255 172.16.0.0 0.0.0.255
access-list 100 permit ip any any
access-list 101 permit ip 172.16.10.0 0.0.0.255 172.16.0.0 0.0.0.255
dialer-list 1 protocol ip permit
hostname WAN
!
username hy@hy.com password 0 hy
username hy1@hy.com password 0 hy1
!
bba-group pppoe PPP1
virtual-template 1
!
bba-group pppoe PPP2
virtual-template 2
!
interface Loopback1
ip address 1.1.1.1 255.255.255.255
!
interface Loopback2
ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
pppoe enable group PPP1
!
interface FastEthernet0/1
pppoe enable group PPP2
!
interface Virtual-Template1
ip unnumbered Loopback1
peer default ip address pool POOL1
ppp authentication chap
!
interface Virtual-Template2
ip unnumbered Loopback2
peer default ip address pool POOL2
ppp authentication chap
!
ip local pool POOL1 210.154.182.1
ip local pool POOL2 210.154.183.2