How to query TXT and SRV records from Windows? - windows

I am attempting to query a set of SRV records using the naked host name (e.g. _service._proto) however this fails unless I also include the domain name. This is strange because other tools such as nslookup work fine and also using the same API call to query A records works fine with naked host names.
dsRet = DnsQuery("_service._udp",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("collector",DNS_TYPE_A,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL); //==ERROR_SUCCESS
I can of course query the system to get the primary domain name and maybe even all of the configured search domains but I'm pretty sure I shouldn't have to do that. I can find very little reference to the Windows DNS APIs out there so I'm wondering if there is a better way to query TXT and SRV records. Does anyone have any experience with this under Windows?
Thanks for any suggestions,
Robert

The reason that it works under nslookup is that windows is performing all the searches using the domain suffixes that it is configured with. To see this in action start up nslookup and then issue the "set debug" command. Now perform your search and you will see the requests and responses send and received by your machine. There will be an unanaswered one for the "naked host name" before one of the configured domain suffixes is appended and matched.
Hope that this helps.
Jonathan
Here is a free DNS client library that you can use to query the DNS for different types of query: http://www.simpledns.com/dns-client-lib.aspx also http://arsofttoolsnet.codeplex.com

Related

Piping / Filtering Windows DNS Server logs

I am looking to log all the unique hosts which have had any transaction with my Windows DNS Server.
I found that there is an option to log my DNS server transactions via the Set-DnsServerDiagnostics PS command.
However - it is quite heavy and I am not interested in most of the data there. I just care about the host name, for example www.google.com
I was wondering if there's an option to create a File pipe which consumes the log data, and filters it - resulting in a file which contains domain names only.
I saw that I could specify the file path with the -LogFilePath argument - it may help.
Any help / ideas will be appreciated!

Get DNS infos for local machine interfaces

I need the DNS suffix of all my local interfaces on my PC.
Is there way how I can achieve this via Go?
Best case would be for any OS
Necessary: working on Windows
I have tried net.Inferfaces() and all the net commands but I haven't found anything regarding the DNS server.
EDIT
I have found the solution for the Windows-specific version but it would be interesting if there is anything that works for Linux and macOS too.
I don't think there is a solution that work for any OS. In Linux the DNS suffix is not interface specific but system wide, it is configured in /etc/resolv.conf. Here is an excerpt from the man page:
search Search list for host-name lookup.
By default, the search list contains one entry, the local domain name. It is determined from the local hostname returned by gethostname(2); the local domain name is taken to be everything after the first '.'. Finally, if the hostname does not contain a '.', the root domain is assumed as the
local domain name.
This may be changed by listing the desired domain search path following the search keyword with spaces or tabs separating the names. Resolver queries having fewer than ndots dots (default is 1) in them will be attempted using each component of the search path in turn until a match is found.
For environments with multiple subdomains please read options ndots:n below to avoid man-in-the-middle attacks and unnecessary traffic for the root-dns-servers. Note that this process may be slow and will generate a lot of network traffic if the servers for the listed domains are not local, and
that queries will time out if no server is available for one of the domains.
If there are multiple search directives, only the search list from the last instance is used.
The net package standard library parses this file to get the DNS config, so the DNS resolver should behave as expected, however, the parsing functionality is not exposed.
The libnetwork.GetSearchDomains func in the libnetwork library should be able to help you out. If there are no search entries in /etc/resolv.conf, you should use the hostname, which can be gotten with the os.Hostname func.
I believe this also works for FreeBSD and Mac OS since they are both "UNIX like". But I am not 100% sure.

DNS migration to Route53

I have transferred domain name from https://www.onlydomains.com/ to aws Route53. Using name-server,it works most of the time, but sometime it will not be available for some time max 5 min.
I have tried using alias, it works for other domain which I have added alias to check it.
Probably your domain zone still in transfer, you could either use tools like drill/dig:
$ dig your-domain.tld ns
This will show the existing nameservers, but the same tool can be used for checking A records, example:
$ dig your-domain.tld +trace
The +trace option makes iterative queries to resolve the name being looked up. it helps to see what servers still using your old DNS provider.
Also, could be an issue with your own DNS, to check for example using google DNS servers you could use something like:
$ dig #8.8.8.8 your-domain.tld
Also, give a try to https://intodns.com/ to check more details

Server name dissapears from rdoConnection.Connect string

I'm working with an old Visual Basic 6 application that connects to an Oracle11g server using Remote Data Objects (RDO) 2. Here is my code:
Dim rdoCon As New rdoConnection
rdoCon.Connect = "DRIVER={Microsoft ODBC for Oracle};SERVER=os11atst.world;"
Debug.Print rdoCon.Connect '1
'Prompt the user to enter credentials and connect to the server:
rdoCon.EstablishConnection rdDriverComplete, False
Debug.Print rdoCon.Connect '2
The first Debug.Print gives me this (as expected):
DRIVER={Microsoft ODBC for Oracle};SERVER=os11atst.world;
However, the second one gives me this:
DRIVER={Microsoft ODBC for Oracle};UID=username;PWD=password;
The SERVER parameter is missing, even though the connection works fine. This is a problem for me, because I need to know what server the connection is to. I can not simply use the information from the first string, because the user is (and should be) able to change the server in the prompt that asks for username and password.
This problem arose from nowhere, possibly in connection to an upgrade from Windows XP to 7. Previously the program did not exhibit this behaviour, or so I am told by older colleagues. Not 100% sure that is correct, though.
How can I prevent the dissaperance of the server name? Can I get the name of the server in any other way than looking at the connection string?
I am not interested in solutions that include upgrading to something newer than RDO. For external reasons I am stuck with it.
rdoCon.EstablishConnection will override whatever you had previously set.
It sounds like the problem is in the DSN that is installed on this new machine. Compare it to the DSN that was installed on the previous machine. It had a configuration that you are missing on this new machine.
I have developed a not so pretty workaround to solve this. I have a table called SETTINGS containing columns NAME and VALUE. For every database I have simply added the setting servername together with the appropriate value. All I need to do to find out what server I am connected to is then to query the DB:
SELECT value FROM settings WHERE name = 'servername'
This is of course quite an ugly hack, so any better solutions would be welcome.

API for Detecting Windows Active Directory name/IP

I have a requirement to detect all users from local and Active Directory(if present) in Windows.
I have found that C API: NetQueryDisplayInformation() has also the option to retrieve the information from a "serverName", which is presumably an Active Directory which can be queried.
But how do I find out if ActiveDirectory is available/ and it's name ?
Thanks.
This information is available in WMI. In the Win32_ComputerSystem class (there will be a single instance per computer) has a Domain property containing the domain's name.
Another way of finding out domain name (if present) is to use WIN API ::DsGetDcName()
This one returns information about Active Dir server name in DOMAIN_CONTROLLER_INFO struct.
You get there all the domain information you need. Much sympler than using WMI :-)

Resources