DHCP - getting different IP address each time I restart
#1
Posted 06 November 2010 - 09:38 AM
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#2
Posted 06 November 2010 - 10:01 AM
#3
Posted 06 November 2010 - 10:45 AM
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#4
Posted 06 November 2010 - 11:00 AM
foreach (NetworkInterface net in NetworkInterface.GetAllNetworkInterfaces()) { Debug.Print(net.IPAddress.ToString()); Debug.Print(ByteUtil.PrintBytes(net.PhysicalAddress)); net.RenewDhcpLease(); } foreach (NetworkInterface net in NetworkInterface.GetAllNetworkInterfaces()) { Debug.Print(net.IPAddress.ToString()); Debug.Print(ByteUtil.PrintBytes(net.PhysicalAddress)); }
The output looks like this:
192.168.178.82
5C-86-4A-00-00-E5
0.0.0.0
5C-86-4A-00-00-E5
If I reboot the device I get 192.168.178.83.
Michael
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#5
Posted 06 November 2010 - 11:17 AM
Attached Files
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#6
Posted 06 November 2010 - 11:38 AM
Hi,
maybe I found the problem. When switching on the Netduino Plus I get following DHCP request:
1) DISCOVER with YourIP 0.0.0.0
2) Reply from my DHCP server with OFFER and IP address 192.168.178.96
3) REQUEST with YourIP still 0.0.0.0 instead of the offered IP 192.168.178.96
4) Reply with ACK
When comparing i.e. with Thaoe-II I have a difference with the step 3, the YourIP and ServerIP is filled correct instead of using 0.0.0.0.
I have attached the capture of both requests.
Michael
I don't really know how to tell this but I will give it a try.
The step 3 when it sends out a request should be 0.0.0.0 for a device that have never got an ip adress before. It will send it as a broadcast so that all the dhcp servers on the network will know about it.
The reason why the Thaoe will send it it's ip adress I don't know but as far as i know the whole DORA process is with Boradcast (Except when there is only a renew, and not a release renew)
I would really like to see the captures with wireshark though.
Sorry for the bad english..
#7
Posted 06 November 2010 - 02:03 PM
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#8
Posted 06 November 2010 - 02:26 PM
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#9
Posted 06 November 2010 - 07:40 PM
#10
Posted 06 November 2010 - 09:01 PM
yes, the same happens with other DHCP servers I have here.
I had a look on RFC 2132, 9.14:
This option is used by DHCP clients to specify their unique
identifier. DHCP servers use this value to index their database of
address bindings. This value is expected to be unique for all
clients in an administrative domain.
Identifiers SHOULD be treated as opaque objects by DHCP servers.
The client identifier MAY consist of type-value pairs similar to the
'htype'/'chaddr' fields defined in [3]. For instance, it MAY consist
of a hardware type and hardware address. In this case the type field
SHOULD be one of the ARP hardware types defined in STD2 [22]. A
hardware type of 0 (zero) should be used when the value field
contains an identifier other than a hardware address (e.g. a fully
qualified domain name).
For correct identification of clients, each client's client-
identifier MUST be unique among the client-identifiers used on the
subnet to which the client is attached. Vendors and system
administrators are responsible for choosing client-identifiers that
meet this requirement for uniqueness.
This is the part that DHCP servers use to identify the client's MAC address.
I think we need to add this.
Michael
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#11
Posted 06 November 2010 - 09:09 PM
#12
Posted 06 November 2010 - 09:59 PM
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#13
Posted 07 November 2010 - 08:35 AM
#14
Posted 07 November 2010 - 11:08 AM
Seems that the clientID = 1 is missing in the REQUEST (step 3). I have monitored other DHCP requests and all are sending clientID = 1 which means that the DHCP server should take care of the MAC address (as far as I understand the DHCP protocol).
Michael
Hi Michael,
You probably right concerning clientID, but it works fine with my Windows Server 2008 R2 DHCP server. And I use a reservation to fix my NetduinoPlus address.
Another strange behavior is that DHCP request take the configured static IP address to forge the IP packet. In case of this ip address use another subnet, it could be a issue. So, I have define 0.0.0.0 for static IP, subnet and gw.
If we definitly conclude that ClientID must be set, it probably not a big deal to fix it.
Pascal
#15
Posted 07 November 2010 - 01:49 PM
You probably right concerning clientID, but it works fine with my Windows Server 2008 R2 DHCP server. And I use a reservation to fix my NetduinoPlus address.
Hi Pascal,
yepp, seems that it is working with Microsoft DHCP server. I tried it with the AVM box as well as another Linux box and had no luck. Not sure who could give a try to add this option, should not be a big deal.
Can you do another test? What if you try to renew the lease in your application? Think of a module that you will plug to different networks while it is running. Is this working? I have configured the IP to 0.0.0.0, then I get an IP address from my DHCP... then I disconnect from network... connect again and renew the lease and get 0.0.0.0. :-(
Michael
http://michael-schwarz.blogspot.com/
http://www.ajaxpro.info/
#16
Posted 07 November 2010 - 11:00 PM
Hi Pascal,
yepp, seems that it is working with Microsoft DHCP server. I tried it with the AVM box as well as another Linux box and had no luck. Not sure who could give a try to add this option, should not be a big deal.
Can you do another test? What if you try to renew the lease in your application? Think of a module that you will plug to different networks while it is running. Is this working? I have configured the IP to 0.0.0.0, then I get an IP address from my DHCP... then I disconnect from network... connect again and renew the lease and get 0.0.0.0. :-(
Michael
Hi Micheal,
Unfortunatly, I'm traveling this week. Without possibility to test. I will try next week-end if anybody have done it before.
Pascal
#17
Posted 07 November 2010 - 11:16 PM
#18
Posted 14 November 2010 - 12:51 PM
I have tested the last version with this code :
NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); networkInterfaces[0].EnableDhcp(); networkInterfaces[0].RenewDhcpLease();
Netduino is already configured to use DHCP, the first request works fine. But, the renew doesn't works.
I'll wait for debugging capability to do more testing,
Also, I made some tests to evaluate the posibility to implement a little TCP/IP stack completly in managed code. It would be a good way to learn more by a easier way. The only bad effect would be the performance. Regarding FLASH/RAM use, it probably near the native code size. First implementation will be for the enc28j60 chip.
I'll let you know about it ...
Pascal
#19
Posted 15 November 2010 - 07:22 PM
#20
Posted 31 January 2011 - 06:30 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users