1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

CenturyルーターにてNAT環境でのL2TPv3 Over IPsec

Posted at

CenturyルーターにてNAT環境でのL2TPv3 Over IPsec

CenturyルーターNXR-230を用いて、NAT環境でのL2TPv3 Over IPsecを実現したときの記録である。

ネットワーク

image.png

  • ClientはDHCPによりIPアドレスを取得
  • NATルーターが存在
  • Serverは固定IPアドレスを持つ
  • 末端のPCどうしが同一ネットワークセグメント

Configuration(設定)

先日の記事「CenturyルーターでIPsec」同様、本家サイト「2. L2TPv3応用設定」を試したが、動作せず。各種トライをして、動作した設定が下記となる(未関連部分は省略)。設定内にポイントとなるコメント追加。

Client

hostname Client
!
ipsec nat-traversal enable # NATトラバーサルをON
!
l2tpv3 udp path-mtu-discovery
l2tpv3 hostname nxr-client # ホスト名
l2tpv3 router-id 192.168.10.10 # ルーターID
!
ipsec local policy 1 # IPsecローカルポリシー
 address ip 
 self-identity fqdn test # IPsecで用いるidentity
!
ipsec isakmp policy 1 # IKEポリシー
 authentication pre-share himitsu # 事前共有鍵
 hash sha256
 encryption aes128
 group 2
 isakmp-mode aggressive
 remote address ip aaa.bbb.ccc.201 # Server IPアドレス
 remote identity fqdn test # Server identity
 local policy 1 # 適用するIPsecローカルポリシー
!
ipsec tunnel policy 1 # IPsecトンネルポリシー
 set transform esp-aes128 esp-sha256-hmac
 set key-exchange isakmp 1 # 適用するIKEポリシー
 match address ipsecACL # IPsecを適用するIPアドレス(後述)
!
l2tpv3 tunnel 1 # L2TPv3トンネル定義
 tunnel address 192.168.10.20 # 相手先IPアドレス
 tunnel hostname nxr-server # 相手先ホスト名
 tunnel router-id 192.168.10.20 # 相手先ルーターID
!
l2tpv3 xconnect 1 # L2Tv3接続情報
 tunnel 1
 xconnect ethernet 0 # 適用する物理I/F
 xconnect end-id 1
 retry-interval 30
 ip tcp adjust-mss auto
!
interface tunnel 0 # IPsecトンネルI/F定義
 ip address 192.168.10.10/32 # IPアドレス(ルーターIDと同一にすることがポイントの様子)
 tunnel mode ipsec ipv4 # IPsecトンネル
 tunnel protection ipsec policy 1 # 適用するIPsecトンネルポリシー
!
interface ethernet 0 # L2TPv3の対象となる物理I/F
 no ip address
!
interface ethernet 1 # WAN側IPアドレス
 ip address dhcp # DHCPによりIPアドレス取得
 ip masquerade # IPマスカレード
 ipsec policy 1 # 適用するIPsecポリシー
!
ip route 192.168.10.20/32 tunnel 0 # IPsecの相手先へのルートにトンネルを指定
!
ipsec access-list ipsecACL ip any any # IPsecの対象IPアドレス

Server

hostname Server
!
ipsec nat-traversal enable # NATトラバーサルをON
!
l2tpv3 udp path-mtu-discovery
l2tpv3 hostname nxr-server # ホスト名
l2tpv3 router-id 192.168.10.20 # ルーターID
!
ipsec local policy 1 # IPsecローカルポリシー
 address ip 
 self-identity fqdn test # IPsecで用いるidentity
!
ipsec isakmp policy 1 # IKEポリシー
 authentication pre-share himitsu # 事前共有鍵
 hash sha256
 encryption aes128
 group 2
 isakmp-mode aggressive
 remote address ip any # 相手先IPアドレス(Server側なので不定(any))
 remote identity fqdn test # Client identity
 local policy 1 # 適用するIPsecローカルポリシー
