NEC IXのIKEv1 IPsec設定 両拠点 固定IPアドレス

スポンサーリンク

NEC IXルータで両拠点がグローバルIPを保有する場合のIKEv1 IPsec設定を紹介します。

設定まとめ

コマンド一覧

IKEv1 IPsecに関連するコマンド一覧は以下の通りです。

ip access-list <acl_name> permit ip src <prefix> dest <prefix>
ike proposal <ike_proposal_name> encryption <encryption> hash <hash>
ike policy ike-policy peer <peer_addr> key <password> <ike_proposal_name>
ipsec autokey-proposal <ipsec_proposal_name> [<esp>...] [<ah>...]
ipsec autokey-map <policy_map_name> <acl_name> peer <peer_addr> <ipsec_proposal_name>
ipsec local-id <policy_map_name> <local_private_prefix>
ipsec remote-id <policy_map_name> <remote_private_prefix>
!
interface Tunnel0.0
  tunnel mode ipsec
  ip address <addr>
  ip tcp adjust-mss auto
  ipsec policy tunnel <policy_map_name> out
!
interface GigaEthernet0.0
  ip napt enable 
  ip napt static GigaEthernet0.0 50
  ip napt static GigaEthernet0.0 udp 500
  ip napt static GigaEthernet0.0 udp 4500  

IKE関連のパラメタ

事前共有鍵を用いて、IKE関連のパラメタを定義する構文は以下の通りです。暗号化とハッシュ値は対向機器と同じ値を設定する必要があります。

ike proposal <ike_proposal_name> encryption <encryption> hash <hash>
ike policy ike-policy peer <peer_addr> key <password> <ike_proposal_name>

設定例は以下の通りです。

ike proposal ikeprop encryption aes-256 hash sha2-256
ike policy ike-policy peer 200.0.20.20 key P@ssw0rd ikeprop

IPsec関連のパラメタ

IPsec間で疎通を許可するACLを定義します。

ip access-list <acl_name> permit ip src <prefix> dest <prefix>

自身と対向のIDを定義します。(分かりやすい運用を目指す意図で)慣例的には互いのプライベートアドレスを指定する事が多いですが、実は任意の値で差し支えございません。

ipsec local-id <policy_map_name> <local_private_prefix>
ipsec remote-id <policy_map_name> <remote_private_prefix>

IPsecで使用するAHおよび暗号化を指定します。

ipsec autokey-proposal <ipsec_proposal_name> [<esp>...] [<ah>...]
ipsec autokey-map <policy_map_name> <acl_name> peer <peer_addr> <ipsec_proposal_name>

設定例は以下の通りです。

ip access-list sec-list permit ip src any dest any
ipsec autokey-proposal secprop esp-aes-256 ah-md5
ipsec autokey-map ipsec-policy sec-list peer 200.0.20.20 secprop
ipsec local-id ipsec-policy 192.168.10.0/24
ipsec remote-id ipsec-policy 192.168.20.0/24

トンネル設定

以下のようにTunnelインターフェースを定義し、さらにパケットをトンネルを経由し始めたタイミングでIPsecが確立されます。

interface Tunnel0.0
  tunnel mode ipsec
  ip address <addr>
  ip tcp adjust-mss auto
  ipsec policy tunnel <policy_map_name> out
  no shutdown

Tunnelだけでは拠点間の疎通はできません。staticやBGPで適宜ルーティングを設定しましょう。以下はstatic routeを定義する構文です。

ip route <prefix> Tunnel0.0

NAT併用時の注意

NEC IXのNAPT service(インターネットからNEC IXへの接続許可)設定」で説明した通り、NAPTが設定されている状態ではNEC IXは自身へのパケットを破棄します。この破棄される挙動はIPsecに関するパケットも同様です。

以下のようにIPsecに関するパケットの受信を許可する設定が必要です。

protocol number 50(ESP)は明示的な許可なしに受信可能です。udp 4500はNATトラバーサルが必要な環境下のみ必要な設定です。

NEC IXのバージョンによってはudp500, udp4500が暗黙的に許可され、設定投入を省略する事もできます。

interface GigaEthernet0.0
  ip napt static GigaEthernet0.0 50
  ip napt static GigaEthernet0.0 udp 500
  ip napt static GigaEthernet0.0 udp 4500

動作確認

