vpn-router: Switch VPN with web interface for LAN

[ bsd3, library, program, system ] [ Propose Tags ] [ Report a vulnerability ]

vpn-router is a service with the web interface allowing users of a local network to control VPN bypass from their devices. The service is tested with AmneziaVPN 4.8.10.

Motivation

It is convinient if the whole WiFi network is connected through VPN, but user might not access some resources sometimes. Having two networks deployed might be an option, though destop stations usually connect through the Ethernet cable, and such approch doubles the number of WiFi routers. Hopping between WiFi networks might not be as ergonomic as it should be due to bugs in the connectivity check in Android and Windows.

Installation

There are several ways to install the app: - with conventional Haskell tools directly - nix-build - download the statically link version of vpn-router from github - nixos module

NixOS module

  1. Copy vpn-router.nix to /etc/nixos.

  2. Modify /etc/nixos/configuration.nix as follows:

  imports =
    [ # ... ./hardware-configuration.nix
      ./vpn-router.nix
    ];
  programs = {
    vpn-router = {
      # the service will try to detect gateway and dev automatically if not specified
      # gateway = "192.168.1.1";
      # dev = "wlp2s0";
      # port = 3000;
      enable = true;
    };
  };

Update configuration and check the new service:

nixos-rebuild switch
systemctl status "vpn-router.service"

Once the service is running open link http://my-router:3000/ on device other than the router. There is a simple UI available with a toggle button to control the VPN bypass.

onoff

The service can be stopped, because it only adjusts routing options in the Linux kernel, but at every start all settings related to the routing table and the packet mark specified in configuration will be cleared.

Manual configuration

NixOS module provides a service ready to go, but the standalone binary can launched without configuration under sudo or by a regular user after setting proper capabilities to access ip and iptables. The nixified version is shipped with these tools, but static elf assumes that host has these networking apps pre-installed.

Usage: vpn-router run [-d|--dev ARG] [-g|--gateway ARG] [-t|--routing-table ARG]
                      [-m|--packet-mark ARG] [-p|--port PORT]

   launch the service exposed over HTTP

Available options:
  -d,--dev ARG             network device name connected to the Internet
                           (default: "wlp2s0")
  -g,--gateway ARG         network device name connected to the Internet
                           (default: 192.168.1.1)
  -t,--routing-table ARG   routing table id (default: 7)
  -m,--packet-mark ARG     packet mark (default: 2)
  -p,--port PORT           HTTP port to listen (default: 3000)
  -h,--help                Show this help text

Default values for gateway and device are dynamically detected.

Development environment

HLS should be available inside the dev environment.

$ nix-shell
$ emacs src/VpnRouter/Net.hs &
$ cabal build
$ cabal test
$ nix-build
$ sudo ./result/bin/vpn-router run

Static linking

Static is not enabled by default, because GitHub CI job times out.

nix-build --arg staticBuild true
# faster build on beefy machine
nix-build --cores 20 -j 20 --arg staticBuild true

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1
Change log changelog.md
Dependencies base (>=4.7 && <5), blaze-markup (<1), conduit (<2), conduit-extra (<2), network (<4), optparse-applicative (<1), regex-tdfa (<2), relude (>=1.2.2 && <2), tagged (<1), template-haskell (<3), trace-embrace (<2), typelits-printf (<1), unliftio (<1), vpn-router, wai (<4), yesod-core (<1.8) [details]
Tested with ghc ==9.12.2
License BSD-3-Clause
Copyright Daniil Iaitkov 2026
Author Daniil Iaitskov
Maintainer dyaitskov@gmail.com
Uploaded by DaniilIaitskov at 2026-02-04T20:39:08Z
Category System
Home page http://github.com/yaitskov/vpn-router
Bug tracker https://github.com/yaitskov/vpn-router/issues
Source repo head: git clone https://github.com/yaitskov/vpn-router.git
Distributions
Executables vpn-router
Downloads 1 total (1 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]