Reputation: 283
I am working on embedded device who run BusyBox.
The system is getting its address by using the ip command.
I want to figure out from my C program whether the device
ip static or received from DHCP server. How do I do that?
Upvotes: 1
Views: 5542
Reputation: 41
I don't know how your users interact with your embedded system. But on ours (same components) we have CLI that registers the chosen DHCP/STATIC type setting in a SHM struct (db) per interface.
Essentially, you need to keep track of how the IP of an interface was set.
Upvotes: 4
Reputation: 78618
If you control the enviroment, I suggest setting an env variable, or creating a flag file somewhere you can stat, when the IP adress is set.
Upvotes: 0
Reputation: 48330
Take a look at this question and check the IFF_DYNAMIC flag - that may be set when DHCP is active on an interface.
Upvotes: 1
Reputation: 400109
The dumpleases command is supposed to show the current leases. I guess if you can determine that you have an IP address, but no lease, then the address is static.
Upvotes: 1