動作確認の構成

以下の環境で動作確認を行います。

+------------------+
|  Rocky Linux 8.5 |
|     host010      |
+-------+----------+
 ens224 | .10
        |
        | 192.168.10.0/24
        | 
   lan1 | .1 
+-------+----------+ 
|    NEC IX 2015   | 
|       R10        |
+-------+----------+
   lan2 | .10
        |
        | 200.0.10.0/24
        |
   eth0 | .1 
+-------+----------+ 
|    VyOS 1.4      | 
|    Internet      |
+-------+----------+
   eth1 | .1
        |
        | 200.0.20.0/24
        |
   lan2 | .20
+-------+----------+ 
|    NEC IX 2015   | 
|       R20        |
+-------+----------+
   lan1 | .1 
        |
        | 192.168.20.0/24
        | 
 ens224 | .20
+-------+----------+
|  Rocky Linux 8.5 |
|     host020      |
+------------------+

初期設定

IX2015の初期設定は以下の通りとします。設定はIPアドレスとデフォルトゲートウェイのみとします。検証シナリオの都合上、初期設定時点ではNATを設定していません。

R10 : NEC IX 2015
! NEC Portable Internetwork Core Operating System Software
! IX Series IX2105 (magellan-sec) Software, Version 10.2.34, RELEASE SOFTWARE
! Compiled Mar 26-Fri-2021 16:04:41 JST #2
! Current time Nov 23-Tue-2021 12:03:45 JST
!
hostname R10
timezone +09 00
!
logging buffered 8192
logging subsystem all warn
logging timestamp datetime
!
username admin password hash 63cA632c6fBB8D099804ed6eBc758b@ administrator
!
!
ip ufs-cache enable
ip route default 200.0.10.1
!
!
!
!
!
!
!       
!
!
telnet-server ip enable
!
!
!
device GigaEthernet0
!
device GigaEthernet1
!
interface GigaEthernet0.0
  ip address 200.0.10.10/24
  no shutdown
!
interface GigaEthernet1.0
  ip address 192.168.10.1/24
  no shutdown
!
interface Loopback0.0
  no ip address
!
interface Null0.0
  no ip address
R20 : NEC IX 2015
! NEC Portable Internetwork Core Operating System Software
! IX Series IX2105 (magellan-sec) Software, Version 8.10.11, RELEASE SOFTWARE
! Compiled Aug 02-Fri-2013 13:57:45 JST #2
! Current time Nov 23-Tue-2021 11:46:48 JST
!
!
hostname R20
timezone +09 00
!
!
!
username admin password hash 0C34240482 administrator
!
!
!
!
!
!
logging buffered 131072
logging subsystem all warn
logging timestamp datetime
!       
!
ip route default 200.0.20.1
!
!
!
!
!
!
!
!
!
!
telnet-server ip enable
!
!
!
!
!
!
!
!
!
device GigaEthernet0
!
device GigaEthernet1
!
interface GigaEthernet0.0
  ip address 200.0.20.20/24
  no shutdown
!
interface GigaEthernet1.0
  ip address 192.168.20.1/24
  no shutdown
!
interface Loopback0.0
  no ip address
!
interface Null0.0
  no ip address
Internet : VyOS1.4
set interfaces ethernet eth0 address '200.0.10.1/24'
set interfaces ethernet eth0 hw-id '00:50:56:90:8e:9d'
set interfaces ethernet eth1 address '200.0.20.1/24'
set interfaces ethernet eth1 hw-id '00:50:56:90:a2:8c'
set service ssh disable-host-validation
set system config-management commit-revisions '100'
set system conntrack modules ftp
set system conntrack modules h323
set system conntrack modules nfs
set system conntrack modules pptp
set system conntrack modules sip
set system conntrack modules sqlnet
set system conntrack modules tftp
set system console device ttyS0 speed '115200'
set system host-name 'vyos'
set system login user admin authentication encrypted-password '$6$cl1DIDt8CHJnLXst$zNkGlajjlSDirfSVdmFEkVfkvj3rxjayuu1RfzvuJQ.rNzJlb3s995/1HZX91nvW83ZvINnGvXBG6Z.sWVE7W/'
set system login user vyos authentication encrypted-password '$6$BLBE.ChYBI4ynui8$u2B.sTlyz1d.5GEjLyQKQmNRPN3kDHb3ynAzolORLLGOYe3up4u3vNg93QWk1DkOBbRNgkJJyYYVkrMofOFgw1'
set system login user vyos authentication plaintext-password ''
set system ntp server time1.vyos.net
set system ntp server time2.vyos.net
set system ntp server time3.vyos.net
set system syslog global facility all level 'info'
set system syslog global facility protocols level 'debug'

動作確認 (1) NAT無効環境でのIPsec

設定投入

IPsecを確立するための設定を入れます。

[R10:IX2015]
ip access-list sec-list permit ip src any dest any
ike proposal ikeprop encryption aes-256 hash sha2-256
ike policy ike-policy peer 200.0.20.20 key P@ssw0rd ikeprop
ipsec autokey-proposal secprop esp-aes-256 ah-md5
ipsec autokey-map ipsec-policy sec-list peer 200.0.20.20 secprop
ipsec local-id ipsec-policy 192.168.10.0/24
ipsec remote-id ipsec-policy 192.168.20.0/24
!
interface Tunnel0.0
  tunnel mode ipsec
  ip address 169.254.0.10/24
  ip tcp adjust-mss auto
  ipsec policy tunnel ipsec-policy out
  no shutdown
[R20:IX2015]
ip access-list sec-list permit ip src any dest any
ike proposal ikeprop encryption aes-256 hash sha2-256
ike policy ike-policy peer 200.0.10.10 key P@ssw0rd ikeprop
ipsec autokey-proposal secprop esp-aes-256 ah-md5
ipsec autokey-map ipsec-policy sec-list peer 200.0.10.10 secprop
ipsec local-id ipsec-policy 192.168.20.0/24
ipsec remote-id ipsec-policy 192.168.10.0/24
!
interface Tunnel0.0
  tunnel mode ipsec
  ip address 169.254.0.20/24
  ip tcp adjust-mss auto
  ipsec policy tunnel ipsec-policy out
  no shutdown

IPsec確立確認

IPsecが確立された事を確認します。IPsecが確立されるのは何らかの通信が開始されたタイミングですので、トンネル間のpingを実行します。

[R10:IX2015]
R10(config)# ping 169.254.0.20 count 3
PING 169.254.0.10 > 169.254.0.20 56 data bytes
64 bytes from 169.254.0.20: icmp_seq=1 ttl=64 time=1.102 ms
64 bytes from 169.254.0.20: icmp_seq=2 ttl=64 time=1.048 ms

--- 169.254.0.20 ping statistics ---
3 packets transmitted, 2 packets received, 33% packet loss
round-trip (ms)  min/avg/max = 1.048/1.075/1.102
R10(config)# 

IKEが確立された事を確認します。

[R10:IX2015]
R10(config)# show ike sa 
ISAKMP SA - 1 configured, 1 created
Local address is 200.0.10.10, port is 500
Remote address is 200.0.20.20, port is 500
  IKE policy name is ike-policy
  Direction is initiator
  Initiator's cookie is 0x090684abadd55a86
  Responder's cookie is 0x486fa0229c20dd82
  Exchange type is main mode
  State is established
  Authentication method is pre-shared
  Encryption algorithm is aes-256
  Hash algorithm is sha2-256
  DH group is modp768, lifetime is 28784 seconds
  #ph1 success: 1, #ph1 failure: 0
  #ph1 hash err: 0, #ph1 timeout: 0, #ph1 resend: 0
  #ph2 success: 1, #ph2 failure: 0
  #ph2 hash err: 0, #ph2 timeout: 0, #ph2 resend: 0

IPsecが確立された事を確認します。

[R10:IX2015]
R10(config)# show ipsec sa 
IPsec SA - 1 configured, 4 created
Interface is Tunnel0.0
  Key policy map name is ipsec-policy
    Tunnel mode, 4-over-4, autokey-map
    Local address is 200.0.10.10
    Remote address is 200.0.20.20
    Outgoing interface is GigaEthernet0.0
    Interface MTU is 1422, path MTU is 1500
    Inbound:
      AH, SPI is 0x95bb1938(2512066872)
        Transform is AH-HMAC-MD5-96
        Remaining lifetime is 28780 seconds
      ESP, SPI is 0x1bdc481f(467421215)
        Transform is ESP-AES-256
        Remaining lifetime is 28780 seconds
      Replay detection support is on
    Outbound:
      AH, SPI is 0x7249235a(1917395802)
        Transform is AH-HMAC-MD5-96
        Remaining lifetime is 28780 seconds
      ESP, SPI is 0x69418f0b(1765904139)
        Transform is ESP-AES-256
        Remaining lifetime is 28780 seconds
      Replay detection support is on
    Perfect forward secrecy is off
