当前位置:   article > 正文

openwrt配置strongswan对接hillstone ipsec的笔记_openwrt安装strongswan

openwrt安装strongswan

一、主要参考资料:

https://openwrt.org/docs/guide-user/services/vpn/ipsec/strongswan/roadwarrior

https://openwrt.org/docs/guide-user/services/vpn/ipsec/strongswan/basic

https://openwrt.org/docs/guide-user/services/vpn/ipsec/strongswan/site2site

https://openwrt.org/docs/guide-user/services/vpn/ipsec/strongswan/basics

https://oldwiki.archive.openwrt.org/inbox/strongswan.howto

https://www.xiaocan.me/linux-strongswan-cilent/

https://wiki.strongswan.org/projects/strongswan/wiki/ConnSection

https://www.strongswan.org/testing/testresults/ikev1/net2net-psk/

https://wiki.strongswan.org/issues/2071

http://blog.sina.com.cn/s/blog_517c21c00102wvij.html

 

二、具体笔记

1、安装strongswan:

  1. opkg update
  2. opkg install strongswan-ipsec strongswan-mod-kernel-libipsec kmod-tun

 

2、修改/tmp/ipsec/ipsec.conf

  1. root@OpenWrt:/tmp/ipsec# cat ipsec.conf
  2. # generated by /etc/init.d/ipsec
  3. version 2
  4. conn dmz
  5. left=%any
  6. right=111.111.111.111 #主端的公网IP地址
  7. leftsubnet=192.168.23.0/24 #本地LAN端的IP地址段
  8. ikelifetime=3h
  9. lifetime=1h
  10. margintime=9m
  11. keyingtries=3
  12. dpdaction=none
  13. dpddelay=30s
  14. leftauth=psk
  15. rightauth=psk
  16. rightsubnet=192.168.10.0/24 #主端的内网IP地址段
  17. auto=route #这个参数定义IPSEC隧道的启动方式,可选add\route\start
  18. leftid=IPSEC-TEST #这个ID根据主端的IPSEC配置来匹配
  19. keyexchange=ikev1
  20. type=tunnel
  21. esp=3des-md5-modp1024 #IPSEC第二阶段的协商加密协议,需与主端匹配,注意dh2对应是modp1024的写法,其它dh组对应值查看上面资料
  22. ike=3des-md5-modp1024 #IPSEC第一阶段的协商加密协议,需与主商匹配
  23. forceencaps = yes #据说是udp包的封装,yes后可以适配更多的网关转发,需视情况yes/no

2、修改/etc/firewall.user

  1. iptables -I INPUT -m policy --dir in --pol ipsec --proto esp -j ACCEPT
  2. iptables -I FORWARD -m policy --dir in --pol ipsec --proto esp -j ACCEPT
  3. iptables -I FORWARD -m policy --dir out --pol ipsec --proto esp -j ACCEPT
  4. iptables -I OUTPUT -m policy --dir out --pol ipsec --proto esp -j ACCEPT

3、/etc/config/ipsec(无用的,可以无视之)

  1. config 'ipsec'
  2. list listen ''
  3. option 'debug' '0'
  4. option 'interface' 'eth0.3'
  5. config 'remote' 'aaa'
  6. option 'enabled' '1'
  7. option 'gateway' '1.1.1.1'
  8. option 'pre_shared_key' 'aaaaaaaaaa'
  9. option 'exchange_mode' 'main'
  10. option 'authentication_method' 'psk'
  11. option 'local_identifier' 'IPSEC-TEST-1'
  12. list 'p1_proposal' 'pre_g2_des_sha1'
  13. list 'tunnel' 'aaa_dmz'
  14. list 'tunnel' 'aaa_lan'
  15. config 'p1_proposal' 'pre_g2_des_sha1'
  16. option 'encryption_algorithm' 'des'
  17. option 'hash_algorithm' 'sha1'
  18. option 'dh_group' '2'
  19. config 'tunnel' 'aaa_lan'
  20. option 'local_subnet' '192.168.23.0/24'
  21. option 'remote_subnet' '192.168.10.0/24'
  22. option 'p2_proposal' 'g2_des_sha1'
  23. option 'keyexchange' 'ikev1'
  24. config 'tunnel' 'aaa_dmz'
  25. option 'local_subnet' '192.168.23.0/24'
  26. option 'remote_subnet' '192.168.15.0/24'
  27. option 'p2_proposal' 'g2_des_sha1'
  28. option 'keyexchange' 'ikev1'
  29. config 'p2_proposal' 'g2_des_sha1'
  30. option 'pfs_group' '2'
  31. option 'encryption_algorithm' 'des'
  32. option 'authentication_algorithm' 'sha1'

4、手动启动命令

  1. /usr/sbin/ipsec start #启动IPSEC进程
  2. /usr/sbin/ipsec up dmz #手动启动dmz隧道(当上面的auto=add或route时)
  3. /usr/sbin/ipsec statusall #查看ipsec的配置及运行状态等
  4. ifconfig ipsec0 #查看隧道打通后是否产生ipsec0这个虚拟网卡

5、添加路由:

route add -net 192.168.10.0/24 dev ipsec0

6、最后发现:

hillstone的垃圾只可以一个连接,当第二个IPSEC连上去会把第一个IPSEC踢掉!!!!!!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/965220
推荐阅读
  

闽ICP备14008679号