From your code, you can call ifconfig() with the parameters IFS_NAMESERVER_SET (to clear all name servers and set the first one) and IFS_NAMESERVER_ADD (to add additional name servers).
If you're using the zconsole library, look at Samples/zconsole/userblock_tcpipconsole.c, it includes commands to change the DNS addresses:
Code:
{ "SET NAMESERVER", con_set_nameserver, help_set_txt },
{ "ADD NAMESERVER", con_add_nameserver, help_add_nameserver_txt },