NAT環境下でのSite-to-Site VPN+L2TP(Any待ち)
「久しぶりにGNS3(その44:Ciscoルーター利用時のNAT環境下でのSite-to-Site VPN(Any待ち))」の続き。ほぼ、そのまま実現できるかと思ったが、そうではなかった。
方針
Dyamic Mapを使うのではなく、DMVPNを利用して実現する。下記サイトが参考になる。
結論的には、下記がポイント。
- IPsecを確立するルーターにLoopbackアドレスを設け、そのLoopbackをL2TPの端点とする
- Loopbackアドレスを、DMVPNにより解決(ルーティング確立)
環境
- 中央のルーターがNAT
- NAT内側にルーターR1
- NAT外側にルーターR2
- R1-R2間がIPsecにより暗号化かつL2TPトンネル
- 末端のPC1及びPC2とが同一ネットワーク(192.168.1.0/24)
設定
関連する部分のみ記載(及び説明)。
NAT内側ルーター(R1)
hostname R1
pseudowire-class L2TP
encapsulation l2tpv3
ip local interface Loopback1
crypto isakmp policy 1
authentication pre-share
crypto isakmp key PRE-KEY address 0.0.0.0
crypto ipsec transform-set TS-IPSEC esp-aes esp-sha-hmac
mode tunnel
crypto map DMVPN local-address Ethernet0/0
crypto map DMVPN 1 ipsec-isakmp
set peer 50.1.1.1
set security-association level per-host
set transform-set TS-IPSEC
match address 100
interface Loopback1
ip address 1.1.1.1 255.255.255.255
!
interface Tunnel1
ip address 10.0.0.1 255.255.255.252
ip mtu 1436
ip nhrp authentication NHRP-KEY
ip nhrp map 10.0.0.2 50.1.1.1
ip nhrp network-id 100
ip nhrp holdtime 600
ip nhrp nhs 10.0.0.2
tunnel source Ethernet0/0
tunnel destination 50.1.1.1
tunnel key 50
crypto map DMVPN
interface Ethernet0/0
ip address 200.1.1.1 255.255.255.0
crypto map DMVPN
interface Ethernet0/3
no ip address
xconnect 2.2.2.2 1 encapsulation l2tpv3 pw-class L2TP
ip route 0.0.0.0 0.0.0.0 200.1.1.254
ip route 2.2.2.2 255.255.255.255 10.0.0.2
ip route 10.0.0.0 255.255.255.252 Tunnel1
access-list 100 permit gre any host 50.1.1.1
- L2TP
- Version3
- 対象インターフェース:Loopback1
- IKE
- 事前共有鍵:testpwd
- 対象IPアドレス:DMVPN用に不定(0.0.0.0)とする
- IPsec
- 暗号化およびハッシュ方式
- トンネルモード
- 暗号化マップ:DMVPN
- 対象インターフェース:Ethernet0/0
- 対向機IPアドレス:対向ルーター(50.1.1.1)
- 対象IPアドレス(access-list 100)
- Loopback1 IPアドレス:1.1.1.1/32
- Tunnel1:トンネルインターフェース
- IPアドレス:10.0.0.1/30
- NHRPキー:NHRP-KEY
- 相手トンネルIPアドレス(10.0.0.2)を実IPアドレス(50.1.1.1)へマッピング
- NHS IPアドレス:10.0.0.2
- トンネルソースインターフェース:Ethernet0/0
- トンネル先IPアドレス:50.1.1.1
- 暗号マップ適用:DMVPN
- インターフェースEthernet0/0
- IPアドレス:200.1.1.1
- 暗号マップ適用:DMVPN
- インターフェースEthernet0/3
- L2TP対象インターフェース
- 接続先:対向機ループバックIPアドレス(2.2.2.2)
- スタティックルート
- デフォルトルート:NATルーター
- 対向機ループバックIPアドレス(2.2.2.2):対向機トンネルIPアドレス(10.0.0.2)
- トンネルIPアドレスネットワーク:トンネルインターフェース(Tunnel1)
- IPsec対象:GREトンネルかつ宛先指定(対向機IPアドレス50.1.1.1)
NAT外側ルーター(R2)
hostname R2
pseudowire-class L2TP
encapsulation l2tpv3
ip local interface Loopback1
crypto isakmp policy 1
authentication pre-share
crypto isakmp key PRE-KEY address 0.0.0.0
crypto ipsec transform-set TS-IPSEC esp-aes esp-sha-hmac
mode tunnel
crypto ipsec profile PR-IPSEC
set transform-set TS-IPSEC
interface Loopback1
ip address 2.2.2.2 255.255.255.255
interface Tunnel1
ip address 10.0.0.2 255.255.255.252
no ip redirects
ip mtu 1436
ip nhrp authentication NHRP-KEY
ip nhrp map multicast dynamic
ip nhrp network-id 100
ip nhrp holdtime 600
tunnel source Ethernet0/0
tunnel mode gre multipoint
tunnel key 50
tunnel protection ipsec profile PR-IPSEC
interface Ethernet0/0
ip address 50.1.1.1 255.255.255.0
interface Ethernet0/3
no ip address
xconnect 1.1.1.1 1 encapsulation l2tpv3 pw-class L2TP
ip route 0.0.0.0 0.0.0.0 50.1.1.254
ip route 1.1.1.1 255.255.255.255 10.0.0.1
ip route 10.0.0.0 255.255.255.252 Tunnel1
L2TP
- Version3
- 対象インターフェース:Loopback1
- IKE
- 事前共有鍵:testpwd
- 対象IPアドレス:DMVPN用に不定(0.0.0.0)とする
- IPsec
- 暗号化およびハッシュ方式
- トンネルモード
- 暗号化プロファイル:PR-IPSEC
- Loopback1 IPアドレス:2.2.2.2/32
- Tunnel1:トンネルインターフェース
- IPアドレス:10.0.0.2/30
- NHRPキー:NHRP-KEY
- NHRPマップ:マルチキャストダイナミック(multicast dynamic)
- トンネルソースインターフェース:Ethernet0/0
- トンネルモード:mGRE(multipoint gre)
- 暗号プロファイル適用:PR-IPSEC
- インターフェースEthernet0/0
- IPアドレス:50.1.1.1
- インターフェースEthernet0/3
- L2TP対象インターフェース
- 接続先:対向機ループバックIPアドレス(1.1.1.1)
- スタティックルート
- デフォルトルート:NATルーター
- 対向機ループバックIPアドレス(1.1.1.1):対向機トンネルIPアドレス(10.0.0.1)
- トンネルIPアドレスネットワーク:トンネルインターフェース(Tunnel1)
NATルーター
hostname NAT
interface FastEthernet0/0
ip address 200.1.1.254 255.255.255.0
ip nat inside
interface FastEthernet0/1
ip address 50.1.1.254 255.255.255.0
ip nat outside
ip nat inside source list 10 interface FastEthernet0/1 overload
access-list 10 permit any
- インターフェース(IPアドレス)
- NAT
- 内側及び外側の指定
- IPマスカレード(overload)
- NAT対象(access-list 10)
PC1及びPC2
自明のため、省略。
検証
あえて、NAT外側PC1からNAT内側PC2へのPingを実施(DMVPNによりIPsec確立済みのため)。
PC2> ping 192.168.1.1
84 bytes from 192.168.1.1 icmp_seq=1 ttl=64 time=34.572 ms
84 bytes from 192.168.1.1 icmp_seq=2 ttl=64 time=32.043 ms
84 bytes from 192.168.1.1 icmp_seq=3 ttl=64 time=31.441 ms
84 bytes from 192.168.1.1 icmp_seq=4 ttl=64 time=22.086 ms
84 bytes from 192.168.1.1 icmp_seq=5 ttl=64 time=19.271 ms
Wiresharkで取得したデータ
NAT外側(PC-NAT間)
PC2(192.168.1.2)が、ARPを用いて、PC1(192.168.1.1)のMacアドレスを取得している様子、ping(ICMP)の様子が見える。
NAT内側(R1-NAT間)
IKE(UDP 500)で通信開始。
途中から、IKE/ESP over UDP(UDP 4500)となる。これは、Ciscoルーターの特徴。下記は、ping実施時のものであるが、ICMPやNHRPのパケットは、暗号化(ESP)されているため、見えない。
NAT外側(R2-NAT間)
当然ながら、NAT外側では、内側のIPアドレス(R1のIPアドレス:200.1.1.1)は見えない。
ルーターのStatus
ルーティング情報、IPsec/NHRP/L2TP/トンネル状況を記す。
R1
R1#show ip route
Gateway of last resort is 200.1.1.254 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 200.1.1.254
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback1
2.0.0.0/32 is subnetted, 1 subnets
S 2.2.2.2 [1/0] via 10.0.0.2
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/30 is directly connected, Tunnel1
L 10.0.0.1/32 is directly connected, Tunnel1
200.1.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 200.1.1.0/24 is directly connected, Ethernet0/0
L 200.1.1.1/32 is directly connected, Ethernet0/0
R1#show crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id status
50.1.1.1 200.1.1.1 QM_IDLE 1001 ACTIVE
R1#show crypto ipsec sa
interface: Tunnel1
Crypto map tag: DMVPN, local addr 200.1.1.1
protected vrf: (none)
local ident (addr/mask/prot/port): (0.0.0.0/0.0.0.0/47/0)
remote ident (addr/mask/prot/port): (50.1.1.1/255.255.255.255/47/0)
current_peer 50.1.1.1 port 500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 0, #pkts encrypt: 0, #pkts digest: 0
#pkts decaps: 0, #pkts decrypt: 0, #pkts verify: 0
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 200.1.1.1, remote crypto endpt.: 50.1.1.1
plaintext mtu 1436, path mtu 1436, ip mtu 1436, ip mtu idb Tunnel1
current outbound spi: 0x0(0)
PFS (Y/N): N, DH group: none
inbound esp sas:
inbound ah sas:
inbound pcp sas:
outbound esp sas:
outbound ah sas:
outbound pcp sas:
protected vrf: (none)
local ident (addr/mask/prot/port): (200.1.1.1/255.255.255.255/47/0)
remote ident (addr/mask/prot/port): (50.1.1.1/255.255.255.255/47/0)
current_peer 50.1.1.1 port 4500
PERMIT, flags={}
#pkts encaps: 18, #pkts encrypt: 18, #pkts digest: 18
#pkts decaps: 22, #pkts decrypt: 22, #pkts verify: 22
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 200.1.1.1, remote crypto endpt.: 50.1.1.1
plaintext mtu 1358, path mtu 1436, ip mtu 1436, ip mtu idb Tunnel1
current outbound spi: 0x6E466FE4(1850109924)
PFS (Y/N): N, DH group: none
inbound esp sas:
spi: 0xCAECD9A9(3404519849)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel UDP-Encaps, }
conn id: 1, flow_id: SW:1, sibling_flags 80004040, crypto map: DMVPN
sa timing: remaining key lifetime (k/sec): (4341059/3332)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE(ACTIVE)
inbound ah sas:
inbound pcp sas:
outbound esp sas:
spi: 0x6E466FE4(1850109924)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel UDP-Encaps, }
conn id: 2, flow_id: SW:2, sibling_flags 80004040, crypto map: DMVPN
sa timing: remaining key lifetime (k/sec): (4341060/3332)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE(ACTIVE)
outbound ah sas:
outbound pcp sas:
interface: Ethernet0/0
Crypto map tag: DMVPN, local addr 200.1.1.1
protected vrf: (none)
local ident (addr/mask/prot/port): (0.0.0.0/0.0.0.0/47/0)
remote ident (addr/mask/prot/port): (50.1.1.1/255.255.255.255/47/0)
current_peer 50.1.1.1 port 500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 0, #pkts encrypt: 0, #pkts digest: 0
#pkts decaps: 0, #pkts decrypt: 0, #pkts verify: 0
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 200.1.1.1, remote crypto endpt.: 50.1.1.1
plaintext mtu 1436, path mtu 1436, ip mtu 1436, ip mtu idb Tunnel1
current outbound spi: 0x0(0)
PFS (Y/N): N, DH group: none
inbound esp sas:
inbound ah sas:
inbound pcp sas:
outbound esp sas:
outbound ah sas:
outbound pcp sas:
protected vrf: (none)
local ident (addr/mask/prot/port): (200.1.1.1/255.255.255.255/47/0)
remote ident (addr/mask/prot/port): (50.1.1.1/255.255.255.255/47/0)
current_peer 50.1.1.1 port 4500
PERMIT, flags={}
#pkts encaps: 18, #pkts encrypt: 18, #pkts digest: 18
#pkts decaps: 22, #pkts decrypt: 22, #pkts verify: 22
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 200.1.1.1, remote crypto endpt.: 50.1.1.1
plaintext mtu 1358, path mtu 1436, ip mtu 1436, ip mtu idb Tunnel1
current outbound spi: 0x6E466FE4(1850109924)
PFS (Y/N): N, DH group: none
inbound esp sas:
spi: 0xCAECD9A9(3404519849)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel UDP-Encaps, }
conn id: 1, flow_id: SW:1, sibling_flags 80004040, crypto map: DMVPN
sa timing: remaining key lifetime (k/sec): (4341059/3332)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE(ACTIVE)
inbound ah sas:
inbound pcp sas:
outbound esp sas:
spi: 0x6E466FE4(1850109924)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel UDP-Encaps, }
conn id: 2, flow_id: SW:2, sibling_flags 80004040, crypto map: DMVPN
sa timing: remaining key lifetime (k/sec): (4341060/3332)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE(ACTIVE)
outbound ah sas:
outbound pcp sas:
R1#show ip nhrp brief
Target Via NBMA Mode Intfc Claimed
10.0.0.2/32 10.0.0.2 50.1.1.1 static Tu1 < >
R1#show l2tp
L2TP Tunnel and Session Information Total tunnels 1 sessions 1
LocTunID RemTunID Remote Name State Remote Address Sessn L2TP Class/
Count VPDN Group
1059798518 102810956 R2 est 2.2.2.2 1 l2tp_default_cl
LocID RemID TunID Username, Intf/ State Last Chg Uniq ID
Vcid, Circuit
988304820 2759286366 1059798518 1, Et0/3 est 01:36:25 0
R1#show interfaces tunnel 1
Tunnel1 is up, line protocol is up
Hardware is Tunnel
Internet address is 10.0.0.1/30
MTU 17912 bytes, BW 100 Kbit/sec, DLY 50000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation TUNNEL, loopback not set
Keepalive not set
Tunnel linestate evaluation up
Tunnel source 200.1.1.1 (Ethernet0/0), destination 50.1.1.1
Tunnel Subblocks:
src-track:
Tunnel1 source tracking subblock associated with Ethernet0/0
Set of tunnels with source Ethernet0/0, 1 member (includes iterators), on interface <OK>
Tunnel protocol/transport GRE/IP
Key 0x32, sequencing disabled
Checksumming of packets disabled
Tunnel TTL 255, Fast tunneling enabled
Tunnel transport MTU 1472 bytes
Tunnel transmit bandwidth 8000 (kbps)
Tunnel receive bandwidth 8000 (kbps)
Last input 00:00:49, output 00:00:46, output hang never
Last clearing of "show interface" counters 00:10:59
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/0 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
32 packets input, 3455 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
31 packets output, 3423 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
0 unknown protocol drops
0 output buffer failures, 0 output buffers swapped out
R2
R2#show ip route
Gateway of last resort is 50.1.1.254 to network 0.0.0.0
S* 0.0.0.0/0 [1/0] via 50.1.1.254
1.0.0.0/32 is subnetted, 1 subnets
S 1.1.1.1 [1/0] via 10.0.0.1
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback1
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/30 is directly connected, Tunnel1
L 10.0.0.2/32 is directly connected, Tunnel1
50.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 50.1.1.0/24 is directly connected, Ethernet0/0
L 50.1.1.1/32 is directly connected, Ethernet0/0
R2#show crypto isakmp sa
IPv4 Crypto ISAKMP SA
dst src state conn-id status
50.1.1.1 50.1.1.254 QM_IDLE 1001 ACTIVE
R2#show crypto ipsec sa
interface: Tunnel1
Crypto map tag: Tunnel1-head-0, local addr 50.1.1.1
protected vrf: (none)
local ident (addr/mask/prot/port): (50.1.1.1/255.255.255.255/47/0)
remote ident (addr/mask/prot/port): (200.1.1.1/255.255.255.255/47/0)
current_peer 50.1.1.254 port 4500
PERMIT, flags={origin_is_acl,}
#pkts encaps: 38, #pkts encrypt: 38, #pkts digest: 38
#pkts decaps: 34, #pkts decrypt: 34, #pkts verify: 34
#pkts compressed: 0, #pkts decompressed: 0
#pkts not compressed: 0, #pkts compr. failed: 0
#pkts not decompressed: 0, #pkts decompress failed: 0
#send errors 0, #recv errors 0
local crypto endpt.: 50.1.1.1, remote crypto endpt.: 50.1.1.254
plaintext mtu 1422, path mtu 1500, ip mtu 1500, ip mtu idb (none)
current outbound spi: 0xCAECD9A9(3404519849)
PFS (Y/N): N, DH group: none
inbound esp sas:
spi: 0x6E466FE4(1850109924)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel UDP-Encaps, }
conn id: 1, flow_id: SW:1, sibling_flags 80000040, crypto map: Tunnel1-head-0
sa timing: remaining key lifetime (k/sec): (4284871/2787)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE(ACTIVE)
inbound ah sas:
inbound pcp sas:
outbound esp sas:
spi: 0xCAECD9A9(3404519849)
transform: esp-aes esp-sha-hmac ,
in use settings ={Tunnel UDP-Encaps, }
conn id: 2, flow_id: SW:2, sibling_flags 80000040, crypto map: Tunnel1-head-0
sa timing: remaining key lifetime (k/sec): (4284870/2787)
IV size: 16 bytes
replay detection support: Y
Status: ACTIVE(ACTIVE)
outbound ah sas:
outbound pcp sas:
R2#show ip nhrp brief
Target Via NBMA Mode Intfc Claimed
10.0.0.1/32 10.0.0.1 200.1.1.1 dynamic Tu1 < >
R2#show l2tp
L2TP Tunnel and Session Information Total tunnels 1 sessions 1
LocTunID RemTunID Remote Name State Remote Address Sessn L2TP Class/
Count VPDN Group
102810956 1059798518 R1 est 1.1.1.1 1 l2tp_default_cl
LocID RemID TunID Username, Intf/ State Last Chg Uniq ID
Vcid, Circuit
2759286366 988304820 102810956 1, Et0/3 est 01:35:52 0
R2#show interfaces tunnel 1
Tunnel1 is up, line protocol is up
Hardware is Tunnel
Internet address is 10.0.0.2/30
MTU 17912 bytes, BW 100 Kbit/sec, DLY 50000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation TUNNEL, loopback not set
Keepalive not set
Tunnel linestate evaluation up
Tunnel source 50.1.1.1 (Ethernet0/0)
Tunnel Subblocks:
src-track:
Tunnel1 source tracking subblock associated with Ethernet0/0
Set of tunnels with source Ethernet0/0, 1 member (includes iterators), on interface <OK>
Tunnel protocol/transport multi-GRE/IP
Key 0x32, sequencing disabled
Checksumming of packets disabled
Tunnel TTL 255, Fast tunneling enabled
Tunnel transport MTU 1472 bytes
Tunnel transmit bandwidth 8000 (kbps)
Tunnel receive bandwidth 8000 (kbps)
Tunnel protection via IPSec (profile "PR-IPSEC")
Last input 00:02:37, output never, output hang never
Last clearing of "show interface" counters 00:12:47
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/0 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
32 packets input, 3228 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
36 packets output, 4173 bytes, 0 underruns
0 output errors, 0 collisions, 0 interface resets
0 unknown protocol drops
0 output buffer failures, 0 output buffers swapped out
おまけ
DMVPNでは、トンネル関連部分のルート作成には、スタティックルートではなく、ルーティングプロトコルが使われるのが通常。せっかくなので、本環境にて、スタティックルートではなく、EIGRPを利用したときの設定を下記。
R1
router eigrp 1
network 1.1.1.1 0.0.0.0
network 10.0.0.0 0.0.0.3
ip route 0.0.0.0 0.0.0.0 200.1.1.254
R2
interface Tunnel1
no ip split-horizon eigrp 1
router eigrp 1
network 2.2.2.2 0.0.0.0
network 10.0.0.0 0.0.0.3
ip route 0.0.0.0 0.0.0.0 50.1.1.254
DMVPNは新たなネットワークが追加された時に、Hub設定の修正不要が特徴である。そういった意味では、”network 10.0.0.0 0.0.0.3”ではなく、
network 10.0.0.0 0.0.0.255
などとしておくのが通常であろう。
EOF