OpenVPN Guest Lecture OS3 System & Network Engineering janjust/presentations/OS3_OpenVPN_Lecture... ·

  • View
    212

  • Download
    0

Embed Size (px)

Text of OpenVPN Guest Lecture OS3 System & Network Engineering...

  • J.J. KeijserNikhefAmsterdamGrid Group

    OpenVPN Guest LectureOS3 System & Network Engineering

    Jan Just KeijserNikhef

    11 May 2011

  • J.J. KeijserNikhefAmsterdamGrid Group

    Working as grid system engineer since 2005Working in IT industry since 1995discovered OpenVPN in 2004Used and supported OpenVPN since thenAuthor of the OpenVPN 2 Cookbook,

    published in 2011 IT interests include open source, networking,

    VPNs, security, openssl, socat

    A few words about me

  • J.J. KeijserNikhefAmsterdamGrid Group

    What is a VPN? Types of VPNs What is OpenVPN? OpenVPN protocol Modes of operation: preshared keys, certificates,

    'tun' vs 'tap', bridging Routing Smart card support Scripting and plugins Other features Weaknesses Future work Summary

    Outline

  • J.J. KeijserNikhefAmsterdamGrid Group

    What is a VPN?

    Internet / WAN

    NAT&Firewall Firewall&NAT

    Without the use of a VPN

    Server

    Your TROL (Typical Remote Office Layout)Client

  • J.J. KeijserNikhefAmsterdamGrid Group

    What is a VPN?

    Internet / WAN

    NAT&Firewall Firewall&NAT

    Using a VPN

    Server

    VPN SetupClient

  • J.J. KeijserNikhefAmsterdamGrid Group

    Types of VPNsWeb based: Proxies, SOCKSSolutions based on SSHPPTP based: Microsoft PPTP VPN client IPSec based: OpenS/WAN, raccoon IPSec+L2TP based: Microsoft L2TP VPN clientSSL based: OpenVPN

  • J.J. KeijserNikhefAmsterdamGrid Group

    Virtual network adapterMost VPNs use the concept of a Virtual Network

    Adapter. This allows for: Separate IP address; Control over the routing and protocols allowed over the

    VPN.The Virtual Network Adapter is the interface

    between the VPN client (or server) software and the Operating System.

    Virtual Network Adapter

    Ethernet 1

    23VPN client

  • J.J. KeijserNikhefAmsterdamGrid Group

    Web-based VPNsAlso known as clientless VPNsWork only with web-based applicationsBasically, a souped-up Secure Proxy server or

    SOCKS serverThe VPN never leaves the sandbox of the

    webbrowser:HTTPS

    encrypted trafficEthernet 1 Web

    browserVPN applet

  • J.J. KeijserNikhefAmsterdamGrid Group

    SSH-based solutions Not a true VPN tunnelling of specific TCP ports only Client and server software available for nearly every

    platform OpenSSH includes SOCKS server support, allowing more

    flexible tunnels

    SSH Tunnel

    hostA:80

    hostB:23127.0.0.1:8080127.0.0.1:1200

    127.0.0.1 port 8080127.0.0.1 port 1200

    hostA port 80 (http)hostB port 23 (telnet)

  • J.J. KeijserNikhefAmsterdamGrid Group

    Web&SSH Pro's and con'sPros:

    Cient software for nearly all platforms; Uses standard TCP traffic so no NATting issues; Easy to configure.

    Cons: Web-based (TCP, HTTPS) only; Not easy to share local data with remote site/server; Not a true VPN solution.

  • J.J. KeijserNikhefAmsterdamGrid Group

    PPTP: the Microsoft solution

    PPTP adapter

    Ethernet 1

    23VPN client

    GREencrypted traffic

    Developed by Microsoft and Ascend (RFC2637) Authentication using username/password

    OR X.509 certificates (EAP-TLS) Runs over single TCP port and GRE tunnels (protocol 47) Frequently used for ADSL ethernet modems Interface to OS through PPTP adapter:

  • J.J. KeijserNikhefAmsterdamGrid Group

    PPTP: Pro's and con'sPros:

    Client built into Microsoft platform; Other platforms supported for both client and server:

    Linux; FreeBSD/OpenBSD/NetBSD; Macintosh OS X.

    Cons: PPTP considered fundamentally insecure; Secure version (EAP-TLS) supported fully only on

    Windows; GRE tunnelling does not work well with NATting devices.

  • J.J. KeijserNikhefAmsterdamGrid Group

    IPsec Official IEEE/IETF standard voor IP security (RFC2411) Operates at Level2/Level3 of IP stack Part of IPv6 specification Introduces the concept of Security Policies Uses Encapsulated Security Payload (ESP, IP protocol

    50) for payload security, Hash-based Message Authentication Code (HMAC) for integrity

    Authentication using X.509 certificates or pre-shared keys

    Two modes supported: Transport mode; Tunnelling mode;

  • J.J. KeijserNikhefAmsterdamGrid Group

    IPsec+L2TP Developed by Microsoft and Cisco Systems (RFC3193) Utilizes IPSec Transport mode Authentication using X.509 certificates or pre-shared

    keys, in combination with a username/password Uses both UDP ports 500 and 4500 as well as ESP

    (protocol 50) Interface to OS through L2TP adapter:

    L2TP adapter

    3L2TP client

    IPSecEthernet

    IPsecencrypted traffic

    2

    1

  • J.J. KeijserNikhefAmsterdamGrid Group

    IPsec: Pro's and con'sPros:

    Industry standard; Good platform support, including ADSL and Wifi

    routers; Security policies allow for a very modular approach.

    Cons: Configuration and troubleshooting can be difficult; Notoriously difficult to configure, especially in

    combination with NAT-Traversal (NAT-T); Server-side cannot be NATted, often forcing the use

    of a DMZ; IPSec and NATting devices do not go well together.

  • J.J. KeijserNikhefAmsterdamGrid Group

    OpenVPN: an SSL based VPN

    tun/tap device

    Ethernet 1

    23OpenVPN

    Uses TLS/SSL for payload security, HMAC for integrity Authentication using X.509 certificates or pre-shared keys UDP, TCP and SOCKS/HTTP Proxy support Supports tunnelling (TCP/IP) and bridging (Ethernet) mode Interface to OS through tun/tap device or TAP-Win32

    adapter:

    UDP/TCPencrypted traffic

  • J.J. KeijserNikhefAmsterdamGrid Group

    What is OpenVPN?With OpenVPN, you can:

    tunnel any IP subnetwork or virtual ethernet adapter over a single UDP or TCP port, configure a scalable, load-balanced VPN server farm using one or more machines

    which can handle thousands of dynamic connections from incoming VPN clients, use all of the encryption, authentication, and certification features of the OpenSSL

    library to protect your private network traffic as it transits the internet, use any cipher, key size, or HMAC digest (for datagram integrity checking)

    supported by the OpenSSL library, choose between static-key based conventional encryption or certificate-based

    public key encryption, use static, pre-shared keys or TLS-based dynamic key exchange, use real-time adaptive link compression and traffic-shaping to manage link

    bandwidth utilization, tunnel networks whose public endpoints are dynamic such as DHCP or dial-in

    clients, tunnel networks through connection-oriented stateful firewalls without having to

    use explicit firewall rules, tunnel networks over NAT, create secure ethernet bridges using virtual tap devices, and control OpenVPN using a GUI on Windows or Mac OS X.

    (from http://openvpn.net/index.php/open-source/333-what-is-openvpn.html)

  • J.J. KeijserNikhefAmsterdamGrid Group

    OpenVPN: some historyStarted in 2002 by James YonanFirst version only supported preshared keys

    and site-to-site connectivity2004: OpenVPN 2.0 which supported

    X509 certificates Multiple clients to same server

    2009: OpenVPN 2.1 which added PKCS#11 support Windows Vista/7 support

    2011: OpenVPN 2.2 released First community-built version

  • J.J. KeijserNikhefAmsterdamGrid Group

    OpenVPN protocol In SSL/TLS mode two channels are used:

    A reliable control channel for exchanging SSL/TLS information and keys

    A data channel for transporting actual payload. In UDP mode this channel is not reliable

    Each encrypted packet is formatted as follows: HMAC(explicit IV, encrypted envelope) Explicit IV Encrypted Envelope

    The content of the encrypted envelope is formatted as follows: 64 bit sequence number payload data, i.e. IP packet or Ethernet frame

  • J.J. KeijserNikhefAmsterdamGrid Group

    Modes of operationOpenVPN supports several modes of operation:Preshared static keysAuthN using X509 certificatesAuthN using username+passwordTunnelling mode (point-to-point, aka 'tun')Ethernet mode (aka 'tap')Ethernet bridging

  • J.J. KeijserNikhefAmsterdamGrid Group

    Basic static key exampleFirst, generate a static key:$ openvpn --genkey --secret secret.keyTransfer the key to the remote end using a secure

    channel (e.g. scp)Start the server/listener:$ openvpn --ifconfig 10.200.0.1 10.200.0.2 \ --dev tun --secret secret.keyAnd connect to it using the client:$ openvpn --ifconfig 10.200.0.2 10.200.0.1 \ --dev tun --secret secret.key \ --remote openvpnserver.example.com

  • J.J. KeijserNikhefAmsterdamGrid Group

    Setting up a PKIOpenVPN supplies 'easy-rsa' scripts, which are

    wrappers around 'openssl ca' commandsOther PKI solutions can also be used, provided they

    can supply PEM-encoded certificates and keys or PKCS#12 formatted files

    Example usage of 'easy-rsa':$ $ . ./vars$ ./clean-all$ ./build-ca$ ./build-key-server $ ./build-key

  • J.J. KeijserNikhefAmsterdamGrid Group

    Basic X509 example (server)proto udpport 1194dev tunserver 10.8.0.0 255.255.255.0ca ca.crtcert server.crtkey server.keydh dh1024.pemtls-auth ta.key 0persist-keypersist-tunkeepalive 10 60user nobodygroup nobody

  • J.J. KeijserNikhefAmsterdamGrid Group

    Basic X509 example (client)clientproto udpremote openvpnserver.example.comport 1194dev tunnobindca ca.crtcert client.crtkey client.keytls-auth ta.key 1

  • J.J. KeijserNikhefAmsterdamGrid Group

    Network topologiesOpenVPN 2.1 introduced