Documentation ¶
Overview ¶
netcfg is a stateless helper to setup interface attributes IP, route, interface state, etc
Index ¶
- Constants
- Variables
- func DefaultRoute() (netip.Addr, string, error)
- func HostHasIP(ipAddress netip.Addr) bool
- func InterfaceDown(ifname string) error
- func InterfaceHasIP(ifname string, ipAddress netip.Addr) bool
- func InterfaceIPAdd(ifname string, ip netip.Addr) error
- func InterfaceIPDel(ifname string, ip netip.Addr) error
- func InterfaceIPSet(ifname string, ip netip.Addr) error
- func InterfaceSetMTU(ifname string, mtu uint32) error
- func InterfaceSetRPFilter(ifname string, mode RPFilterMode) error
- func InterfaceUp(ifname string) error
- func IsDefaultRoute(addr *netip.Prefix) bool
- func RouteAdd(ifname string, gw *netip.Addr, ip *netip.Prefix) error
- func RouteDel(ifname string, ip *netip.Prefix) error
- func RouteReplace(ifname string, gw *netip.Addr, ip *netip.Prefix) error
- func RouteSearch(ip *netip.Prefix) (found bool, ifname string)
- type RPFilterMode
Constants ¶
View Source
const ( RPFilterNoValidation = iota RPFilterStrict RPFilterLoose )
Variables ¶
View Source
var ErrNotFound = errors.New("default route not found")
Functions ¶
func InterfaceDown ¶
func InterfaceIPAdd ¶
InterfaceIPAdd adds `ip` to interface `ifname`
func InterfaceIPDel ¶
InterfaceIPDel removes `ip` from interface `ifname`
func InterfaceIPSet ¶
InterfaceIPSet removes old IP addresses from interface `ifname` and sets `ip` as the only address
func InterfaceSetMTU ¶
func InterfaceSetRPFilter ¶
func InterfaceSetRPFilter(ifname string, mode RPFilterMode) error
func InterfaceUp ¶
func IsDefaultRoute ¶
IsDefaultRoute returns true if addr == 0.0.0.0/0
Types ¶
type RPFilterMode ¶
type RPFilterMode int
Click to show internal directories.
Click to hide internal directories.