Is there a cmd which can send directly a query to the host to obtain his domain?

Is there a cmd which can send directly a query to the host to obtain his domain?  I don't want a query to DNS (suppose it's not configured properly ). Which cmd can give the domain of the host if I have his ip adr? I have list of 100 servers to verify...
LVL 1
SAM2009Asked:
Who is Participating?
 
OrenRozenConnect With a Mentor Commented:
Hi,

Basically, this script use the command SYSTEMINFO to get the information you need and in this script I'm looking for the 'Domain:' value, but you can change the 'Domain:' to any other thing this command show.

Put this command in a batch file

for /F "tokens=2" %%a in ('systeminfo /S %1 ^| find /i "Domain:"') DO echo %%a

To use just type the batch file name and the remote ip (e.g finddom.cmd 192.168.1.55)
0
 
-HenryM-Commented:
i am unaware of a single command...

however you could execute a script to accomplish this...

http://www.codeproject.com/KB/vbscript/userinfo.aspx
0
 
APNFSSCConnect With a Mentor Commented:
if your running windows domains then you could run into security issues with what ever solution you choose.

Where you query a machine that is on a different domain or the account you are running from does not have permission to query the system.

Below is an example of how to do this using WMI

wmic /Node:COMPUTERNAME ComputerSystem Get Domain | findstr /V "Domain" | findstr /R /V "^$"
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
AlanConsultantCommented:
Hi,

There is no definitive answer to the question you would be asking.

For example, I could point both:

www.example.com

AND

www.invalid.com

to the same IP address (say, 123.123.123.123)

If so, then what is the correct answer to your question?

This is very common with multiple websites being hosted on a single server, especially at the 'cheap' (or free) end of the market.

Alan.
0
 
SAM2009Author Commented:
Alan what you said is correct if the domain is queried by the DNS that why I asked for for something which query the info directly to the host machine if I have the IP.
0
 
OrenRozenCommented:
Hi,

Please look at my initial post to your question.
It uses the SYSTEMINFO command line. using this command following the IP address of the remote machine you get additional including the domain as shown on that remote machine.
and the script just filters all the other information to show the result that is the domain.

Maybe I didn't understand your question question   and if so, I'd appreciate if you'll clarify.

Thanks,
Oren
0
 
SAM2009Author Commented:
Ya I tried. I put the cmd in "get_dom.bat" and run the cmd like this but the only thing I get is the cmd back:

C:\>get_dom.bat 192.168.1.1

C:\>for /F "tokens=2" %a in ('systeminfo /S 192.168.1.1 | find /i "Domain:"') DO echo %a
0
 
OrenRozenCommented:
from command line try :

systeinfo /S 192.168.1.1

you should get a lot of information. one of the fields is Domain.
if you get the domain then the problem is only with the command itself.
BTW, in your last reply add the ^ mark just before the | mark in the command you entered.

0
 
AlanConsultantCommented:
Hi Sam2009,

If you re-read my response, you will see that I am talking about the situation where you have the IP address and want to get a hostname back.

You seem to be wanting something like:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

> GiveMeYourName 123.123.123.123

ThisIs 123.123.123.123: My name is www.example.com

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

There cannot always be a single response to such a query for a given IP.

Moreover, there is no reason why any given IP has to have ANY hostname.


Alan.
0
 
SAM2009Author Commented:
Hi Alan,

Yes in DSN you can put many hostname and the A record can point to more than 1 Ip adr but in the server itself it can just link to one domain no?

Like:

Exemple.com  123.123.123.123
Exemple.net    123.123.123.124


If we go directly to the server maybe the  name is SERVER1.Domain.com. I just the domain name  on the server not the info from DNS.
0
 
AlanConsultantCommented:
Hi Sam2009,

Are you talking about 100 servers all being members of various Windows Server Domains, or are you talking about 100 servers on the net for which you have IP addresses, and you want to know what domain(s) they are serving on behalf of?

Also, you have variously asked about domains and hostnames - they are different.

If you are talking about Windows Server Domains, then you could have (for example):

server1.mydomain1.local
server2.mydomain1.local
server3.mydomain2.local

In that example, there are three hostnames across two Windows Server Domains (which might, or might not have a trust relationship between them).

If you are talking about internet domains, then you could have (for example):

www.example.com on 123.123.123.123
smtp.example.com on 123.123.123.123

OR

www.example.com on 123.123.123.123
smtp.example.com on 123.123.123.124
www.invalid.com on 123.123.123.123
smtp.invalid.com on 123.123.123.124

In the first of those two examples, you could say, in a sense, that the domain (example.com) is hosted on 123.123.123.123 (although even then, you'd have to check where the authoritative nameservers for example.com are located).

In the second example, both 'domains' are (at least partially) hosted on 123.123.123.123 (and also 123.123.123.124).


I am picking you mean the former (Windows Server Domains), but best to check I guess!

Does that help?

Alan.
0
 
SAM2009Author Commented:
That I'm  talking about Windows Server Domains. Ya I see you mean that same IP adr can be assigned to different servers in differerent domains right? But it is not the case there is trust between all domains and just unique IP is assigned to servers.
0
 
AlanConnect With a Mentor ConsultantCommented:
Hi Sam2009,

You could try using PSEXEC from SysInternals (now part of Microsoft) to run an IPConfig /All on each of those machines.  I am assuming you have appropriate permissions else this whole conversation is moot :-)

http://technet.microsoft.com/en-us/sysinternals/bb897553

Something like:

psexec \\192.168.1.1 ipconfig /all


Would that work for you?

Alan.


0
 
SAM2009Author Commented:
Thank you for all your suggestions!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.