[En-Nut-Discussion] DNS server IP via DHCP
Harald Kipp
harald.kipp at egnite.de
Fri Oct 8 10:34:15 CEST 2004
Thorsten,
this is probably the fastest way to do it. I'm not
sure though, wether it would be better to add it
to CONFNET.
Host and domain is interface specific, right? Hm...
what about DNS?
Any comments?
Harald
At 17:49 07.10.2004 +0200, you wrote:
>Hi,
>
>I had the same problem and it seems there is no official way to get that
>info. So I investigated a bit. The NutDnsConfig2 routine stores the setting
>in a global but private structure "doc". So the simpliest way is to make
>that structure public.
>
>I moved it's definition from "pro/resolv.c" to "netdb.h"
>
>So in "pro/resolv.c" the only thing is to remove the type definition and
>therefor include the netdb.h:
>-----------------------------------------------------
>/*
> * moved to netdb.h, so everyone can get the current DNS parameters
>typedef struct {
> u_char *doc_hostname;
> u_char *doc_domain;
> u_long doc_ip1;
> u_long doc_ip2;
>} DNSCONFIG;
>*/
>DNSCONFIG doc;
>-----------------------------------------------------
>
>
>Then put it into "netdb.h"
>-----------------------------------------------------
>typedef struct {
> u_char *doc_hostname;
> u_char *doc_domain;
> u_long doc_ip1;
> u_long doc_ip2;
>} DNSCONFIG;
>
>extern DNSCONFIG doc;
>-----------------------------------------------------
>
>Now you can access it from everywhere in your code by writing
>
>printf("Hostname : %s.%s\n", doc.doc_hostname, doc.doc_domain);
>printf("Primary DNS server : %s\n", inet_ntoa(doc.doc_ip1);
>printf("Secondary DNS server: %s\n", inet_ntoa(doc.doc_ip2);
>
>But beware. If there is nothing configured the pointers to hostname and
>domain are set to NULL. So check before using it.
>
>I hope that helps. I used an old 3.4.2.1 of NutOS. Maybe it's different in
>the actual 3.9x version.
>
>bye
>Thorsten
>
>
> > I've looked at the standard DHCP code and see that it retrieves the DNS
> > Server settings from the DHCP server and configures them using
> > NutDnsConfig2.
> >
> > This is good. However, I want to "display" these values retrieved from the
> > DHCP request (and others if possible). Does anyone know how to access
>these
> > field other tahn modifying the dhcp code ?
More information about the En-Nut-Discussion
mailing list