Host name to DHCP

Is it possible to specify the name of the unit (the host name) to the DHCP server, so the unit can be recognized by DNS instead of just it’s IP address?

Muscleman,DNSgethostbyname() function call registers your host name on the DNS Server. Please explain how DNSgethostbyname would know what host name to provide to the DNS server. If this actually occurs it should be documented. The description of DHCPHostNowBound stub function is often pointed out as a possible way to do this, however, no sample is supplied.

DNSgethostbyname() function call registers your host name on the DNS Server.

I believe what Mr. Nkfelectronics is looking for is the implementation of DHCP option 12 (Host Name), whereby the DHCP server is asked to register the device’s host name with the DNS server. This is certainly possible. Please refer to the attached DHCPOptions.doc and aceCallback.c files. The doc file provides an overview of how one can implement one’s own DHCP options. The source file is a copy of the aceCallbacks file from the Connect ME platform on NET+OS 6.0f GNU. The information should be applicable to 6.1 (or greater) both GNU and GHS. Regards, Cameron

DNSgethostbyname() is a lookup function. It takes a string containing a host or domain name to be resolved and returns the corresponding IP address. What I need is a way to tell the DNS server what my own name/IP combination is. Normally that is done by the DHCP call, where the name can be passed. With the Netsilicon stack that field is all zeroes. If registering my unit’s name with the DNS server is an undocumented side effect of DNSgethostbyname() then it is still unclear how/where I should set up that name. Is there some global variable that I should fill-in? Or is there a name string that I might set up before the DHCP starts?

I guess there is some confusion here. Firstly, you need to add the DNS servers what ever you have when using our DNS client api which means that you need to know the IP address of those the DNS servers in advance and hardcode them in the application before you run it. It doesn’t matter if it is via PPP or Ethernet. Sorry that I don’t have good news this time. Once you added the DNS server then you check to see if they are there by the call DNSGetServers and then you do DNSgethostbyname char name1[]=“”; ip = htonl(DNSgethostbyname (name1)); if (ip == 0) { printf("DNSgethostbyname() returns: 0
"); } else { NAInet_toa (ip, buffer); printf("Domain name: %s has IP address: %s
", name1, buffer); } Domain name: has IP address: I get an ip address for my domain name… To validate this went to the dos kernel and pinged and there you go found it responding.

I think you are misunderstanding the whole point of this post. If I am using DHCP, I don’t know my IP address in advance, and I most likely don’t know the address of the DNS servers. What I would like to be able to do is receive an IP address using DHCP and then publish to the DNS server my host name and have it be associated with the IP address I was just assinged. I think what the original poster was pointing out is that this can be done through an option in DHCP, except that you don’t support it. Since the DHCP-assigned IP address for a given host may change, it can’t be added to a DNS server’s tables in advance, which is what it seems like you are suggesting with the call to DNSGetHostByName. By definition DNSgetHostbyname cannot return an ip for a host name that it doesn’t recognize. Which you show in your code by testing ip==0. For example, my company manufactures a specialty printer. We may have twenty printers at one location. Lets say that each printer constructs its own host name based on its model number and serial number such as I simply turn on DHCP on each printer, go to a computer with a web browser and type in and can access the setup pages of a specific printer. Right now we have to tell our clients to go through the printer’s menu and find the IP address that was assigned to it and use this IP address in the web broswer. Given that the IP address is assigned dynamically, there is the possiblity that a given printer’s IP address will not be the same every time. Therefore, when they type an IP address into the web browser tomorrow, there is no guarantee that they will be accessing the same printer that they accessed today. If we were using static IP, then the hosts.txt file of the DNS server could simply be updated to include the association. We would enter the IP and DNS directly into the printer and everything would work as described in the previous example. How can my scenario be accomplished when the printer’s IP address is assigned dynamically? Glenn

Hi Guest, I’m the original poster. According to a technician of Netsilicon who visited us the DHCP function has no way to send the unit’s name. We will have to write our own DHCP client. Regards, Arie de Muynck

Note though that it is the DHCP servers responsability to register this name to the DNS server! The DHCP server of Windows 2000, for example, has this ability but many DHCP servers does not have this ability. Regards, Jesper