Skip to content

Instantly share code, notes, and snippets.

@itcrab
Last active March 27, 2025 13:52
Show Gist options
  • Select an option

  • Save itcrab/56d5316a99fda5f3ca9a37a976c0cbe1 to your computer and use it in GitHub Desktop.

Select an option

Save itcrab/56d5316a99fda5f3ca9a37a976c0cbe1 to your computer and use it in GitHub Desktop.
Install WireGuard on OpenVZ for Ubuntu 22.04 / 20.04

The problem

We have Ubuntu 22.04 / 20.04 VPS on OpenVZ and trying install WireGuard like this:

# curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
# bash ./wireguard-install.sh
OpenVZ is not supported

The solution

# apt install curl cargo
# cargo install boringtun
    Updating crates.io index
  Downloaded boringtun v0.6.0
  Downloaded 1 crate (59.6 KB) in 0.57s
error: there is nothing to install in `boringtun v0.6.0`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency to a Cargo project with `cargo add`.
# echo "fix boringtun v0.6.0 error"
# cargo install boringtun@0.4.0
# echo "continue..."
# ln ~/.cargo/bin/boringtun /usr/local/bin/
# curl -O https://raw.githubusercontent.com/angristan/wireguard-install/master/wireguard-install.sh
# sed -i 's/^\tcheckVirt/#\tcheckVirt/' wireguard-install.sh
# bash ./wireguard-install.sh
# sed -i '19 i Environment=WG_QUICK_USERSPACE_IMPLEMENTATION=boringtun' /lib/systemd/system/wg-quick@.service
# sed -i '20 i Environment=WG_SUDO=1' /lib/systemd/system/wg-quick@.service
# systemctl stop wg-quick@wg0
Warning: The unit file, source configuration file or drop-ins of wg-quick@wg0.service changed on disk. Run 'systemctl daemon-reload' to reload units.
# echo "fix wg-quick warning"
# systemctl daemon-reload
# echo "continue..."
# systemctl stop wg-quick@wg0
# systemctl start wg-quick@wg0
# systemctl status wg-quick@wg0

Done πŸš€

P.S. Side effects after installing WireGuard

apt update - problem

# apt update
Err:1 http://security.ubuntu.com/ubuntu focal-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu focal InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

apt update - solution πŸš€

# echo "nameserver 8.8.8.8" >> /etc/resolv.conf
# apt update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment