Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux network interface management by C code

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()?

like image 746
Angs Avatar asked Jun 10 '13 22:06

Angs


People also ask

How do I create a virtual network interface in Linux?

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.

What is Macvlan Linux?

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.


1 Answers

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

like image 88
thuovila Avatar answered Oct 27 '22 14:10

thuovila