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.

195 lines
5.6 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 split-dns
  85. ====================
  86. To allow the clients to resolv with the local domain add the following
  87. to the ocserv configuration file.
  88. ```
  89. ----/etc/config/ocserv-------------------------------------------
  90. config ocserv 'config'
  91. option split_dns '1'
  92. option default_domain 'mydomain'
  93. ```
  94. The ```default_domain``` is optional and if not set, it will be autodetected
  95. from dnsmasq's configuration.
  96. Setting up the firewall
  97. =======================
  98. Since the connected users will be assigned to other interfaces than the LAN
  99. one, it is required to assign the VPN clients to an interface, and enable
  100. forwarding for them. That is, you should setup an unmanaged interface (e.g.,
  101. called vpn), which will have assigned the 'vpns+' interfaces (i.e., all vpns
  102. interfaces). Then a zone called vpn should be setup to handle interactions
  103. with lan. An example, which alls all forwarding between LAN and VPN clients,
  104. follows.
  105. ```
  106. ----/etc/config/network------------------------------------------
  107. config interface 'vpn'
  108. option proto 'none'
  109. option ifname 'vpns+'
  110. -----------------------------------------------------------------
  111. ----/etc/config/firewall-----------------------------------------
  112. config zone
  113. option input 'ACCEPT'
  114. option forward 'ACCEPT'
  115. option output 'ACCEPT'
  116. option name 'vpn'
  117. option device 'vpns+'
  118. option network 'vpn'
  119. config forwarding
  120. option dest 'lan'
  121. option src 'vpn'
  122. config forwarding
  123. option dest 'vpn'
  124. option src 'lan'
  125. config rule
  126. option target 'ACCEPT'
  127. option src 'wan'
  128. option proto 'tcp'
  129. option dest_port '443'
  130. option name 'vpn'
  131. config rule
  132. option target 'ACCEPT'
  133. option src 'wan'
  134. option proto 'udp'
  135. option dest_port '443'
  136. option name 'vpn'
  137. -----------------------------------------------------------------
  138. ```
  139. Note, that the last two rules, enable connections to port 443 from the
  140. Internet. That is the port used by OpenConnect VPN.
  141. Starting the server
  142. ===================
  143. Note that both configurations above add the user "test" with password "test". The
  144. password is specified in the crypt(3) format.
  145. The server can be enabled and started using:
  146. # /etc/init.d/ocserv enable
  147. # /etc/init.d/ocserv start
  148. For any custom configuration options of ocserv you may add values in
  149. /etc/ocserv/ocserv.conf.local.
  150. There is a luci plugin to allow configuring the server from
  151. the web environment; see the package luci-app-ocserv.