Author Topic: DHCP server  (Read 8792 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
DHCP server
« on: February 21, 2011, 08:10:03 PM »
Hi Mark,
  I have a board that receives its ip address from the server without any problems. I have an application that connects to the board, but the only problem is, how to know what ip address the DHCP server gives it? I am using windows platform pc's on the network.

Thanks
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: DHCP server
« Reply #1 on: February 22, 2011, 11:20:20 PM »
Hi Neil

I would try using NETBIOS. Thsi will allow the board to be contacted by its name and it works very well with DHCP since it ensures that the network mask is compatible (a requirement ofr NETBIOS to work). See - http://www.utasker.com/forum/index.php?topic=107.0

There are various discovery strategies also - like listening on a UDP address for broadcasts and answering with the IP address - but these require a suitable program on the PC to request and then display the received values(s).

If NETBIOS works for you it is probably the easiest since it doesn'tr require anything special to run at the PC.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: DHCP server
« Reply #2 on: February 23, 2011, 03:51:26 AM »
Hi Mark,
  The NETBIOS works great, thanks

Neil

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: DHCP server
« Reply #3 on: February 23, 2011, 05:28:36 AM »
Hi Mark,
  If my board gets a different ip address the second time it starts I cant access it by the name.

Within start up I called:
fnStartNetBIOS_Server("Ser1234");

after it gets an ip for the first time I get back the correct ip address returned from ping ser1234, for example 192.168.0.176

If I restart my board and it gets a different ip address it still comes back from the ping ser1234, the original ip, instead of the new ip, then times out, even if I call arp -d (does this just clear my PC arp table?)

If I wait a few minutes it does eventually come up with the correct address, but we need the correct ip as soon as it registers,this is our scenario. We ship our units out with a default ip of 192.168.0.100, and DHCP off. When they get it the first thing they do is switch it on, then setup the unit with various info, they then change to DHCP and restart the unit, and it now gets a new ip address. When they try a ping ser1234, it still comes up 192.168.0.100.

Thanks
Neil


Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: DHCP server
« Reply #4 on: February 23, 2011, 06:23:12 AM »
Hi Mark,
  I seem to get around this by entering the command nbtstat -R   (Purges the name cache and reloads all #PRE entries from LMHOSTS) from
the command prompt. Then I can access the unit by name. It works with windows xp (I dont have a server, so gets ip from router), but havent tested it with other operating systems, but hopefully it will be the same.

Neil


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: DHCP server
« Reply #5 on: February 23, 2011, 11:22:08 AM »
Hi Neil

NETBIOS only requests the address when it doesn't know it. It caches the information and so, when the address/name is change, the cache needs first to time out before NETBIOS requests the address again.

The timeout is a couple of minutes or so. As long as the address doesn't change (in a local network the lease time should be long and often the same IP address is always given too) this shouldn't be disturbing.

Hopefully all OS's support the nbtstat -R command (I remember that arp -d stopped working on my Vista PC but came back in Win 7 - although requires admin rights to actually be executed).

Regards

Mark