Skip to content

Converts and adds IPv4- to IPv6-Adresses and AllowedIP-Entries for wireguard-interfaces

License

Notifications You must be signed in to change notification settings

Ruakij/wg-ipv6-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wg-ipv6-converter

Converts and adds IPv4- to IPv6-Adresses and AllowedIP-Entries for wireguard-interfaces.



1. Overview

The program will convert IPv4-only wireguard-interfaces to IPv6. It converts and adds the Address of the Interface and AllowedIPs-Entries with optional filters.

IPv6-Adresses are generated based on the IPv4-Adress.

Beware: This program needs NET_ADMIN privileges for setting Adresses and to access the wireguard-daemon.


2. Install

2.1. From Binary

  1. Download the appripriate binary for your system from the Release-page (or build from sources)
  2. Save at an appropriate location e.g. /usr/bin/local/wg-ipv6-converter
  3. Make executeable: chmod +x /usr/bin/local/wg-ipv6-converter

2.2. From sources

Clone the repository and compile using go build ./cmd/app


3. Setup

3.1. Environment

Variable Description Default
INTERFACE* Wireguard-Interface Name
IPV6_FORMAT Format to use for converting v4 to v6
The CIDR-Mask gets translated using 128 - 24 - Mask
e.g. 10.0.100.5/16 -> fc12::0a00:6405/96
fc12::%02x%02x:%02x%02x/%d
FILTER_PREFIX Prefix to filter for IP-Networks 100.100
RECHECK_INTERVAL Interval in go-time-format to recheck AllowedIPs entries in case something changed 5m

* Required


3.2. Examples

3.2.1. Netbird

Netbird is at the moment only IPv4-compatible, with this program running where necessary, some basic IPv6-setup can be archieved.

INTERFACE="wt0" ./wg-ipv6-converter

Or using a systemd-service based on the example:

[Unit]
Description=WireGuard IPv6 converter for netbird
BindsTo=netbird.service
After=netbird.service

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/bin/wg-ipv6-converter
Restart=always
RestartSec=30

Environment="INTERFACE=wt0"
Environment="RECHECK_INTERVAL=60s"

[Install]
WantedBy=multi-user.target

4. License

This project is licenced under GPLv3.
See LICENSE for more details.

About

Converts and adds IPv4- to IPv6-Adresses and AllowedIP-Entries for wireguard-interfaces

Resources

License

Stars

Watchers

Forks