You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.2 KiB

  1. Setting up OpenConnect VPN server
  2. =================================
  3. The openconnect server expects to be configured using the uci interface.
  4. It is recommended to setup a dynamic DNS address with openwrt prior
  5. to starting the server. That is because during the first startup
  6. a certificate file which contain the setup dynamic DNS name will be
  7. created. You can always regenerate the certificate by deleting
  8. /etc/ocserv/server-key.pem.
  9. There are two approaches to setup the VPN. The proxy-arp approach (1)
  10. which provides clients with addresses of the LAN, and the "forwarding"
  11. approach (2) which provides clients with addresses of a separate private
  12. network. The former is suitable when you have "roadwarrior" type of clients
  13. connecting to the LAN, and the latter when you may need to connect
  14. multiple networks with the LAN.
  15. 1. Proxy-ARP Approach
  16. =====================
  17. [This option is available since ocserv-0.10.9-2 package]
  18. To setup a server the provides access to LAN with network address
  19. 10.100.2.0/255.255.255.0 add the following to /etc/config/ocserv.
  20. The following setup will assign the upper 62 addresses for VPN use.
  21. ```
  22. ----/etc/config/ocserv-------------------------------------------
  23. config ocserv 'config'
  24. option port '443'
  25. option dpd '120'
  26. option max_clients '8'
  27. option max_same '2'
  28. option netmask '255.255.255.192'
  29. option ipaddr '10.100.2.192'
  30. option auth 'plain'
  31. option default_domain 'lan'
  32. option compression '1'
  33. option proxy_arp '1'
  34. option ping_leases '1'
  35. option enable '1'
  36. config dns
  37. option ip '10.100.2.1'
  38. config routes
  39. option ip '10.100.2.0'
  40. option netmask '255.255.255.0'
  41. config ocservusers
  42. option name 'test'
  43. option password '$5$unl8uKAGNsdTh9zm$PnUHEGhDc5VHbFE2EfWwW38Bub6Y6EZ5hrFwZE1r2F1'
  44. -----------------------------------------------------------------
  45. ```
  46. This setup re-utilizes the addresses assigned to LAN for the VPN clients.
  47. To ensure that there are no conflicts with the DHCP server use the following
  48. commands. These will set the maximum address assigned by DHCP to be 10.100.2.191
  49. which is below the first VPN assigned address (10.100.2.192).
  50. ```
  51. # uci set dhcp.lan.start=100
  52. # uci set dhcp.lan.limit=91
  53. ```
  54. For simple networks like that you may also leave the 'netmask' and 'ipaddr'
  55. fields empty and ocserv on startup will set the necessary values.
  56. 2. Forwarding Approach
  57. ======================
  58. To setup a server the provides access to LAN with network address
  59. 10.100.2.0/255.255.255.0 using the VPN address range
  60. 10.100.3.0/255.255.255.0 add the following to /etc/config/ocserv:
  61. ```
  62. ----/etc/config/ocserv-------------------------------------------
  63. config ocserv 'config'
  64. option port '443'
  65. option dpd '120'
  66. option max_clients '8'
  67. option max_same '2'
  68. option netmask '255.255.255.0'
  69. option ipaddr '10.100.3.0'
  70. option auth 'plain'
  71. option default_domain 'lan'
  72. option compression '1'
  73. option enable '1'
  74. config dns
  75. option ip '10.100.2.1'
  76. config routes
  77. option ip '10.100.2.0'
  78. option netmask '255.255.255.0'
  79. config ocservusers
  80. option name 'test'
  81. option password '$5$unl8uKAGNsdTh9zm$PnUHEGhDc5VHbFE2EfWwW38Bub6Y6EZ5hrFwZE1r2F1'
  82. -----------------------------------------------------------------
  83. ```
  84. Setting up the firewall
  85. =======================
  86. Since the connected users will be assigned to other interfaces than the LAN
  87. one, it is required to assign the VPN clients to an interface, and enable
  88. forwarding for them. That is, you should setup an unmanaged interface (e.g.,
  89. called vpn), which will have assigned the 'vpns+' interfaces (i.e., all vpns
  90. interfaces). Then a zone called vpn should be setup to handle interactions
  91. with lan. An example, which alls all forwarding between LAN and VPN clients,
  92. follows.
  93. ```
  94. ----/etc/config/network------------------------------------------
  95. config interface 'vpn'
  96. option proto 'none'
  97. option ifname 'vpns+'
  98. -----------------------------------------------------------------
  99. ----/etc/config/firewall-----------------------------------------
  100. config zone
  101. option input 'ACCEPT'
  102. option forward 'ACCEPT'
  103. option output 'ACCEPT'
  104. option name 'vpn'
  105. option device 'vpns+'
  106. option network 'vpn'
  107. config forwarding
  108. option dest 'lan'
  109. option src 'vpn'
  110. config forwarding
  111. option dest 'vpn'
  112. option src 'lan'
  113. config rule
  114. option target 'ACCEPT'
  115. option src 'wan'
  116. option proto 'tcp'
  117. option dest_port '443'
  118. option name 'vpn'
  119. config rule
  120. option target 'ACCEPT'
  121. option src 'wan'
  122. option proto 'udp'
  123. option dest_port '443'
  124. option name 'vpn'
  125. -----------------------------------------------------------------
  126. ```
  127. Note, that the last two rules, enable connections to port 443 from the
  128. Internet. That is the port used by OpenConnect VPN.
  129. Starting the server
  130. ===================
  131. Note that both configurations above add the user "test" with password "test". The
  132. password is specified in the crypt(3) format.
  133. The server can be enabled and started using:
  134. # /etc/init.d/ocserv enable
  135. # /etc/init.d/ocserv start
  136. For any custom configuration options of ocserv you may add values in
  137. /etc/ocserv/ocserv.conf.local.
  138. There is a luci plugin to allow configuring the server from
  139. the web environment; see the package luci-app-ocserv.