I am looking for a function/system call that can be used in C to manage network interfaces of the Linux machine. E.g., I would like to do ip link set wlan0 down
(or up) or ifconfig wlan0 down
, what function can be used for it, apart from system()
?
Create virtual network interfaces on Linux Start off by enabling the dummy kernel module with the following command. Now that the module has been loaded, we can create a new virtual interface. Feel free to name yours however you want, but we will name ours eth0 in this example.
macvlan is a local scope network driver which is configured per-host. As a result, there are stricter dependencies between MACVLAN and external networks, which is both a constraint and an advantage that is different from overlay or bridge. The macvlan driver uses the concept of a parent interface.
To access the functionality provided by the iproute2 tools from software, you can use the Linux rtnetlink API. To make it easier for you, use libraries like libnl.
In case you encounter trouble, there is already a tag called netlink
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With