Skip to content

Installation and first run ​

ours runs only on Linux: a build for any other target (macOS, Windows, BSD, Android) stops with an error from ours-net-sys. Prebuilt binaries are published with releases and installed by the installer below; otherwise the binary is built from source.

Installer ​

On Linux x86_64 and aarch64 the quickest way is the interactive installer, run as root:

sh
curl -fsSL https://janeblower.github.io/ours/install.sh | sh

It detects the system (Debian-based with systemd, or OpenWrt with procd), the architecture and the free space, and asks about each setting; Enter accepts the default in brackets: the architecture, the build (the UPX-compressed binary is the default when little space is free, as on an OpenWrt overlay), the version (latest or a tag), the binary path (/usr/local/bin/ours on Debian, /usr/bin/ours on OpenWrt), the configuration directory (/etc/ours) and whether to install and enable the service. After a summary it asks Install? [Y/n]. Without a terminal it accepts all defaults.

The installer downloads the binary from the GitHub release, checks it against SHA256SUMS, and installs the systemd unit or the procd script dist/openwrt/ours.init. An existing configuration is never overwritten; if there is none, it writes the one from First run and checks it with ours check.

FlagMeaning
--yesAccept all defaults without asking
--arch x86_64|aarch64Architecture
--upx, --plainUPX-compressed or plain binary
--version <tag>Release tag instead of the latest
--bin <path>, --conf-dir <dir>Binary path, configuration directory
--no-serviceDo not install the service
--uninstallRemove the binary and the service, keep the configuration
--purgeWith --uninstall: remove the configuration directory too

To read the script before running it, download install.sh and run sh install.sh.

Requirements ​

  • rustup. The Rust version is pinned in rust-toolchain.toml; on the first build rustup installs it by itself, together with the x86_64-unknown-linux-musl target.
  • A C compiler (gcc or clang) and make: part of the cryptography is written in C and assembly, and on x86_64 and aarch64 the jemalloc allocator is built into the binary (feature jemalloc; without it, and on other architectures, the system malloc is used).
  • For a static build, musl-gcc (the musl-tools package on Debian and Ubuntu).

Platforms ​

PlatformHow it is checked
Linux x86_64, glibcthe full test suite and Clippy
Linux x86_64, musl (static)end-to-end scenarios in Docker, against sing-box as well
Linux aarch64, glibccross build, ours version under qemu; the tests are not run there
Other Linux architectures (aarch64 musl, MIPS, ARMv7)not checked: they may build, nothing is promised

Rust: 1.99 or newer (rust-version in Cargo.toml, checked with that toolchain); the version the repository is developed with is pinned in rust-toolchain.toml.

QUIC comes from a fork of quinn 0.11 pinned in [patch.crates-io], so ours builds from git only: cargo install ours from crates.io does not work. Why the fork exists and what it changes: quinn fork.

Kernel requirements ​

Developed on kernel 6.18. What individual features need:

FeatureWhat it needs from the kernel and permissions
Network inbounds and outbounds, routing, DNSNothing special
tproxyModules nft_tproxy, nf_tproxy_ipv4, nf_tproxy_ipv6; with auto_nft also nf_tables and nft_fib_inet, and CAP_NET_ADMIN
redirectYour own redirect/dnat rules in nftables or iptables
tun/dev/net/tun, CAP_NET_ADMIN; with auto_redirect also nf_tables, nft_redir, nft_nat, nft_reject_inet
WireGuardmode: userspace — /dev/net/tun, CAP_NET_ADMIN, UDP segmentation on the device since Linux 6.2 (works without it on an older kernel); mode: kernel — the wireguard or amneziawg module
kTLS (unstable, separate build)The tls module; TLS 1.3 key updates in the kernel need Linux 6.14, on an older kernel a connection that gets one is closed with an error

To load the modules: sudo modprobe -a nft_tproxy nf_tproxy_ipv4 nf_tproxy_ipv6 nft_fib_inet.

Building ​

From the repository root:

sh
cargo build -p ours --release

The binary is target/release/ours. It is dynamically linked against the glibc of the system it was built on.

A static binary that runs on any Linux of the same architecture, OpenWrt included:

sh
cargo build -p ours --release --target x86_64-unknown-linux-musl

The binary is target/x86_64-unknown-linux-musl/release/ours.

For aarch64 (Raspberry Pi, routers, ARM servers), cross-build on x86_64 with gcc-aarch64-linux-gnu:

sh
rustup target add aarch64-unknown-linux-gnu
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
cargo build -p ours --release --target aarch64-unknown-linux-gnu

Or build directly on an aarch64 machine with the same command as on x86_64. Which platforms are checked and how is listed in Platforms.

To check the build:

sh
./target/release/ours version

version prints the version and the list of features built in.

Building without unneeded protocols ​

To leave out protocols you don't need, see Build your own.

Installing ​

The binary needs no other files; copy it into PATH:

sh
sudo install -m 755 target/release/ours /usr/local/bin/ours

Permissions: a port below 1024 requires CAP_NET_BIND_SERVICE; tun and auto_nft require CAP_NET_ADMIN; tproxy and dial.fwmark require CAP_NET_ADMIN or CAP_NET_RAW; dial.interface on Linux before 5.7 requires CAP_NET_RAW. Without these an ordinary user is enough. ours check warns of what the configuration needs and the process lacks; at startup a refused operation names the capability it needs.

First run ​

The minimal configuration is a local SOCKS5 and HTTP proxy that connects directly. config.yaml:

yaml
inbounds:
  local:
    mixed:
      listen: 127.0.0.1:1080

outbounds:
  direct:
    direct:

route:
  final:
    outbound: direct

Check the configuration without opening anything, then run it:

sh
ours check -c config.yaml
ours run -c config.yaml

Check it from another terminal:

sh
curl -x socks5h://127.0.0.1:1080 https://www.example.com/
curl -x http://127.0.0.1:1080 https://www.example.com/

Without -c, config.yaml in the current directory is used. The other flags are in Command line.

Running as a service ​

The systemd unit is dist/systemd/ours.service: the binary in /usr/local/bin/ours, the configuration in /etc/ours/config.yaml.

sh
sudo install -m 644 dist/systemd/ours.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now ours
sudo systemctl reload ours   # reread the configuration (SIGHUP)

What matters in it:

  • Type=notify marks the service ready after the listeners and optional dashboard start.
  • TimeoutStopSec=15s gives systemd a deadline for stopping the process.
  • Restart=always and StartLimitIntervalSec=0 — the process is restarted after any exit, no matter how many times it has failed.
  • ExecStopPost=-ours clean — after an exit, including one by SIGKILL or OOM, removes the nftables tables and the routing rules of auto_nft and tun. Otherwise they keep steering the host's and the LAN's traffic into a closed port. The next ours run removes them too, but without a supervisor there may be no next run.
  • LimitNOFILE=1048576 — the open file limit. ours run itself raises the soft limit to the hard one at startup (as the Go runtime does), but only whoever starts the process sets the hard limit.

The process runs as root: tun, tproxy and auto_nft need CAP_NET_ADMIN.

Server and client ​

An example pair of a VLESS/REALITY server and a client, with key generation, is in Server. Other protocols are in Protocols.

Next ​

GPL-3.0-or-later