Android12或以上系统(IKEv2)

本文基于Sumsung One UI 5.1 (Android13)系统编写。

组网需求

通过Android12或以上系统客户端(IKEv2)连接FortiGate的IPSec,并访问VPN内部资源。

通过IKEv2预共享密钥的方式认证(无用户密码认证)。

网络拓扑

image-20230317134228759

配置步骤

FortiGate配置

  1. 配置FortiGate的接口IP。

    image-20230314161154582

  2. 进入FortiGate的VPN→IPSec隧道页面,点击新建按钮,新建IPSec隧道。

    image-20230314160655376

  3. 填写VPN名称,模版选择自定义,点击下一步。

    image-20230317134414018

  4. 按照下图修改配置,其他配置保持默认即可,点击确认下发配置。

    image-20231213111325748

    image-20230317135401483

  5. 对应的CLI如下:

    第一阶段配置:
    config vpn ipsec phase1-interface
        edit "Android_IKEv2"
            set type dynamic
            set interface "port2"
            set ike-version 2
            set peertype any
            set net-device disable
            set mode-cfg enable
            set ipv4-dns-server1 10.10.12.2
            set proposal aes128-sha256 aes256-sha256 aes128gcm-prfsha256 aes256gcm-prfsha384 chacha20poly1305-prfsha256
            set dpd on-idle
            set ipv4-start-ip 10.10.100.1
            set ipv4-end-ip 10.10.100.100
            set psksecret xxxxxxxx
            set dpd-retryinterval 60
        next
    end
    
    第二阶段配置:
    config vpn ipsec phase2-interface
        edit "Android_IKEv2"
            set phase1name "Android_IKEv2"
            set proposal aes128-sha1 aes256-sha1 aes128-sha256 aes256-sha256 aes128gcm aes256gcm chacha20poly1305
            set keepalive enable
        next
    end
    
  6. 配置防火墙策略,允许客户端访问内网VPN资源。

    image-20230317135849334

    内网VPN资源地址对象:
    config firewall address
        edit "LAN_10.10.1.0/24"
            set subnet 10.10.1.0 255.255.255.0
     next
    end
    
    客户端地址对象:
    config firewall address
           edit "VPN_10.10.100.0/24"
               set subnet 10.10.100.0 255.255.255.0
           next
       end
    
    防火墙策略:
    config firewall policy
        edit 1
            set name "Android_IKEv2"
            set srcintf "Android_IKEv2"
            set dstintf "port3"
            set action accept
            set srcaddr "VPN_10.10.100.0/24"
            set dstaddr "LAN_10.10.1.0/24"
            set schedule "always"
            set service "ALL"
        next
    end
    

    客户端配置

  7. 打开设置→连接→更多连接设置→VPN(找不到可以使用搜索功能),点击“添加VPN配置文件”。

    image-20230317143540877

  8. 类型选择IKEv2/IPSec PSK,填写名称、服务器地址、IPSec预共享密钥,注意必须填写IPSec标识符(随意填写即可),点击保存按钮保存连接。

    image-20230317144736414

