netcfg

package
v0.6.3-beta01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

netcfg is a stateless helper to setup interface attributes IP, route, interface state, etc

Index

Constants

View Source
const (
	RPFilterNoValidation = iota
	RPFilterStrict
	RPFilterLoose
)

Variables

View Source
var ErrNotFound = errors.New("default route not found")

Functions

func DefaultRoute

func DefaultRoute() (netip.Addr, string, error)

func HostHasIP

func HostHasIP(ipAddress netip.Addr) bool

func InterfaceDown

func InterfaceDown(ifname string) error

func InterfaceHasIP

func InterfaceHasIP(ifname string, ipAddress netip.Addr) bool

func InterfaceIPAdd

func InterfaceIPAdd(ifname string, ip netip.Addr) error

InterfaceIPAdd adds `ip` to interface `ifname`

func InterfaceIPDel

func InterfaceIPDel(ifname string, ip netip.Addr) error

InterfaceIPDel removes `ip` from interface `ifname`

func InterfaceIPSet

func InterfaceIPSet(ifname string, ip netip.Addr) error

InterfaceIPSet removes old IP addresses from interface `ifname` and sets `ip` as the only address

func InterfaceSetMTU

func InterfaceSetMTU(ifname string, mtu uint32) error

func InterfaceSetRPFilter

func InterfaceSetRPFilter(ifname string, mode RPFilterMode) error

func InterfaceUp

func InterfaceUp(ifname string) error

func IsDefaultRoute

func IsDefaultRoute(addr *netip.Prefix) bool

IsDefaultRoute returns true if addr == 0.0.0.0/0

func RouteAdd

func RouteAdd(ifname string, gw *netip.Addr, ip *netip.Prefix) error

func RouteDel

func RouteDel(ifname string, ip *netip.Prefix) error

func RouteReplace

func RouteReplace(ifname string, gw *netip.Addr, ip *netip.Prefix) error

func RouteSearch

func RouteSearch(ip *netip.Prefix) (found bool, ifname string)

Types

type RPFilterMode

type RPFilterMode int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL