Skip to content

A lightweight OpenConnect-based alternative to Pulse Secure VPN client with selective routing capabilities. Route only specific subnets through VPN while keeping regular internet traffic untouched. 🌐

License

Notifications You must be signed in to change notification settings

olivergg/betterpulse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌐 BetterPulse VPN Script

An improved alternative to the Pulse Secure client, enabling VPN connection via OpenConnect with fine-grained and selective network routing.

🎯 Key Feature

Unlike most VPN configurations that route all internet traffic through the VPN tunnel, this script is designed to:

  • Route only specific subnets through the VPN
  • Maintain the rest of the traffic via the original default route
  • Allow granular route configuration

This approach is particularly useful for:

  • 🏒 Accessing corporate resources without impacting personal internet browsing
  • ⚑ Optimizing performance by avoiding unnecessary traffic routing through VPN
  • πŸ”’ Maintaining better security by clearly separating flows

πŸš€ Features

  • πŸ”„ Automatic VPN connection via OpenConnect
  • πŸ”‘ Mobile token authentication support
  • πŸ›£οΈ Custom routes configuration
  • πŸš‡ Optional SSH tunnel via sshuttle
  • 🧹 Clean disconnection handling
  • βš™οΈ INI file configuration

πŸ“‹ Prerequisites

  • OpenConnect
  • sshuttle (optional, for SSH tunnel)
  • curl
  • sudo
  • iproute2

πŸ›£οΈ Route Management

Configuration

Routes are defined in the routes section of the vpn_config.ini file:

[routes]
routes_to_replace = 10.0.0.0/24, 192.168.0.0/24

Customization

The vpnc-script has been modified in the set_ipv4_default_route() function to:

  1. Capture the existing default route
  2. Add only specified routes to the VPN tunnel
  3. Avoid creating a default route via VPN

To modify this behavior, you can adjust the function in vpnc-script:

set_ipv4_default_route() {
    $IPROUTE route | grep '^default' | fix_ip_get_output > "$DEFAULT_ROUTE_FILE"

    # Add routes from config file
    if [ -f /tmp/vpn_routes ]; then
        while read -r route; do
            [ -n "$route" ] && $IPROUTE route replace $(echo "$route" | tr -d ' ') dev "$TUNDEV"
        done < /tmp/vpn_routes
    fi

    $IPROUTE route flush cache 2>/dev/null
}

βš™οΈ Configuration

Create a ~/.config/vpn_config.ini file with the following structure:

[vpn]
host = vpn.example.com
url = https://vpn.example.com/
realm = Example
user_agent = Mozilla/5.0
accept = text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
accept_language = en-US,en;q=0.5
accept_encoding = gzip, deflate, br
origin = https://vpn.example.com

[ssh_tunnel]
host = ssh.example.com
nameserver = 8.8.8.8
networks_include = 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
networks_exclude = 192.168.1.0/24

[routes]
routes_to_replace = 10.0.0.0/24, 192.168.0.0/24

πŸ”§ Installation

  1. Clone the repository:
git clone https://github.com/your-username/betterpulse.git
cd betterpulse
  1. Make scripts executable:
chmod u+x betterpulse.sh vpnc-script
  1. Create your configuration file:
mkdir -p ~/.config
cp vpn_config.ini.example ~/.config/vpn_config.ini
  1. Edit the configuration file with your settings:
nano ~/.config/vpn_config.ini

πŸ“ Usage

Standard connection

./betterpulse.sh

Connection without SSH tunnel

./betterpulse.sh noshuttle

πŸ”‘ Mobile Token

To save a mobile token prefix (optional):

echo "your-prefix" > ~/.mobilepassprefix

🀝 Contributing

Contributions are welcome! Feel free to:

  • πŸ› Open an issue
  • πŸ”€ Submit a pull request
  • πŸ’‘ Suggest improvements

πŸ“œ License

This project is under GPLv3 License. See the LICENSE file for more details.

About

A lightweight OpenConnect-based alternative to Pulse Secure VPN client with selective routing capabilities. Route only specific subnets through VPN while keeping regular internet traffic untouched. 🌐

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages