innernet

repository·main·Indexed 26 days ago

https://github.com/tonarino/innernet

A private networking system built on top of WireGuard that uses CIDRs and ACL primitives to manage secure, peer-to-peer connectivity across a distributed network. It includes a client for managing network interfaces and a coordination server (innernet-server) to manage peers and endpoint information. The system provides tools for managing network segments, peer invitations, and endpoint overrides, and includes helper libraries such as hostsfile, netlink-request, innernet-publicip, and wireguard-control.

Tokens
11.8K
Snippets
25
Records
97
Agent score
90%

What's inside innernet

  1. Overview of the `wireguard-control` library

    main

    wireguard-control is a high-level control library designed to get and set configurations for WireGuard interfaces. It is a heavily-modified fork of wgctrl-rs specifically optimized for use with innernet.

    Supported implementations:

    • Linux kernel WireGuard implementation
    • Userspace WireGuard implementations (tested against wireguard-go on macOS and Linux)
  2. Use the `hostsfile` library to manage `/etc/hosts`

    main
    The hostsfile library provides a simple way to programmatically edit or replace specific parts of the /etc/hosts file. It is designed to allow developers to inject custom host mappings into the system's hosts file without manually parsing or overwriting the entire file.
  3. Install innernet and innernet-server

    main

    You can install innernet and innernet-server using your system's package manager or via Cargo. Note that WireGuard must be present on your system (either via kernel support or wireguard-go).

    Arch Linux

    pacman -S innernet

    macOS

    brew install tonarino/innernet/innernet

    Cargo (Latest Releases)

    # Install innernet client
    cargo install --locked innernet
    
    # Install innernet server
    cargo install --locked innernet-server
    cargo install --locked innernet
    cargo install --locked innernet-server
  4. Initialize a new peer

    main

    To add a peer to the network, first create an invitation via the server or an admin peer. The process generates an invitation file (TOML format) that must be transferred securely to the target machine.

    1. Create the invitation (on server/admin):

    sudo innernet-server add-peer <interface>
    # OR (via admin peer)
    sudo innernet add-peer <interface>

    2. Install the client (on the new peer):

    sudo innernet install /path/to/invitation.toml

    Once installed, you can verify the connection with:

    sudo innernet list
    # or for a hierarchical view
    sudo innernet list --tree
    sudo innernet install /path/to/invitation.toml
  5. Uninstall a network

    main

    To permanently remove a created network and its configuration, use the uninstall command on the server. Use this with extreme caution as it is a destructive action.

    sudo innernet-server uninstall <interface>
    sudo innernet-server uninstall <interface>
  6. Associate CIDRs to allow communication

    main

    Peers in different CIDRs cannot communicate unless the CIDRs are explicitly associated. Use an admin peer to create these associations.

    Add an association:

    sudo innernet add-association <interface>

    (The CLI will prompt you to select the two CIDRs to associate.)

    List current associations:

    sudo innernet list-associations <interface>

    Delete an association:

    sudo innernet delete-associations <interface>
    sudo innernet add-association <interface>
  7. Build innernet-server from source

    main
    To build the innernet-server binary, ensure you have rustc/cargo (v1.50.0+), libclang, and libsqlite3 installed. If your target system uses SELinux, enable the selinux feature to ensure correct context maintenance on the /etc/hosts file by installing the selinux-devel package and adding the --features selinux flag to your build command.
  8. Build innernet CLI from source

    main

    To build the innernet client CLI binary, ensure you have rustc/cargo (v1.50.0+) and libclang installed. The resulting binary will be located at ./target/release/innernet.

    cargo build --release --bin innernet
  9. Run Docker-based tests

    main

    You can manually invoke Docker-based tests if a Docker daemon is running. Use the --interactive flag to attach to the server and client innernet Docker containers, allowing you to test commands inside a sandboxed environment.

    docker-tests/build-docker-images.sh
    docker-tests/run-docker-tests.sh [--interactive]
  10. Create a new innernet network server

    main

    Every innernet network requires a coordination server to manage peers and endpoint information. Use the innernet-server CLI to initialize a new network. The wizard will guide you through setting up the root CIDR and an automatic "infra" CIDR for server reachability.

    To start the initialization process:

    sudo innernet-server new

    To run the server manually:

    sudo innernet-server serve <interface>

    On Linux, you can enable it as a systemd service:

    systemctl enable --now innernet-server@<interface>
    sudo innernet-server new