Open MorningLightMountain713 opened 4 months ago
I figured this out with strace.
About 6 hours later lol.
I was missing the create flag. Here is working code
import { createRtNetlink, FlagsNew } from 'netlink'
const socket = createRtNetlink()
const route = { family: 2, dstLen: 24, table: 254, protocol: 'BOOT', scope: 'UNIVERSE', type: 'UNICAST' }
const dstAdd = "192.168.99.0"
const gatewayAdd = "10.10.9.0"
const dst = Buffer.from(dstAdd.split("."))
const gateway = Buffer.from(gatewayAdd.split("."))
const routeAttrs = { dst, gateway }
const options = { flags: FlagsNew.CREATE }
await socket.newRoute(route, routeAttrs, options)
works like a charm now :)
Hi there, I was able to add an address to an interface and bring it up, but I can't add a route for some reason.
Here is a route similar to the one I'm adding, obtained via
getRoutes()
Here is the route using
ip route
:I'm basically copying the route above, just using a different
dst
address. However, when I do this, I get an error.Here is the interface (and index) I'm using as the gateway:
The first object printed below is the
Route
object i'm passing tonewRoute
and the second object is theRouteAttrs
object. Theoif
is the interface index.Here is the code:
What am I doing wrong? Thanks.