!
ipsec tunnel policy 1 # IPsecトンネルポリシー
 set transform esp-aes128 esp-sha256-hmac
 set key-exchange isakmp 1 # 適用するIKEポリシー
 match address ipsecACL # IPsecを適用するIPアドレス(後述)
!
l2tpv3 tunnel 1 # L2TPv3トンネル定義
 tunnel address 192.168.10.10 # 相手先IPアドレス
 tunnel hostname nxr-client # 相手先ホスト名
 tunnel router-id 192.168.10.10 # 相手先ルーターID
!
l2tpv3 xconnect 1 # L2Tv3接続情報
 tunnel 1
 xconnect ethernet 0 # 適用する物理I/F
 xconnect end-id 1
 retry-interval 30
 ip tcp adjust-mss auto
!
interface tunnel 0 # IPsecトンネルI/F定義
 ip address 192.168.10.20/32 # IPアドレス(ルーターIDと同一にすることがポイントの様子)
 tunnel mode ipsec ipv4 # IPsecトンネル
 tunnel protection ipsec policy 1 # 適用するIPsecトンネルポリシー
!
interface ethernet 0 # L2TPv3の対象となる物理I/F
 no ip address
!
interface ethernet 1 # WAN側IPアドレス
 ip address aaa.bbb.ccc.201/24 # 固定IPアドレス
 ip masquerade # IPマスカレード
 ipsec policy 1 # 適用するIPsecポリシー
!
ip route 0.0.0.0/0 aaa.bbb.ccc.1 # デフォルトルート
ip route 192.168.10.10/32 tunnel 0 # IPsecの相手先へのルートにトンネルを指定
!
ipsec access-list ipsecACL ip any any # IPsecの対象IPアドレス

Status

IPsecの状況である(Client)。

Client#show ipsec sa
src 192.168.200.19 dst aaa.bbb.ccc.201
	proto esp spi 0xbeaf66a1 reqid 16385 mode tunnel
	interface tunnel0
	replay-check enable replay-window 32 flag 20
	auth hmac(sha256) 0x465888810300c585bea5c3967a2cac425c8e976ee263ef5a4dfc
4e400492f5be
	enc cbc(aes) 0x4433fbeb719ad12029107268c7ebf201
	encap type espinudp sport 4500 dport 4500 addr 0.0.0.0
	sel src 0.0.0.0/0 dst 0.0.0.0/0 interface tunnel0 
src aaa.bbb.ccc.201 dst 192.168.200.19
	proto esp spi 0x269d553a reqid 16385 mode tunnel
	interface tunnel0
	replay-check enable replay-window 32 flag 20
	auth hmac(sha256) 0x6560bcee01efe3f74f17a225dac2f1988e18e1d2667147913790
001f15e12ae8
	enc cbc(aes) 0x276229953bd47385e66bae6285f85f00
	encap type espinudp sport 4500 dport 4500 addr 0.0.0.0
	sel src 0.0.0.0/0 dst 0.0.0.0/0 interface tunnel0 

L2TPv3の状況である(Client)。

Client#show l2tpv3 tunnel detail 

Tunnel Information Total tunnels 1

Tunnel id 3844543436 is up, remote id is 1646783082, 1 active sessions
  Tunnel state is established, time since change 00:08:25
  Tunnel transport is IP(115)
  Interop Mode is IETF(RFC3931)
  Remote tunnel name is nxr-server
    Internet Address 192.168.10.20, port0
  Local tunnel name is nxr-client
  10 packets sent, 8 received
  449 bytes sent, 221 received
  4 sent errors, 0 received errors
  Control Ns 8, Nr 8
  Local RWS 4, Remote RWS 4
  Retransmission count 0, timeout 1, max 8 seconds
  ZLB ACKs sent 6, received 6
  Session attempt 1, est 1, fail 0

「Tunnel state is established」により、L2TPv3が確立されていることがわかる。

EOF

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?