Author Topic: dhcp and DNS search order  (Read 2924 times)

Offline alager

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
dhcp and DNS search order
« on: June 21, 2010, 06:39:44 PM »
Now that our product is out in "the wild" we've found that a fair amount of dhcp servers are giving "bogus" DNS server information.  After poking around in the utasker code, I found that fnReadDHCP_IP() is setup to return the last IP of possibly multiple DNS server IP addresses.

Example option 6 response:
IP Address: 2.2.2.2
IP Address: 3.3.3.3
IP Address: 192.168.10.2
IP Address: 192.168.10.1
fnReadDHCP_IP() will return 192.168.10.1.

Is there a reason to use the last IP given, as opposed to the first one?
Please ignore the actual values of of the first two IPs, this is my testing of what to do when we receive bad DNS values.

Thanks,
Aaron

EDIT:
I've made the following change to fnReadDHCP_IP(), and so far so good.
Code: [Select]
//unsigned char *ptr = (*data + ucMsgLength - IPV4_LENGTH + 1);
unsigned char *ptr = (*data + 1);
But I'm not an Ethernet expert.  Are there times when this could cause problems for the other IPs that are passed in?
« Last Edit: June 21, 2010, 07:03:34 PM by alager »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3069
    • View Profile
    • uTasker
Re: dhcp and DNS search order
« Reply #1 on: June 24, 2010, 09:13:00 PM »
Hi Aaron

There is no specific reason for taking the last IP address in the list. The code unsigned char *ptr = (*data + ucMsgLength - IPV4_LENGTH + 1); simply works back from the end of the list to the start of the IP entry. The fact that there may be multiple entries is not actually considered. unsigned char *ptr = (*data + 1); therefore takes the first entry, which will be the same if there is only one.

Why some DHCP servers give bogus addresses at the end of this list is however another question. If the one at the start of the list is more reliable it is probably better to use it - theoretically it shouldn't make a difference but it is the practical side which counts most...

Regards

Mark