tags:

views:

32

answers:

1

I want to read the primary and secondary dns addresses from the system and want to change it to any user given address.

Is this possible through some library.

An alternative approach is that I read the /etc/resolv.conf and do the changes, which is what I've done.

BTW the current solution I have is for Ubuntu OS, and for now if I get if for the same OS also it would be fine.

+1  A: 

/etc/resolv.conf IS the authoritative source of DNS servers, so you better check there.

A bit off-topic, but note that it's being overriden by DHCP, so if you need to add own DNS server, you have to edit /etc/dhcp3/dhclient.conf and add there something like:

append domain-name-servers <DNS-ip>;

or

prepend domain-name-servers <DNS-ip>;

Also note that Ubuntu (at least 9.04 I'm using) supports only up to 3 DNS servers.

Tomasz Zielinski
@Thomasz: Totally agree, I'm using Ubuntu 9.10, and have read through it.
Panther24