1

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?

BЈовић
  • 62,405
  • 41
  • 173
  • 273
amitp
  • 253
  • 6
  • 14
  • 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 Answers4

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
0

Take a look at this question and check the IFF_DYNAMIC flag - that may be set when DHCP is active on an interface.

Community
  • 1
  • 1
Adam Liss
  • 47,594
  • 12
  • 108
  • 150
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