I would like to check a network devices status e.g. promiscous mode. Basically like shown with ip a command.
Maybe someone could push me in the right direction?
I want to do this in C for linux so linux specific headers are available.
I would like to check a network devices status e.g. promiscous mode. Basically like shown with ip a command.
Maybe someone could push me in the right direction?
I want to do this in C for linux so linux specific headers are available.
You need to use the
SIOCGIFFLAGS
ioctl to retrieve the flags associated with an interface. You can then check if theIFF_PROMISC
flag is set:If you want to set the interface to promiscuous mode, you will need root privileges, but you can simply set the field in
ifr_flags
and use theSIOCSIFFLAGS
ioctl: