# resolv.conf MAXNS



## Deleted member 9563 (Oct 30, 2015)

I see in the resolv.conf man pages that you can put a maximum of 3 nameserver entries in the file. What happens if you put more?

Edit to add:
I'm not needing or wanting more that 3, but was just curious why they were so adamant about a fixed number rather than stating that only the first 3 (MAXNS)would be used, if that was the case.


----------



## kpa (Oct 30, 2015)

What will probably happen is that the excess nameserver lines are just ignored, probably silently. I took a peek at the resolv.conf header file, it isn't pretty:


```
struct __res_state {
  int  retrans;  /*%< retransmission time interval */
  int  retry;  /*%< number of times to retransmit */
  /*
  * XXX: If `sun' is defined, `options' and `pfcode' are
  * defined as u_int in original BIND9 distribution.  However,
  * it breaks binary backward compatibility against FreeBSD's
  * resolver.  So, we changed not to see `sun'.
  */
#if defined(sun) && 0
  u_int  options;  /*%< option flags - see below. */
#else
  u_long  options;  /*%< option flags - see below. */
#endif
  int  nscount;  /*%< number of name servers */
  struct sockaddr_in
  nsaddr_list[MAXNS];  /*%< address of name server */
#define nsaddr  nsaddr_list[0]  /*%< for backward compatibility */
  u_short id;  /*%< current message id */
  char  *dnsrch[MAXDNSRCH+1];  /*%< components of domain to search */
  char  defdname[256];  /*%< default domain (deprecated) */
#if defined(sun) && 0
  u_int  pfcode;  /*%< RES_PRF_ flags - see below. */
#else
  u_long  pfcode;  /*%< RES_PRF_ flags - see below. */
#endif
```

It's clear that there is room for only three nameserver addresses in that structure so anything more won't be even stored anywhere. The comment and #if defined(sun) && 0 lines cracked me up, really has no one dared to clean that up? Kind of makes you wonder if anyone reads these very important pieces of system headers anymore these days.


----------

