Skip to main content

vpnc-script replacement for easy split-tunnel VPN setup

Project description

This is a replacement for the vpnc-script used by OpenConnect or VPNC.

Instead of trying to copy the behavior of standard corporate VPN clients, which normally reroute all your network traffic through the VPN, this one tries to minimize your contact with an intrusive corporate VPN. This is also known as a split-tunnel VPN, since it splits your traffic between the VPN tunnel and your normal network interfaces.

vpn-slice makes it easy to set up a split-tunnel VPN:

  • It only routes traffic for specific hosts or subnets through the VPN.

  • It automatically looks up named hosts, using the VPN’s DNS servers, and adds entries for them to your /etc/hosts (which it cleans up after VPN disconnection), however it does not otherwise alter your /etc/resolv.conf at all.

Requirements

  • Python 3.3+

  • Either of the following:
    • dnspython module (preferred, tested with v1.16.0)

    • dig command-line DNS lookup tool (tested with v9.9.5 and v9.10.3)

  • Supported OSes:
    • Linux kernel 3.x+ with iproute2 and iptables utilities (used for all routing setup)

    • macOS 10.x

Usage

You should specify vpn-slice as your connection script with openconnect or vpnc. It has been tested with vpnc v0.5.3, OpenConnect v7.06+ (Cisco AnyConnect and Juniper protocols) and v8.0+ (PAN GlobalProtect protocol).

For example:

$ sudo openconnect gateway.bigcorp.com -u user1234 \
    -s 'vpn-slice 192.168.1.0/24 hostname1 hostname2'
$ cat /etc/hosts
...
192.168.1.1 dnsmain00 dnsmain00.bigcorp.com         # vpn-slice-tun0 AUTOCREATED
192.168.1.2 dnsbackup2 dnsmain2.bigcorp.com         # vpn-slice-tun0 AUTOCREATED
192.168.1.57 hostname1 hostname1.bigcorp.com        # vpn-slice-tun0 AUTOCREATED
192.168.1.173 hostname1 hostname1.bigcorp.com       # vpn-slice-tun0 AUTOCREATED

Notice that vpn-slice accepts both hostnames alone (hostname1) as well as host-to-IP* aliases (alias2=alias2.bigcorp.com=192.168.1.43). The former are first looked up using the VPN’s DNS servers. Both are also added to the routing table, as well as to /etc/hosts (unless --no-host-names is specified). As in this example, multiple aliases can be specified for a single IP address.

There are many command-line options to alter the behavior of vpn-slice; try vpn-slice --help to show them all.

Running with --verbose makes it explain what it is doing, while running with --dump shows the environment variables passed in by the caller.

Home page

https://github.com/dlenski/vpn-slice

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vpn-slice-0.14.2.tar.gz (18.0 kB view details)

Uploaded Source

File details

Details for the file vpn-slice-0.14.2.tar.gz.

File metadata

  • Download URL: vpn-slice-0.14.2.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.7

File hashes

Hashes for vpn-slice-0.14.2.tar.gz
Algorithm Hash digest
SHA256 019c7568c0006d376732b3a1bd1e29eb23c8aa50f1ed53e2d0c80b022af5ab18
MD5 fb3a0ef3d248293009d458c281fb6486
BLAKE2b-256 87bc30319efb66e915806bb6717852c7c5e7b1788d4c0b9f2c37a10e9be19e12

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page