结果验证

  1. 点击创建的VPN连接,点击连接按钮。连接成功后,点击查看连接状态,可以看到连接的具体信息。

    image-20230317144718407

    image-20230317144656190

  2. 在FortiGate侧查看连接状态。

    image-20230317144404765

    FortiGate # diagnose vpn ike gateway list 
    
    vd: root/0
    name: Android_IKEv2_0
    version: 2
    interface: port2 4
    addr: 202.103.12.2:4500 -> 202.103.23.2:35653
    tun_id: 10.10.100.1/::10.0.0.29
    remote_location: 0.0.0.0
    network-id: 0
    created: 8s ago
    peer-id: fortigate
    peer-id-auth: no
    assigned IPv4 address: 10.10.100.1/0.0.0.0
    nat: peer
    PPK: no
    IKE SA: created 1/1  established 1/1  time 20/20/20 ms
    IPsec SA: created 1/1  established 1/1  time 0/0/0 ms
      id/spi: 5 24e28229fbb0aabf/af590cf99666b224
      direction: responder
      status: established 8-8s ago = 20ms
      proposal: aes128-sha256
      child: no
      SK_ei: ebe7fafddd9a3afa-d25d578817491d46
      SK_er: d498cfd72bc78306-5d96c828c054dc49
      SK_ai: db2fe8a3c377d068-043cb17abe4a50dc-0b6a7406d9136909-d8f071b76a03d411
      SK_ar: 0816650a93fb45f2-620c1f63caa107c3-bdf507a33957e29e-e22ec78cdf616f11
      PPK: no
      message-id sent/recv: 0/2
      lifetime/rekey: 86400/86121
      DPD sent/recv: 00000000/00000000
      peer-id: fortigate
    
    FortiGate # diagnose vpn tunnel list 
    
    list all ipsec tunnel in vd 0
    ------------------------------------------------------
    name=Android_IKEv2_0 ver=2 serial=25 202.103.12.2:4500->202.103.23.2:35653 tun_id=10.10.100.1 tun_id6=::10.0.0.29 dst_mtu=1500 dpd-link=on weight=1
    bound_if=4 lgwy=static/1 tun=intf mode=dial_inst/3 encap=none/9128 options[23a8]=npu rgwy-chg rport-chg frag-rfc  run_state=0 role=primary accept_traffic=1 overlay_id=0
    parent=Android_IKEv2 index=0
    proxyid_num=1 child_num=0 refcnt=5 ilast=0 olast=11 ad=/0
    stat: rxp=63 txp=0 rxb=3644 txb=0
    dpd: mode=on-idle on=1 idle=60000ms retry=3 count=0 seqno=1
    natt: mode=silent draft=0 interval=10 remote_port=35653
    proxyid=Android_IKEv2 proto=0 sa=1 ref=2 serial=1 add-route
      src: 0:0.0.0.0-255.255.255.255:0
      dst: 0:10.10.100.1-10.10.100.1:0
      SA:  ref=3 options=20683 type=00 soft=0 mtu=1422 expire=43175/0B replaywin=2048
           seqno=1 esn=0 replaywin_lastseq=0000003f qat=0 rekey=0 hash_search_len=1
      life: type=01 bytes=0/0 timeout=43187/43200
      dec: spi=02cf6ed7 esp=aes key=16 e9a35403758eddeaa21370e37e36ea8d
           ah=sha256 key=32 54a6e676edae65bb37a0f4a6605b8fcfde743af1f229d29624abbbd4cc8bf8ec
      enc: spi=cbf93f37 esp=aes key=16 4e475164fbf9ac1be9c81497cd8ff98f
           ah=sha256 key=32 682b3b42a8f121a227f70a8952cc92110371f06f32309e5a0c7bb43a48677667
      dec:pkts/bytes=126/7288, enc:pkts/bytes=0/0
      npu_flag=00 npu_rgwy=202.103.23.2 npu_lgwy=202.103.12.2 npu_selid=1b dec_npuid=0 enc_npuid=0
    ------------------------------------------------------
    name=Android_IKEv2 ver=2 serial=22 202.103.12.2:0->0.0.0.0:0 tun_id=10.0.0.9 tun_id6=::10.0.0.9 dst_mtu=0 dpd-link=on weight=1
    bound_if=4 lgwy=static/1 tun=intf mode=dialup/2 encap=none/552 options[0228]=npu frag-rfc  role=primary accept_traffic=1 overlay_id=0
    proxyid_num=0 child_num=1 refcnt=3 ilast=43054304 olast=43054304 ad=/0
    stat: rxp=7209 txp=12 rxb=427332 txb=832
    dpd: mode=on-idle on=0 idle=60000ms retry=3 count=0 seqno=0
    natt: mode=none draft=0 interval=0 remote_port=0
    run_tally=0
    
  3. 在FortiGate侧查看路由kernel表,可以看到FortiGate已经自动添加了到客户端的路由。

    FortiGate # get router info kernel 
    ...
    tab=254 vf=0 scope=0 type=1 proto=11 prio=1 0.0.0.0/0.0.0.0/0->10.10.100.1/32 pref=0.0.0.0 gwy=10.10.100.1 dev=27(Android_IKEv2)
    ...
    
  4. 使用客户端访问VPN内网资源(Ping和HTTP访问)。

    image-20230317144626427

    实际测试Android使用IKEv2,无法使用隧道分割功能,VPN建立后,所有流量被送入VPN隧道。

Copyright © 2024 Fortinet Inc. All rights reserved. Powered by Fortinet TAC Team.
📲扫描下方二维码分享此页面👇
该页面修订于: 2023-12-13 11:14:54

results matching ""

    No results matching ""