f-15: ia: first subnet try
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
bf00d74a26
commit
cad1a9f46b
7 changed files with 445 additions and 0 deletions
21
internal/netif/route_linux.go
Normal file
21
internal/netif/route_linux.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//go:build linux
|
||||
|
||||
package netif
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
func RouteAdd(iface string, subnet *net.IPNet) error {
|
||||
link, err := netlink.LinkByName(iface)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return netlink.RouteAdd(&netlink.Route{
|
||||
LinkIndex: link.Attrs().Index,
|
||||
Dst: subnet,
|
||||
Scope: netlink.SCOPE_LINK,
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue