Hello all,I would like to connect a NetBSD client to a remote LAN via IPSEC. Unfortunately, I am stuck at a very early point and would like to know if I am making a basic mistake or if I am expecting something from NetBSD that it cannot do.
1) Network Topology [NetBSD-Client IP 192.168.2.177] [Windows-Client IP 192.168.2.176] | | | | (==================== LAN 192.168.2.0/24 ====================) | | ['local' Router/NAT IP 192.168.2.254 / external IP 222.222.222.222] | | (=========================== WAN ============================) | | ['remote' Router/NAT IP 192.168.1.254 / external IP 111.111.111.111] | | (==================== LAN 192.168.1.0/24 ====================) | | [Server IP 192.168.1.1] 2) Remote Endpoint SpecThe 'remote' router is a FritzBox 7490, which is the IPSEC access point. According to the manufacturer, the FritzBox supports:
- VPN connections according to the IPSec standard with ESP, IKEv1 and Pre-Shared Keys. Authentication Header (AH) and Perfect Forward Security (PFS) are not supported.
- Supported IPSec algorithms for IKE phase 1:Encryption methods: AES with 256, 192, 128 bits, Triple-DES with 168 bits or DES with 56 bits.
Hash algorithm: SHA2-512, SHA1 or MD5-96The FRITZ!Box initially uses 1024 bits (DH group 2) for key exchange via Diffie-Hellman. However, it subsequently also accepts 768, 1536, 2048 and 3072 bits (DH group 1, 5, 14 and 15).
- Supported IPSec algorithms for IKE phase 2:Encryption methods: AES with 256, 192, 128 bits, Triple-DES with 168 bits or DES with 56 bits.
Hash algorithm: SHA2-512, SHA1 or MD5-96 Diffie-Hellman group is determined by IKE phase 1 Compression: none 3) Configuration For the client configuration, I have essentially orientated myself on: https://www.netbsd.org/docs/network/ipsec/rasvpn.html#nat_t FILE: /etc/racoon/racoon.conf: ``` path pre_shared_key "/etc/racoon/psk.txt" ; log debug2; remote anonymous { exchange_mode main,base,aggressive; my_identifier address 111.111.111.111 nat_traversal force; ike_frag on; esp_frag 540; dpd_delay 20; mode_cfg on; lifetime time 24 hour ; # sec,min,hour script "/etc/racoon/phase1-up.sh" phase1_up; script "/etc/racoon/phase1-down.sh" phase1_down; proposal { encryption_algorithm aes; hash_algorithm sha1; authentication_method xauth_psk_client; dh_group 2 ; } xauth_login "user"; proposal_check strict; } sainfo anonymous { pfs_group 2; lifetime time 12 hour ; encryption_algorithm aes ; authentication_algorithm hmac_sha1, hmac_md5 ; compression_algorithm deflate ; } ``` FILE: /etc/racoon/psk.txt: ``` 111.111.111.111 myshareds3cre7 user myxau7hp4ssw0rd ``` 4) Test EnvironmentI am using a NetBSD 9.2_STABLE with a custom kernel that has IPSEC_DEBUG enabled.
``` armv7# uname -aNetBSD armv7 9.2_STABLE NetBSD 9.2_STABLE (GENERIC) #0: Mon Jun 7 07:17:03 CEST 2021 mpeterma@x230Mk10.local:/tank/dev/netbsd/9-STABLE/obj/sys/arch/evbarm/compile/GENERIC evbarm
``` ``` armv7# sysctl -a|grep ipsec net.inet.ipsec.def_policy = 1 net.inet.ipsec.esp_trans_deflev = 1 net.inet.ipsec.esp_net_deflev = 1 net.inet.ipsec.ah_trans_deflev = 1 net.inet.ipsec.ah_net_deflev = 1 net.inet.ipsec.ah_cleartos = 1 net.inet.ipsec.ah_offsetmask = 0 net.inet.ipsec.dfbit = 2 net.inet.ipsec.ecn = 0 net.inet.ipsec.debug = 1 net.inet.ipsec.ipip_spoofcheck = 1 net.inet.ipsec.enabled = 1 net.inet.ipsec.used = 1 net.inet.ipsec.ah_enable = 1 net.inet.ipsec.esp_enable = 1 net.inet.ipsec.ipcomp_enable = 1 net.inet.ipsec.crypto_support = 0 net.inet.ipsec.test_replay = 0 net.inet.ipsec.test_integrity = 0 net.inet6.ipsec6.def_policy = 1 net.inet6.ipsec6.esp_trans_deflev = 1 net.inet6.ipsec6.esp_net_deflev = 1 net.inet6.ipsec6.ah_trans_deflev = 1 net.inet6.ipsec6.ah_net_deflev = 1 net.inet6.ipsec6.ecn = 0 net.inet6.ipsec6.debug = 1 net.inet6.ipsec6.enabled = 1 net.inet6.ipsec6.used = 1 ``` 5) Test Execution Starting racoon in foreground to get debug log: ``` armv7# racoon -dddddd -F -f /etc/racoon/racoon.conf Foreground mode.2021-06-08 07:29:22: INFO: @(#)ipsec-tools cvs (http://ipsec-tools.sourceforge.net) 2021-06-08 07:29:22: INFO: @(#)This product linked OpenSSL 1.1.1k 25 Mar 2021 (http://www.openssl.org/) 2021-06-08 07:29:22: INFO: Reading configuration from "/etc/racoon/racoon.conf"
2021-06-08 07:29:22: DEBUG: call pfkey_send_register for AH 2021-06-08 07:29:22: DEBUG: call pfkey_send_register for ESP 2021-06-08 07:29:22: DEBUG: call pfkey_send_register for IPCOMP 2021-06-08 07:29:22: DEBUG: reading config file /etc/racoon/racoon.conf 2021-06-08 07:29:22: DEBUG2: lifetime = 86400 2021-06-08 07:29:22: DEBUG2: lifebyte = 0 2021-06-08 07:29:22: DEBUG2: encklen=128 2021-06-08 07:29:22: DEBUG2: p:1 t:1 2021-06-08 07:29:22: DEBUG2: AES-CBC(7) 2021-06-08 07:29:22: DEBUG2: SHA(2) 2021-06-08 07:29:22: DEBUG2: 1024-bit MODP group(2) 2021-06-08 07:29:22: DEBUG2: pre-shared key(1) 2021-06-08 07:29:22: DEBUG2: 2021-06-08 07:29:22: DEBUG2: Etype mismatch: got 2, expected 4. 2021-06-08 07:29:22: DEBUG2: Etype mismatch: got 1, expected 4. 2021-06-08 07:29:22: DEBUG: hmac(modp1024) 2021-06-08 07:29:22: DEBUG: encryption(aes)2021-06-08 07:29:22: DEBUG: no check of compression algorithm; not supported in sadb message. 2021-06-08 07:29:22: DEBUG: getsainfo params: loc='ANONYMOUS' rmt='ANONYMOUS' peer='NULL' client='NULL' id=0
2021-06-08 07:29:22: DEBUG2: parse successed. 2021-06-08 07:29:22: DEBUG: open /var/run/racoon.sock as racoon management. 2021-06-08 07:29:22: INFO: 192.168.2.177[500] used as isakmp port (fd=7) 2021-06-08 07:29:22: INFO: 192.168.2.177[4500] used for NAT-T 2021-06-08 07:29:22: INFO: 192.168.2.177[4500] used as isakmp port (fd=8) 2021-06-08 07:29:22: INFO: 127.0.0.1[500] used as isakmp port (fd=9) 2021-06-08 07:29:22: INFO: 127.0.0.1[4500] used for NAT-T 2021-06-08 07:29:22: INFO: 127.0.0.1[4500] used as isakmp port (fd=10) 2021-06-08 07:29:22: DEBUG: pk_recv: retry[0] recv() 2021-06-08 07:29:22: DEBUG: got pfkey X_SPDDUMP message 2021-06-08 07:29:22: DEBUG2: xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx2021-06-08 07:29:22: DEBUG: pfkey X_SPDDUMP failed: No such file or directory
``` Start connection: ``` armv7# racoonctl vc 111.111.111.111 ``` Monitoring racoon: ```2021-06-08 07:31:18: DEBUG2: getph1: start 2021-06-08 07:31:18: DEBUG2: local: 192.168.2.177[0] 2021-06-08 07:31:18: DEBUG2: remote: 111.111.111.111[0] 2021-06-08 07:31:18: DEBUG2: no match 2021-06-08 07:31:18: [111.111.111.111] DEBUG2: Checking remote conf "anonymous" anonymous.
2021-06-08 07:31:18: DEBUG2: enumrmconf: "anonymous" matches.2021-06-08 07:31:18: [111.111.111.111] DEBUG: configuration "anonymous" selected. 2021-06-08 07:31:18: INFO: accept a request to establish IKE-SA: 111.111.111.111 2021-06-08 07:31:18: DEBUG: === 2021-06-08 07:31:18: INFO: initiate new phase 1 negotiation: 192.168.2.177[500]<=>111.111.111.111[500]
2021-06-08 07:31:18: INFO: begin Identity Protection mode.2021-06-08 07:31:18: DEBUG: new cookie: xxxxxxxxxxxxxxxxxxx 2021-06-08 07:31:18: DEBUG: add payload of len 56, next type 13
2021-06-08 07:31:18: DEBUG: add payload of len 16, next type 13 2021-06-08 07:31:18: DEBUG: add payload of len 16, next type 13 2021-06-08 07:31:18: DEBUG: add payload of len 16, next type 132021-06-08 07:31:18: DEBUG: add payload of len 20, next type 13
2021-06-08 07:31:18: DEBUG: add payload of len 16, next type 02021-06-08 07:31:18: DEBUG: 192 bytes from 192.168.2.177[500] to 111.111.111.111[500]
2021-06-08 07:31:18: DEBUG: sockname 192.168.2.177[500] 2021-06-08 07:31:18: DEBUG: send packet from 192.168.2.177[500] 2021-06-08 07:31:18: DEBUG: send packet to 111.111.111.111[500]2021-06-08 07:31:18: DEBUG: 1 times of 192 bytes message will be sent to 111.111.111.111[500]
2021-06-08 07:31:18: DEBUG:[hex data cleared as it may contain private information]
2021-06-08 07:31:18: DEBUG: resend phase1 packet xxxxxxxxxxxxxxx:xxxxxxxxxxxxxxxxxxx
2021-06-08 07:31:18: DEBUG: [11] admin connection is polling events 2021-06-08 07:31:18: DEBUG: [11] admin connection established 2021-06-08 07:31:22: DEBUG: [11] admin connection released2021-06-08 07:31:28: DEBUG: 192 bytes from 192.168.2.177[500] to 111.111.111.111[500]
2021-06-08 07:31:28: DEBUG: sockname 192.168.2.177[500] 2021-06-08 07:31:28: DEBUG: send packet from 192.168.2.177[500] 2021-06-08 07:31:28: DEBUG: send packet to 111.111.111.111[500]2021-06-08 07:31:28: DEBUG: 1 times of 192 bytes message will be sent to 111.111.111.111[500]
...2021-06-08 07:32:08: ERROR: phase1 negotiation failed due to time up. xxxxxxxxxxxxx:xxxxxxxxxxxxxxx
``` 6) Observations / SummaryIt looks like I'm not getting any response at all from the remote endpoint. Therefore, racoon tries to send the phase1 packet several times and finally gives up via a timeout.
It might be important to mention that a Windows client with the Shrew Soft VPN client on the same LAN as the NetBSD client gets a working VPN connection to the same endpoint.
I am trying to clarify the following questions:1) Does my configuration match the spec of the endpoint, or have I missed something fundamental? Especially for the fact that the Fritzbox does not support authentication headers, I do not know how to check this part in my racoon configuration.
2) Is NAT-T known to work without problems in NetBSD 9.2? I have read some mailing list posts, also from times when this was apparently not yet supported / broken / questionable for patent reasons. Where options(8) mentions under IPSEC_DEBUG that NAT-T is supported.
3) Switching to a kernel with IPSEC_DEBUG didn't seem to do anything - I don't see any additional IPSEC messages in the logfiles during my connection attempts. Of course, this could also mean that I didn't even get as far as running anything through ipsec's kernel engines.
4) What "classic" errors does one usually make in such a setup as above and how can I check this? As I said - I'm sure my racoon.conf is far from finished. But the fact that no response comes back (or doesn't find its way back - NAT-T?) irritates me a lot.
I would be very happy if someone who knows more about this could give me a few tips. The IPSEC topic is relatively new to me.
Many greetings Matthias
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature