I'm trying to determine whether my IP has been statically or dynamically assigned in Ubuntu 11.04 from within C. The closest I've come is examining /var/lib/dhcp/dhclient.leases
, but that doesn't change if a static IP is assigned (as it caches DHCP leases for future connection attempts).
So... is there a command line utility (for Ubuntu) that will allow me to check if DHCP is enabled or disabled?
Alternatively: the machine is a server dedicated to one application; would it be easier just to maintain an environment variable that keeps track of DHCP status?