Sunday, February 7, 2021

VPN: OpenConnect

For connecting to vpn using openconnect command, we need to install three packages:

  • openvpn
  • easy-rsa
  • openconnect

 

In RedHat or CentOS based Linux system:

  • $ sudo yum install epel-release                            
  • $ sudo yum install -y openvpn easy-rsa
  • $ sudo yum install -y openconnect

 

In Debian based Linux system:

  • $ sudo apt install -y openvpn easy-rsa
  • $ sudo apt install -y openconnect

 

Before connecting to vpn, create tunneling device using openvpn command and make it active. If 'ip' command is not available (on older system) use "sudo ifconfig tun1 up" in step 2

  • $ sudo openvpn --mktun --dev tun1
  • $ sudo ip link set tun1 up
  • $ sudo openconnect <IP-Address> --interface=tun1

Once done, remove the tun1 using following commands:

  • $ sudo ip link set tun1 down
  • $ sudo openvpn --rmtun --dev tun1