LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-14-2010, 04:49 AM   #1
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
DNS Mail Server Lookup from C?


Hi there,

I'm trying to do dns lookups from C using getaddrinfo(), but I can't find out how to set the query type to MX instead of the default A - can anyone help me out?

Thanks

John G
 
Old 02-14-2010, 03:40 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

If you really want to query low-level DNS stuff like MX records, perhaps your best bet might be to write some scripts for "dig" or "nslookup", and have your C program a) invoke the script, and b) parse the results.

Another alternative might be "man 3 resolver". This documents APIs like "res_mkquery" and "res_search".

'Hope that helps .. PSM
 
Old 02-14-2010, 05:53 PM   #3
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Maybe, you find the following API interesting as well:

man 3 gethostbyaddr
man 3 gethostbyname

This will resolve a hostname by following the configuration in /etc/nsswitch.conf, e.g. via the hosts file or the dns server. The advantage is that you don't have to care about the DNS specifics/details.

Hope that helps,

- Andi -
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows pc go to a linux server for dns lookup shanie Linux - Server 1 12-02-2009 07:26 AM
Fetchmail stalls at DNS lookup of smtp server Russell Griffiths Linux - Software 15 05-26-2006 11:49 AM
server lookup through other DNS server inaki Linux - Security 4 08-16-2005 06:16 AM
Traceroute, Ping, Domain Name Server (DNS) Lookup, WHOIS, and DNS Records Lookup netoknet General 1 05-09-2005 03:43 AM
dns server can't lookup external zones dskny Linux - Software 0 11-17-2004 09:41 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration