Skip to content

A pure Go IPv6 Router Advertisement library and stand-alone daemon

License

Notifications You must be signed in to change notification settings

YutaroHayakawa/go-ra

Repository files navigation

go-ra

Go Reference

Provides the ra package that implements a router-side functionality of IPv6 Neighbor Discovery mechanism (RFC4861 and related RFCs). It also provides a stand-alone daemon gorad and CLI tool gora to interact with it. While the existing mdlayher/ndp package provides a low-level protocol functionalities (packet encoding, raw-socket wrapper, etc), go-ra implements an unsolicited and solicited advertisement machinery and declarative configuration interface on top of it.

Features

  • Basic RA mechanism defined in RFC4861
  • Router MAC address discovery with Source Link Layer Address option
  • MTU discovery with MTU option
  • Prefix discovery with Prefix Information option
  • DNS configuration discovery with RDNSS/DNSSL option
  • Route advertisement with Route Information option
  • NAT64 prefix discovery with PREF64 option

Installation

  • Library: Use Go Modules as usual
  • Stand-alone Binary: Visit release page and install pre-build binaries
  • Container Image: Visit registry page and pull images

Basic Usage

As a library

// Build a configuration
config := ra.Config{
	  Interfaces: []*ra.InterfaceConfig{
		    {
			      Name: "eth0",
			      // Send unsolicited RA once a second
			      RAIntervalMilliseconds: 1000, // 1sec
		    },	
	  },
}

// Create an RA daemon
daemon, _ := ra.NewDaemon(&config)

// Run it
ctx, cancel := context.WithCancel(context.Background())
go daemon.Run(ctx)

// Get a running status
status := daemon.Status()
for _, iface := range status.Interfaces {
    fmt.Printf("%s: %s (%s)\n", iface.Name, iface.State, iface.Message)
}

// Change configuration and reload
config.Interfaces[0].RAIntervalMilliseconds = 2000 // 2sec
err := daemon.Reload(ctx, &config)
if err != nil {
    panic(err)
}

// Stop it
cancel()

As a stand-alone daemon

Create a configuration file. This configuration will be translated into the Config object and passed to the daemon. Please see the godoc for more details.

interfaces:
- name: eth0
  raIntervalMilliseconds: 1000 # 1sec

Start daemon. You need a root privilege to run it.

$ sudo gorad -f config.yaml

Get status.

$ gora status
Name         Age    TxUnsolicited    TxSolicited    State      Message
eth0         22s    21               1              Running

Modify and reload configuration

$ gora reload -f config.yaml

Motivation

Our original motivation for this project was use it with gobgp library to do BGP Unnumbered (see our integration test) which for us, makes sense to reinvent the RA daemon to not introduce an external non-go dependency.

About

A pure Go IPv6 Router Advertisement library and stand-alone daemon

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages