Ip link add oni0 link eno0 addr 00:11:22:33:44:55 up type macvlan mode private

Hello,

Thing I would to do is adding a macvlan interface in Rust.

The result should be the same as of

ip link add oni0 link eno0 addr 00:11:22:33:44:55 up type macvlan mode private

What I found until now as closest thing iis crate nispor ( https://crates.io/crates/nispor ) which has MacVlanInfo ( MacVlanInfo in nispor - Rust ). But that is only "view", not "create".

Which crate has ip link add functions?

Things I also would like to know:

  • How did you find that crate? ( For increasing websearch skills )
  • Use case example

Regards
Geert Stappers

One of the dependencies of nispor is rtnetlink, from looking in nispor/src/lib/Cargo.toml at base · nispor/nispor · GitHub. I vaguely remember that “netlink” is how at least some Linux networking is configured, so looking at rtnetlink — Rust network library // Lib.rs and checking the API Reference link, I see it has a LinkAddRequest which it says is the same as ip link add and which has a macvlan function, so it looks like that’s what you’re looking for.

I haven’t tried it, though. I only have easy access to Linux with WSL and I don’t know what a MACVLAN is supposed to do, so in this case I’ll leave that to you.

I didn’t even try to use a search engine, which is a sad state of affairs.

1 Like

Thanks. It did bring me to [examples/create_macvlan.rs[(https://github.com/rust-netlink/rtnetlink/blob/main/examples/create_macvlan.rs).

It does a large part of what I'm looking for, for the missing part there is now example/create_macvlan.rs and MAC-address · Issue #30 · rust-netlink/rtnetlink · GitHub

macvlan in a few words: On top of a physical network interface an additional MAC-address that can be used a network interface.