How can I programmingly (C) know if given interface has static address or one provided by dhcp? I can look at /var/db/dhclient.leases.<interface_name>. Any better/cleaner way? any ioctl I can use?
How can I programmingly (C) know if given interface has static address or one
Share
Read
/etc/rc.conf. Look for lines starting withifconfigand see which of those contain the textDHCP.This will not catch interfaces that were re-configured by running
dhclientmanually. Parsing the leases file would work better in that respect, assuming its permessions allow your program to read it.