R10(config)# 

拠点間の疎通確認

拠点間となるhost010(192.168.10.10)とhost020(192.168.20.20)の間の疎通を確認します。拠点間で疎通可能なようにするにはIPsecの確立だけでなくルーティングの設定が必要です。

以下のように拠点間のルーティングを定義します。

[R10:IX2015]
ip route 192.168.20.0/24 Tunnel0.0
[R20:IX2015]
ip route 192.168.10.0/24 Tunnel0.0

host010(192.168.10.10)とhost020(192.168.20.20)の間で疎通可能である事を確認します。

[host010:RockyLinux8.5]
[root@host010 ~]# ping -c 3 192.168.20.20
PING 192.168.20.20 (192.168.20.20) 56(84) bytes of data.
64 bytes from 192.168.20.20: icmp_seq=1 ttl=62 time=1.87 ms
64 bytes from 192.168.20.20: icmp_seq=2 ttl=62 time=1.68 ms
64 bytes from 192.168.20.20: icmp_seq=3 ttl=62 time=1.78 ms

--- 192.168.20.20 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 1.680/1.775/1.865/0.083 ms

動作確認 (2) NAT有効環境でのIPsec

事前準備

R10, R20の双方でNATを有効にし、IPsecを再起動します。

[R10:IX2015]
interface GigaEthernet0.0
  ip napt enable 
  exit
!
clear ike sa 
clear ipsec sa 
[R20:IX2015]
interface GigaEthernet0.0
  ip napt enable 
  exit
!
clear ike sa 
clear ipsec sa 

トンネル間の疎通が不能になる事を確認します。

[R10:IX2015]
R10(config)# ping 169.254.0.20 count 3
PING 169.254.0.10 > 169.254.0.20 56 data bytes

--- 169.254.0.20 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

Stateが”negotiating”と表示されており、IKEの確立に失敗している事を確認します。

[R10:IX2015]
R10(config)# show ike sa 
ISAKMP SA - 1 configured, 1 created
Local address is 200.0.10.10, port is 500
Remote address is 200.0.20.20, port is 500
  IKE policy name is ike-policy
  Direction is initiator
  Initiator's cookie is 0x440c48be1285a584
  Responder's cookie is 0x0000000000000000
  Exchange type is main mode
  State is negotiating
R10(config)# 

udp500の受信許可

udp500の受信を許可する設定を入れます。なお、protocol number 50 (ESP)の受信許可の明示設定は要らないようです。

protocol number 50 (ESP)は暗黙的に許可される仕様ではないかと推測されます。

[R10:IX2015]
interface GigaEthernet0.0
  ip napt static GigaEthernet0.0 udp 500
[R20:IX2015]
interface GigaEthernet0.0
  ip napt static GigaEthernet0.0 udp 500

トンネル間の疎通を確認します。

[R10:IX2015]
R10(config)# ping 169.254.0.20 count 3
PING 169.254.0.10 > 169.254.0.20 56 data bytes
64 bytes from 169.254.0.20: icmp_seq=1 ttl=64 time=1.040 ms
64 bytes from 169.254.0.20: icmp_seq=2 ttl=64 time=0.870 ms

--- 169.254.0.20 ping statistics ---
3 packets transmitted, 2 packets received, 33% packet loss
round-trip (ms)  min/avg/max = 0.870/0.955/1.040
R10(config)# 

IKEが確立された事を確認します。

[R10:IX2015]
R10(config)# show ike sa 
ISAKMP SA - 1 configured, 1 created
Local address is 200.0.10.10, port is 500
Remote address is 200.0.20.20, port is 500
  IKE policy name is ike-policy
  Direction is initiator
  Initiator's cookie is 0x2aa270e9123302e7
  Responder's cookie is 0x2d2e969c91113c7f
  Exchange type is main mode
  State is established
  Authentication method is pre-shared
  Encryption algorithm is aes-256
  Hash algorithm is sha2-256
  DH group is modp768, lifetime is 28772 seconds
  #ph1 success: 1, #ph1 failure: 0
  #ph1 hash err: 0, #ph1 timeout: 0, #ph1 resend: 0
  #ph2 success: 1, #ph2 failure: 0
  #ph2 hash err: 0, #ph2 timeout: 0, #ph2 resend: 0
R10(config)# 

補足説明

デバッグ手法

0 created

“show ike sa”で”0 created”と表示されるのは、トンネルの確立すら試みていない事を表します。

R10(config)# show ike sa 
ISAKMP SA - 1 configured, 0 created
R10(config)# 

IPsecのトンネルの確立が開始されるのは通信が開始されたタイミングですので、何らかのパケットを流してみます。

R10(config)# ping 169.254.0.20 count 3
PING 169.254.0.10 > 169.254.0.20 56 data bytes

--- 169.254.0.20 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

通信を試みると”1 created”に変わった事が読み取れます。

R10(config)# show ike sa              
ISAKMP SA - 1 configured, 1 created
Local address is 200.0.10.10, port is 500
Remote address is 200.0.20.20, port is 500
  IKE policy name is ike-policy
  Direction is initiator
  Initiator's cookie is 0x504d783dbe9de9ff
  Responder's cookie is 0x0000000000000000
  Exchange type is main mode
  State is negotiating

デバッグの有効化

IKE SAに失敗している場合は、ログ出力を有効にしましょう。以下のコマンドでIKEとISAKMPに関するデバッグを有効にできます。

R10(config)# logging buffered 8192
R10(config)# logging subsystem ike debug 
R10(config)# ping 169.254.0.20 count 3
PING 169.254.0.10 > 169.254.0.20 56 data bytes

--- 169.254.0.20 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss
R10(config)# 

show loggingでIKEに関するログを確認できます。

R10(config)# show logging 

 <omitted>

2021/11/23 14:27:25  IKE.001: Begin IKE phase 1 negotiation, destination 200.0.20.20
2021/11/23 14:27:25  IKE.047: Initiator negotiation using Main mode
2021/11/23 14:27:25  IKE.044: Send payload, next type 1:SA, length 108
2021/11/23 14:27:25  IKE.044: Send payload, next type 13:Vendor ID, length 60
2021/11/23 14:27:25  IKE.044: Send payload, next type 0:NONE, length 20
2021/11/23 14:27:25  IKE.005: Send packet to 200.0.20.20, length 108
2021/11/23 14:27:25  IKE.006: Receive packet from 200.0.20.20, length 40
2021/11/23 14:27:25  IKE.009: Receive notification data from 200.0.20.20, type 14:NO-PROPOSAL-CHOSEN, protocol ISAKMP
2021/11/23 14:27:26  SEC.014: SA not found, drop packet, 169.254.0.10 > 169.254.0.20
2021/11/23 14:27:26  SEC.018: No SP for outbound packet, drop packet
2021/11/23 14:27:27  SEC.014: SA not found, drop packet, 169.254.0.10 > 169.254.0.20
2021/11/23 14:27:27  SEC.018: No SP for outbound packet, drop packet
R10(config)#  

“logging subsystem ike debug”コマンドはIKEだけでなくISAKMPに関するデバッグも有効になります。以下のようにISAKMPに関するログも出力されます。

R10(config)# show logging 

 <omitted>

2021/11/23 14:37:16  IKE.001: Begin IKE phase 2 negotiation, destination 200.0.20.20
2021/11/23 14:37:16  IKE.060: Send ID payload local type 4(ID_IPV4_ADDR_SUBNET) addr 192.168.10.0 mask 255.255.255.0, prot 0, port 0
2021/11/23 14:37:16  IKE.060: Send ID payload peer type 4(ID_IPV4_ADDR_SUBNET) addr 192.168.20.0 mask 255.255.255.0, prot 0, port 0
2021/11/23 14:37:16  IKE.005: Send packet to 200.0.20.20, length 220
2021/11/23 14:37:16  IKE.006: Receive packet from 200.0.20.20, length 92
2021/11/23 14:37:16  IKE.009: Receive notification data from 200.0.20.20, type 14:NO-PROPOSAL-CHOSEN, protocol ISAKMP
R10(config)#  
タイトルとURLをコピーしました