Hi all,
Working on setting up IKEv2 on my ER4 and have been through the existing threads on the subject on this forum, and haven't been able to figure it out. I have OpenVPN working fine, but wanted to get IKEv2 running as well as a secondary option / something that might be able to take advantage of HW offloading.
First off: my setup is a home environment, not a corporate setup with many users. My use-case is remote client (i.e. me and my laptop) wishing to VPN back to my apartment to access local resources (#1) and perhaps also route all Internet traffic (#2). I've set up two OpenVPN profiles to achieve that effect, but haven't gotten IKEv2 working.
So far I have managed to get to the point where my remote machine (Windows 10) can authenticate using a machine certificate against the ER4's StrongSwan server. However, I think something is wrong in my firewall or configuration at this point as I think the wrong routes are being installed and/or there is a firewall mistake.
My network setup is currently pretty "dumb", it is just a single 172.16.1.1/24 on eth3 as LAN and DHCP on eth0 as WAN. OpenVPN uses 172.16.1.50/24 and pushes a route to 172.16.1.0/24 and seems to behave itself. Optimally, for this basic configuration, I'd like to get my IKEv2 tunnel either doing a similar setup where it's 172.16.x.0/24 and pushes a route to LAN, or as I have seen some configs here do, it simply allocates IP addresses out of DHCP range to the VPN clients from the 172.16.1.1/24 space.
My StrongSwan config is currently as follows, placed in ipsec.conf:
root@ubnt:/home/ubnt# cat /config/auth/ipsec/ipsec.conf
# Custom StrongSwan IPSec Configuration File
#
# Resources:
# Digital Ocean IKEv2 VPN Ubuntu 16.04 Guide
# General Setup
config setup
# Configure Logging
charondebug="ike 2, cfg 2, dmn 2, knl 1"
uniqueids=no
ca myCA
cacert=/config/auth/ipsec/ca.crt
auto=add
conn split
# Generic Parameters
auto=add
compress=no
ikelifetime=60m
keylife=20m
rekeymargin=3m
keyingtries=1
keyexchange=ikev2
type=tunnel
fragmentation=yes
ike=aes256-sha256-modp2048,aes256-sha1-modp1024!
esp=aes256-sha256,aes256-sha1!
mobike=yes
# Dead-Peer / Cleanup
dpdaction=clear
dpddelay=90s
rekey=no
# Left (Local Settings)
left=%any
leftid=@apt.xxxxxxxxx.yyy
leftsubnet=172.16.1.0/24
leftcert=/config/auth/ipsec/edgerouter4.crt
leftsendcert=ifasked
leftfirewall=yes
# Right (Remote Settings)
# Allow access from any IP address.
right=%any
rightid=%any
rightsourceip=172.16.40.0/24
# rightsourceip=172.16.1.201-172.16.1.219
# rightsubnet=172.16.1.0/24
rightdns=172.16.1.1
# rightauth=eap-mschapv2
rightsendcert=never
eap_identity=%identity
You can see I was playing with various rightsourciep/rightsubnet options...
And (I think) the relevant UBNT configs:
ubnt@ubnt# show vpn
ipsec {
auto-firewall-nat-exclude disable
include-ipsec-conf /config/auth/ipsec/ipsec.conf
include-ipsec-secrets /config/auth/ipsec/ipsec.secrets
ipsec-interfaces {
interface eth0
}
nat-networks {
allowed-network 0.0.0.0/0 {
}
}
nat-traversal enable
}
ubnt@ubnt# show firewall
all-ping enable
broadcast-ping disable
ipv6-receive-redirects disable
ipv6-src-route disable
ip-src-route disable
log-martians enable
name WAN_IN {
default-action drop
description "WAN to internal"
rule 10 {
action accept
description "Allow established/related"
state {
established enable
related enable
}
}
rule 20 {
action drop
description "Drop invalid state"
state {
invalid enable
}
}
}
name WAN_LOCAL {
default-action drop
description "WAN to router"
rule 10 {
action accept
description "Allow established/related"
state {
established enable
related enable
}
}
rule 20 {
action drop
description "Drop invalid state"
state {
invalid enable
}
}
rule 30 {
action accept
description OpenVPN
destination {
port 1194
}
protocol udp
}
rule 40 {
action accept
description ike
destination {
port 500
}
log disable
protocol udp
}
rule 50 {
action accept
description esp
log disable
protocol esp
}
rule 60 {
action accept
description nat-t
destination {
port 4500
}
log disable
protocol udp
}
rule 70 {
action accept
description l2tp
destination {
port 1701
}
ipsec {
match-ipsec
}
log disable
protocol udp
}
}
receive-redirects disable
send-redirects enable
source-validation disable
syn-cookies enable
I feel like it's something on the strongswan side; several forum posts have had users set a global iptables command to allow for ipv4 forwarding or similar; I'm not sure how to do that / if that's a good idea in the context of the Ubiquiti routing platform.
And a log of a IKEv2 connection from swanctl:
root@ubnt:/home/ubnt# swanctl --log
09[NET] received packet: from client.ip.address[500] to edgerouter.ip.address[500] (632 bytes)
09[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(FRAG_SUP) N(NATD_S_IP) N(NATD_D_IP) V V V V ]
09[ENC] received unknown vendor ID: [redacted]
09[ENC] received unknown vendor ID: [redacted]
09[ENC] received unknown vendor ID: [redacted]
09[ENC] received unknown vendor ID: [redacted]
09[IKE] client.ip.address is initiating an IKE_SA
09[IKE] remote host is behind NAT
09[ENC] generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(FRAG_SUP) N(MULT_AUTH) ]
09[NET] sending packet: from edgerouter.ip.address[500] to client.ip.address[500] (448 bytes)
11[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (580 bytes)
11[ENC] parsed IKE_AUTH request 1 [ EF ]
11[ENC] received fragment #1 of 6, waiting for complete IKE message
10[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (580 bytes)
10[ENC] parsed IKE_AUTH request 1 [ EF ]
10[ENC] received fragment #2 of 6, waiting for complete IKE message
13[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (580 bytes)
13[ENC] parsed IKE_AUTH request 1 [ EF ]
13[ENC] received fragment #3 of 6, waiting for complete IKE message
07[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (580 bytes)
07[ENC] parsed IKE_AUTH request 1 [ EF ]
07[ENC] received fragment #4 of 6, waiting for complete IKE message
16[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (580 bytes)
16[ENC] parsed IKE_AUTH request 1 [ EF ]
16[ENC] received fragment #5 of 6, waiting for complete IKE message
06[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (468 bytes)
06[ENC] parsed IKE_AUTH request 1 [ EF ]
06[ENC] received fragment #6 of 6, reassembling fragmented IKE message
06[ENC] parsed IKE_AUTH request 1 [ IDi CERT CERTREQ AUTH N(MOBIKE_SUP) CPRQ(ADDR DNS NBNS SRV ADDR6 DNS6 SRV6) SA TSi TSr ]
06[IKE] received cert request for "C[redacted]"
06[IKE] received 46 cert requests for an unknown ca
06[IKE] received end entity cert [redacted]"
06[CFG] looking for peer configs matching edgerouter.ip.address[%any]...client.ip.address[[redacted]]
06[CFG] selected peer config 'split'
06[CFG] using certificate "[redacted]"
06[CFG] using trusted ca certificate "[redacted]"
06[CFG] checking certificate status of "[redacted]"
06[CFG] certificate status is not available
06[CFG] reached self-signed root ca with a path length of 0
06[IKE] authentication of '[redacted]' with RSA signature successful
06[IKE] peer supports MOBIKE
06[IKE] authentication of 'edgerouter.domain.name' (myself) with RSA signature successful
06[IKE] IKE_SA split[2] established between edgerouter.ip.address[edgerouter.domain.name]...client.ip.address[[redacted]]
06[IKE] sending end entity cert "[redacted]"
06[IKE] peer requested virtual IP %any
06[CFG] reassigning offline lease to '[redacted]'
06[IKE] assigning virtual IP 172.16.40.1 to peer '[redacted]'
06[IKE] peer requested virtual IP %any6
06[IKE] no virtual IP found for %any6 requested by '[redacted]'
06[IKE] CHILD_SA split{2} established with SPIs c1afb32a_i aa230b1e_o and TS 172.16.1.0/24 === 172.16.40.1/32
06[ENC] generating IKE_AUTH response 1 [ IDr CERT AUTH CPRP(ADDR DNS) SA TSi TSr N(MOBIKE_SUP) N(ADD_4_ADDR) N(ADD_4_ADDR) ]
06[ENC] splitting IKE message with length of 1776 bytes into 4 fragments
06[ENC] generating IKE_AUTH response 1 [ EF ]
06[ENC] generating IKE_AUTH response 1 [ EF ]
06[ENC] generating IKE_AUTH response 1 [ EF ]
06[ENC] generating IKE_AUTH response 1 [ EF ]
06[NET] sending packet: from edgerouter.ip.address[4500] to client.ip.address[62939] (532 bytes)
06[NET] sending packet: from edgerouter.ip.address[4500] to client.ip.address[62939] (532 bytes)
06[NET] sending packet: from edgerouter.ip.address[4500] to client.ip.address[62939] (532 bytes)
06[NET] sending packet: from edgerouter.ip.address[4500] to client.ip.address[62939] (388 bytes)
08[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (80 bytes)
08[ENC] parsed INFORMATIONAL request 2 [ D ]
08[IKE] received DELETE for ESP CHILD_SA with SPI aa230b1e
08[IKE] closing CHILD_SA split{2} with SPIs c1afb32a_i (335 bytes) aa230b1e_o (0 bytes) and TS 172.16.1.0/24 === 172.16.40.1/32
08[IKE] sending DELETE for ESP CHILD_SA with SPI c1afb32a
08[IKE] CHILD_SA closed
08[ENC] generating INFORMATIONAL response 2 [ D ]
08[NET] sending packet: from edgerouter.ip.address[4500] to client.ip.address[62939] (80 bytes)
13[NET] received packet: from client.ip.address[62939] to edgerouter.ip.address[4500] (80 bytes)
13[ENC] parsed INFORMATIONAL request 3 [ D ]
13[IKE] received DELETE for IKE_SA split[2]
13[IKE] deleting IKE_SA split[2] between edgerouter.ip.address[edgerouter.domain.name]...client.ip.address[[redacted]]
13[IKE] IKE_SA deleted
13[ENC] generating INFORMATIONAL response 3 [ ]
13[NET] sending packet: from edgerouter.ip.address[4500] to client.ip.address[62939] (80 bytes)
13[CFG] lease 172.16.40.1 by '[redacted]' went offline
Windows route with IKEv2:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.12 50
edgerouter.wan.ip 255.255.255.255 192.168.0.1 192.168.0.12 51
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
127.255.255.255 255.255.255.255 On-link 127.0.0.1 331
172.16.0.0 255.255.0.0 On-link 172.16.40.1 36
172.16.40.1 255.255.255.255 On-link 172.16.40.1 291
172.16.255.255 255.255.255.255 On-link 172.16.40.1 291
192.168.0.0 255.255.255.0 On-link 192.168.0.12 306
192.168.0.12 255.255.255.255 On-link 192.168.0.12 306
192.168.0.255 255.255.255.255 On-link 192.168.0.12 306
224.0.0.0 240.0.0.0 On-link 127.0.0.1 331
224.0.0.0 240.0.0.0 On-link 192.168.0.12 306
224.0.0.0 240.0.0.0 On-link 172.16.40.1 291
255.255.255.255 255.255.255.255 On-link 127.0.0.1 331
255.255.255.255 255.255.255.255 On-link 192.168.0.12 306
255.255.255.255 255.255.255.255 On-link 172.16.40.1 291
===========================================================================