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?
Asked
Active
Viewed 4,942 times
1
-
I think you should edit your question with details on how you get the IP address in the first place. I assumed you ran BusyBox' dhcp client, but that seems wrong. – unwind Oct 08 '09 at 13:20
4 Answers
4
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.

Troglobit
- 41
- 3
1
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.

unwind
- 391,730
- 64
- 469
- 606
-
the device get its address using ip command and not udhcp so dumpleases does not work – amitp Oct 08 '09 at 11:52
0
Take a look at this question and check the IFF_DYNAMIC flag - that may be set when DHCP is active on an interface.
0
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.

gnud
- 77,584
- 5
- 64
- 78