No Description

Anton Skorochod 1393e4f550 Merge pull request #12 from karasz/master 3 months ago
netlink 8ac3969fa1 Add LICENSE to netlink folder 3 years ago
.gitignore b6b1520eb8 Initial commit 3 years ago
LICENSE 0ef049f451 Change to MIT license; fix #5 2 years ago 19c50ef6dd Fix typo in README 3 months ago
config.go 38e24089c1 Make linter happy 2 years ago
encryption.go 5cc23a214a Fixes and refactoring 2 years ago
encryption_cbc.go 5cc23a214a Fixes and refactoring 2 years ago
encryption_hmac.go 5cc23a214a Fixes and refactoring 2 years ago
encryption_none.go 5cc23a214a Fixes and refactoring 2 years ago
iface.go a45e1d6a5f Move interface-related functions to separate file 2 years ago
lcvpn.service 0556d66f8f systemd service file 2 years ago
main.go bce90cdc38 v 0.2.0b 2 years ago
packet.go 5cc23a214a Fixes and refactoring 2 years ago
packet_test.go 5cc23a214a Fixes and refactoring 2 years ago
topology.png db7e073920 Add network routing support 3 years ago

LCVPN - Light decentralized VPN in golang

Originally this repo was just an answer on a question "how much time it'll take to write my own simple VPN in golang" (ansert is about 3 hours for first prototype), but now it used in production in different environments.

So, LCVPN is

  • Very light and easy (one similar config on all hosts)
  • Use same config for all hosts (autedetect local params) - useful with puppet etc
  • Uses AES-128, AES-192 or AES-256 encryption (note that AES-256 is much slower than AES-128 on most computers) + optional HMAC-SHA256 or (super secure! 😅 ) NONE encryption (just copy without modification)
  • Communicates via UDP directly to selected host (no central server)
  • Works only on Linux (uses TUN device)
  • Support of basic routing - can be used to connect several networks
  • Multithread send and receive - scaleable for big traffc
  • Due to use so_reuseport better result in case of bigger number of hosts
  • It's still in beta stage, use it on your own risk (and please use only versions marked as "release")

alt tag

Install and run

You need golang (at least 1.5) installed and configured:

$ go get -u

if you have config in /etc/lcvpn.conf

$ sudo $GOPATH/bin/lcvpn

if you want to specify different location of config (or if you need to run several instances)

$ sudo $GOPATH/bin/lcvpn -config lcvpn.conf

if you host is hidden behind firewall (with udp port forward) lcvpn is unable to detect which "remote" is localhost. In this case use next syntax:

$ sudo $GOPATH/bin/lcvpn -local berlin -config lcvpn.conf

Config example

port = 23456
encryption = aescbc
mainkey = 4A34E352D7C32FC42F1CEB0CAA54D40E9D1EEDAF14EBCBCECA429E1B2EF72D21
altkey = 1111111117C32FC42F1CEB0CAA54D40E9D1EEDAF14EBCBCECA429E1B2EF72D21
broadcast =
netcidr = 24
recvThreads = 4
sendThreads = 4

[remote "prague"]
ExtIP =
LocIP =
route =
route =
route =

[remote "berlin"]
ExtIP =
LocIP =
route =

[remote "kiev"]
ExtIP =
LocIP =

where port is UDP port for communication
encryption is aescbc for AES-CBC, aescbchmac for AES-CBC+HMAC-SHA245 or none for no encryption
for aescbc mainkey/altkey is hex form of 16, 24 or 32 bytes key (for AES-128, AES-192 or AES-256)
for aescbchmac mainkey/altkey is 32 bytes longer for none mainkey/altkey mainkey/altkey is just ignored number of remotes is virtualy unlimited, each takes about 256 bytes in memory

Config reload

Config is reloaded on HUP signal. In case of invalid config just log message will appeared, previous one is used.
P.S.: listening udp socket is not reopened for now, so on port change restart is needed

Online key change

altkey configuration option allows specify alternative encryption key that will be used in case if decription with primary one failed. This allow to use next algoritm to change keys without link going offline:

  • In normal state only mainkey is set (setting altkey is more cpu-consuming)
  • Set altkey to new key on all hosts and send HUP signal
  • Exchange altkey and aeskey on all hosts and send HUP signal
  • Remove altkey (with old key) from configs on all hosts and send HUP signal again
  • We are running with new key :)


  • 100% unit test coverage
  • please let me know if you need anything more