Giter Club home page Giter Club logo

ipv6rd's Introduction

ipv6rd

Calculate 6RD prefixes from DHCP (IPv4) OPTION_6RD (212).

Either use this library or the included 6rdcalc command.

6rdcalc

This tool is useful for scripting, e.g. when used in a dhclient hook.

There's ipv6calc, why create a new tool? This tool is written in Go, so it's easily portable to multiple architectures. Since it also does OPTION_6RD parsing, it saves you from calculating the initial prefix in sh/ash/Bash and lets you easily create new /64 prefixes for your networks (LAN, device, docker, etc.).

Installation

go install github.com/mafredri/ipv6rd/cmd/6rdcalc@latest

Other platforms:

git clone https://github.com/mafredri/ipv6rd.git
cd ipv6rd
GOOS=linux GOARCH=mips go build ./cmd/6rdcalc
scp 6rdcalc unifi-security-gateway.local:
ssh [email protected]
ubnt@unifi-security-gateway:~$ ./6rdcalc

Tunnel configuration

Generating the tunnel configuration from the given 6RD configuration:

6rdcalc tunnel 84.240.100.100 "14 38 8193 8195 62464 0 0 0 0 0 84.251.255.254"

The value for IP comes from $new_ip_address and the value for OPTION 6RD comes from $new_option_6rd, both available in a dhclient hook.

Example output:

PREFIX="2001:2003:f400::/38"
RELAY_PREFIX="84.240.0.0/14"
BORDER_RELAY="::84.251.255.254"
DELEGATED_PREFIX="2001:2003:f464:6400::/56"
TUNNEL_ADDRESS="2001:2003:f464:6400::/128"

Usage in scripts:

eval "$(6rdcalc tunnel 84.240.100.100 "14 38 8193 8195 62464 0 0 0 0 0 84.251.255.254")"
echo "$DELEGATED_PREFIX"

Network configuration

Use the network subcommand to slice a /64 out of your delegated prefix.

6rdcalc network 2001:2003:f464:6400::/56 0:0:0:10::1/64

The DELEGATED PREFIX comes from the tunnel configuration and the IP is the wanted network IP in CIDR notation, without the delegated prefix.

Example output:

NETWORK="2001:2003:f464:6410::/64"
ADDRESS="2001:2003:f464:6410::1/64"
IP="2001:2003:f464:6410::1"

Usage in scripts:

eval "$(6rdcalc network 2001:2003:f464:6400::/56 0:0:0:10::1/64)"
echo "$IP"

Verification

Use the contains subcommand to figure out if your existing configuration needs updating.

DELEGATED_PREFIX="2001:2003:f464:6400::/56"
ADDRESS="2001:2003:f464:6410::1/64"
IP="2001:2003:f464:6410::1"

$ 6rdcalc contains "$DELEGATED_PREFIX" "$IP"
true
$ 6rdcalc contains "$DELEGATED_PREFIX" "$ADDRESS"
true
6rdcalc contains "$DELEGATED_PREFIX" "2001:2003:f464:0000::1"
false

Configuration of dhclient

option option-6rd code 212 = { integer 8, integer 8, ip6-address, array of ip-address };
# OR
option option-6rd code 212 = {
	integer 8, integer 8,
	unsigned integer 16, unsigned integer 16, unsigned integer 16, unsigned integer 16,
	unsigned integer 16, unsigned integer 16, unsigned integer 16, unsigned integer 16,
	array of ip-address
};

interface "eth0" {
	also request option-6rd;
}

Resources

ipv6rd's People

Contributors

mafredri avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.