Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:services:vpn:openconnect:client [2020/11/27 11:22] – split technical reference information to docs:guide-user:network:tunneling_interface_protocols#protocol_openconnect_openconnect_vpn vgaeteradocs:guide-user:services:vpn:openconnect:client [2024/10/17 17:46] – [2. Key management] andrewz
Line 1: Line 1:
 ====== OpenConnect client ====== ====== OpenConnect client ======
-The OpenConnect VPN client can connect to servers running either ocserv, Cisco AnyConnect, or Juniper Pulse Connect Secure. +{{section>meta:infobox:howto_links#basic_skills&noheader&nofooter&noeditbutton}}
-There are various [[https://en.wikipedia.org/wiki/OpenConnect#Platforms|openconnect clients]], including in GNOME NetworkManager, [[https://github.com/nmav/openconnect-gui/releases|Windows]], and [[https://play.google.com/store/apps/details?id=app.openconnect|Android]].+
  
-===== Preparation ===== +===== Introduction ===== 
-Install the packages and specify the VPN client configuration parameters.+  * This how-to describes the method for setting up [[wp>OpenConnect|OpenConnect]] client on OpenWrt. 
 +  * Follow [[docs:guide-user:services:vpn:openconnect:server|OpenConnect server]] for server setup and [[docs:guide-user:services:vpn:openconnect:extras|OpenConnect extras]] for additional tuning. 
 + 
 +===== Goals ===== 
 +{{section>docs:guide-user:services:vpn:wireguard:server#goals&noheader&nofooter&noeditbutton}} 
 + 
 +===== Command-line instructions ===== 
 +==== 1. Preparation ==== 
 +Install the required packages. 
 +Specify configuration parameters for VPN client.
  
 <code bash> <code bash>
 # Install packages # Install packages
 opkg update opkg update
-opkg install openconnect+opkg install openconnect openssl-util 
 + 
 +# Configuration parameters 
 +VPN_IF="vpn" 
 +VPN_SERV="SERVER_ADDRESS" 
 +VPN_PORT="4443" 
 +VPN_USER="USERNAME" 
 +VPN_PASS="PASSWORD"
 </code> </code>
  
-===== Configuration ===== +==== 2. Key management ==== 
-An instance of the OpenConnect client is configured and started through the UCI system by declaring a network interface of ''[[docs:guide-user:network:tunneling_interface_protocols#protocol_openconnect_openconnect_vpn|proto openconnect]]''. +Run the code below directly on the VPN server if you can or [[docs:guide-user:services:vpn:openconnect:extras#server_certificate|fetch certificate]] from the server and generate the hash locally: 
-The resulting interface will be named vpn-name where 'name' is the name specified+<code bash> 
-In this document it is assumed to be ''ocvpn'', thus the full name is ''vpn-ocvpn''.+# Generate certificate hash 
 +VPN_CERT="server-cert.pem" 
 +VPN_HASH="pin-sha256:$(openssl x509 -in ${VPN_CERT} -pubkey -noout \ 
 +| openssl pkey -pubin -outform der \ 
 +| openssl dgst -sha256 -binary \ 
 +| openssl enc -base64)" 
 +</code>
  
-===== Certificates ===== +Alternatively, run the client once without specifying ''serverhash'' in the configuration file or "VPN Server'certificate SHA1 hash" in LuciOpen the System Log and look for the following lines:
-PKI authentication is integral to OpenConnect. +
-Certificates must be installed to the filesystem at ''/etc/openconnect''+
-This can be done by scp, or by pasting the certificate base64 text into LuCI.+
  
-===== Operation ===== +<code> 
-Upon a successful authentication and connection, the vpn-ocvpn interface will be created and brought up, and assigned an IP address by the server+daemon.notice netifd: vpn (3443): Certificate from VPN server "vpn.example.com" failed verification. 
-The firewall and routing should be configured for this interface like any other VPN, for example:+daemon.notice netifd: vpn (3443): Reason: unable to get local issuer certificate 
 +daemon.notice netifd: vpn (3443): To trust this server in future, perhaps add this to your command line: 
 +daemon.notice netifd: vpn (3443):     --servercert pin-sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
 +daemon.notice netifd: vpn (3443): SSL connection failure 
 +</code> 
 + 
 +Copy the complete string shown __after__ ''--servercert'' and use it in the configuration as your server hash. 
 + 
 +==== 3. Firewall ==== 
 +{{section>docs:guide-user:services:vpn:wireguard:client#firewall&noheader&nofooter&noeditbutton}} 
 + 
 +==== 4Network ==== 
 +Set up VPN interface.
  
 <code bash> <code bash>
-# /etc/config/firewall+Configure network 
 +uci -q delete network.${VPN_IF} 
 +uci set network.${VPN_IF}="interface" 
 +uci set network.${VPN_IF}.proto="openconnect" 
 +uci set network.${VPN_IF}.server="${VPN_SERV}" 
 +uci set network.${VPN_IF}.port="${VPN_PORT}" 
 +uci set network.${VPN_IF}.username="${VPN_USER}" 
 +uci set network.${VPN_IF}.password="${VPN_PASS}" 
 +uci set network.${VPN_IF}.serverhash="${VPN_HASH}" 
 +uci commit network 
 +service network restart 
 +</code>
  
-config zone +See all available OpenConnect protocol options [[docs:guide-user:network:tunneling_interface_protocols#protocol_openconnect_openconnect_vpn|here]] and a sample configuration [[https://github.com/openwrt/packages/blob/master/net/openconnect/README|here]].
- option name vpn +
- list network 'ocvpn' +
- option input REJECT +
- option output ACCEPT +
- option forward REJECT +
- option masq 1 +
- option mtu_fix 1+
  
-config forwarding +Disable [[docs:guide-user:services:vpn:openconnect:extras#gateway_redirection|gateway redirection]] and/or [[docs:guide-user:services:vpn:openconnect:extras#keep_existing_gateway|keep the existing gateway]] if necessary. 
- option src lan + 
- option dest vpn+===== Web-based configuration ===== 
 + 
 +Web-based configuration is available through [[:packages:pkgdata:luci-proto-openconnect]] package. 
 + 
 +<code bash> 
 +# Install packages 
 +opkg update 
 +opkg install luci-proto-openconnect 
 +service rpcd restart
 </code> </code>
  
-If the interface does not come up, examine the system log file for error messages. +Navigate to **LuCI -> Network -> Interfaces** to configure OpenConnect client. 
-Although OpenConnect is started with command line options, it is not possible to fully bring up an OpenConnect client interface manually from the command line (''vpnc'' will fail with "must be used on an active interface")+ 
-Manually running OpenConnect through the authentication stages is useful to diagnose authentication problems though. +Currently not all the options can be set through Luci, so manual changes in ''/etc/config/network'' might be needed. 
-UCI will retry a connection constantly at 5 second intervals, which if unsuccessful could lead to being blacklisted by the server. + 
-Thus it would be advisable to disable the configuration in ''/etc/config/network'' while troubleshooting.+\\ 
 + 
 +===== Testing ===== 
 +{{section>docs:guide-user:services:vpn:wireguard:server#testing&noheader&nofooter&noeditbutton}} 
 + 
 +===== Troubleshooting ===== 
 +Collect and analyze the following information. 
 + 
 +<code bash> 
 +# Restart services 
 +service log restart; service network restart; sleep 10 
 + 
 +# Log and status 
 +logread -e openconnect 
 + 
 +# Runtime configuration 
 +pgrep -f -a openconnect 
 +ip address show; ip route show table all 
 +ip rule show; ip -6 rule show; nft list ruleset 
 + 
 +# Persistent configuration 
 +uci show network; uci show firewall 
 +</code>
  
  • Last modified: 2024/10/18 10:24
  • by andrewz