/etc/resolv.conf
Please support our C advertiser: Programming Forums
![]() |
The conf file is just a textfile, so you can use standard c++ file-acces:
cplusplus Syntax (Toggle Plain Text)
#include <fstream> [....] std::ifstream in_file("/etc/resolv.conf"); if (!in_file.is_open()) std::cout << "error opening file"; else // do stuff
Want better/more replies to your questions? Wrap your code in [code] [/code] tags!
•
•
Posts: 41
Reputation:
Solved Threads: 7
Thanks for your reply. I have to use libraries to open this file.
With the help of the library routines I can add name server,
read the contents etc. Does this possible with Resolver library(http://swoolley.org/man.cgi/resolver)? Please let me know,
if need more info.
With the help of the library routines I can add name server,
read the contents etc. Does this possible with Resolver library(http://swoolley.org/man.cgi/resolver)? Please let me know,
if need more info.
Last edited by RenjithVR : Dec 2nd, 2008 at 8:34 am.
•
•
•
•
Hi,
Hi All,
Can anyone tell me about a library that helps me to read contents from /etc/resolv.conf file and also update the same file with new entries. Does this possible with Resolver library routines? Any useful links or sample programs regarding this? Thanks in advance.
Renjith
resolv.conf stores the DNS Servers your system should use, in plain text. Why would you want a special library to read it ???
Last edited by stephen84s : Dec 2nd, 2008 at 9:29 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
•
•
Posts: 41
Reputation:
Solved Threads: 7
If you look at the man resolv.conf, you can see different configuration options. I have to use some of those options. Is it possible to do with the 'resolver', a set of routines in the C library. Can I use those set of routines in my program to access/update resolv.conf file? or any other library available to do this?
Although I have never tried it, I have read the manual pages of both resolv.conf and resolver, and I found the following line which would interest you :-
This is from the resolv.conf manual page.
And this is from the resolver manual page:-
So I guess you can read the resolv.conf file using resolver but I could not find any method that would actually write back to it.
This is from the resolv.conf manual page.
•
•
•
•
The resolver is a set of routines in the C library that provide access to the Internet Domain Name System (DNS). The resolver configuration file contains information that is read by the resolver routines the first time they are invoked by a process.
And this is from the resolver manual page:-
•
•
•
•
The res_init() function reads the configuration files (see resolv.conf(5)) to get the default domain name, search order and name server address(es). If no server is given, the local host is tried. If no domain is given, that associated with the local host is used. It can be overridden with the environment variable LOCALDOMAIN. res_init() is normally executed by the first call to one of the other functions.
So I guess you can read the resolv.conf file using resolver but I could not find any method that would actually write back to it.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
"How to ask questions the smart way ?"
"How to ask questions the smart way ?"
![]() |
Similar Threads
Other Threads in the C Forum
- DNS Problem - rndc: connect failed: connection refused (*nix Software)
- sendmail mail server (Linux Servers and Apache)
- Kubuntu Internet (*nix Software)
- How To Install Dns in Linux ? (Domains and DNS)
- Windows - Linux Shared Internet (Networking Hardware Configuration)
- network segmentation (Network Security)
- Apache Tomcat and IIS 6 with JK2 (Windows Servers and IIS)
- Sendmail problem (*nix Software)
- New to Linux (Getting Started and Choosing a Distro)
Other Threads in the C Forum
- Previous Thread: Warning: Comparison between pointer and integer (mingw 5.1.4)
- Next Thread: Optimizing OpenGL (SwapBuffer being slow)
•
•
•
•
Views: 488 | Replies: 5 | Currently Viewing: 1 (0 members and 1 guests)






Linear Mode