User Tools

Site Tools


doc:howto:openconnect-setup

OpenConnect SERVER Setup Guide for Beginners

This is a beginner's guide to setting up OpenConnect as a SERVICE (ocserv) on OpenWRT for use with a client running either the OpenConnect client or Cisco's Anyconnect.

The primary goal of this HOWTO is to get a working OpenConnect tunnel with the least amount of compatability issues. Note that the instructions provided here did NOT WORK for me, and it seemed like there is an easier, more elegant solution as described in the OpenConnect documentation on Pseudo-Bridging.

For an overview of all VPN-related articles (including other VPN technologies), see vpn.overview.

Use Case (the beginner's configuration)

The user wants a client to access their OpenWrt router and the network it supports on the back securely with a minimum of compatibility issues and minimum configuration fuss. The client can be a mobile user roaming on a mobile network OR at a public wifi hotspot, and wants to EITHER secure their traffic from eavesdropping, or access their private network.

The end result will be an encrypted connection directly between the client (on the WAN side) and LAN side of the OpenWRT, such that the client effectively has access to the LAN side as if they were local, PLUS the benefits of their OpenWRT firewall for browsing the Internet.

Note that this is a FULL tunnel, meaning all traffic is routed through the VPN once connected. This is, in my opinion, the only type of tunnel to use, as a split tunnel is inherently insecure. You cannot, for example, secure your traffic from a public hotspot using a split tunnel since your banking traffic will go through the PUBLIC hotspot and not through your VPN tunnel.

Why use OpenConnect

1) Your network provider is BLOCKING IPSEC traffic. This is apparently POLICY for mobile carriers, though they deny it. OpenConnect is SSL. 2) Your client only supports AnyConnect or the OpenConnect Client. (Blackberry, for example, does not support OpenVPN). 3) You just want a secure SSL-based VPN to your LAN. The official site for Openconnect is Here

Basic Configuration: Router as SERVER

You will want the following packages:

One of the easiest setups is to configure the VPN as a pseudo-bridge with Proxy ARP. What this means is that you will connect and be on the LAN side of your router with no additional routing needed, as if you were there. The configuration is described in this reciperecipe: ocserv pseudo bridge.

Router is configured at 192.168.1.1 DHCP hosts are configured to use the range 192.168.1.2-192.168.1.50 You want your VPN hosts to use the range 192.168.1.100 and have only 1-2 hosts connecting at any given time

1) Edit /etc/config/ocserv as follows, or use LUCI:

    config ocserv 'config'
         option enable '1'                                         
         option port '443'                                         
         option netmask '255.255.255.253'                          
         option ipaddr '192.168.1.100'                            
         option zone 'lan'          

This will put your VPN clients at 192.168.1.100+. Note that the netmask limits the # of clients you can have to TWO. Change as necessary.

 NOTE: the above suggests port 443 as the preferred port. This is to support MOBILE clients. 
 Many mobile network operators are blocking other ports (despite the FCC open internet order), 
 but they cannot block port 443, therefore 443 is more likely to work for the majority of mobil users.
 

2) Add your DNS server

     config dns                                                        
         option ip '192.168.1.1'     
   

3) Edit /etc/config/firewall or use LUCI and add the following rules:

  config rule                      
      option name 'Allow SSL vpn in (tcp)'
      option src 'wan'                    
      option proto 'tcp'                  
      option dest_port '443'              
      option target 'ACCEPT'              
                                          
  config rule                                 
      option name 'Allow SSL vpn in (udp)'
      option src 'wan'                    
      option proto 'udp'                  
      option dest_port '443'              
      option target 'ACCEPT'    
      

What this does is accept traffic for SSL on the WAN side.

4) Add the following to /etc/firewall.user (or use LUCI):

  iptables -A input_rule -i vpns+ -j ACCEPT
  iptables -A forwarding_rule -i vpns+ -j ACCEPT
  iptables -A forwarding_rule -o vpns+ -j ACCEPT
  iptables -A output_rule -o vpns+ -j ACCEPT

What these do is allow traffic from the VPN interface(s).

Lastly: 5) Edit /etc/sysctl.conf and add the following line:

   net.ipv4.conf.all.proxy_arp=1

Then type sysctl -p to reload the configuration file. The purpose is described in the recipe above.

5) Add users(and passwords) to your OpenConnect service. I find LUCI to be pretty easy to use for all of these steps.

FINALLY: Restart your firewall service and fire up the openconnect server to test it out. That's all there is to it!

doc/howto/openconnect-setup.txt · Last modified: 2015/08/13 15:41 by jaf323