Solved

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

Posted on 2011-02-23
14
390 Views
Last Modified: 2012-05-11
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...
0
Comment
Question by:SAM2009
  • 5
  • 4
  • 3
  • +2
14 Comments
 
LVL 3

Accepted Solution

by:
OrenRozen earned 167 total points
ID: 34967373
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
 
LVL 2

Expert Comment

by:-HenryM-
ID: 34967375
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
 
LVL 10

Assisted Solution

by:APNFSSC
APNFSSC earned 167 total points
ID: 34967428
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
 
LVL 12

Expert Comment

by:Alan3285
ID: 34968081
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
 
LVL 1

Author Comment

by:SAM2009
ID: 34969524
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
 
LVL 3

Expert Comment

by:OrenRozen
ID: 34969726
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
 
LVL 1

Author Comment

by:SAM2009
ID: 34970264
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 3

Expert Comment

by:OrenRozen
ID: 34971434
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
 
LVL 12

Expert Comment

by:Alan3285
ID: 34973188
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
 
LVL 1

Author Comment

by:SAM2009
ID: 34973366
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
 
LVL 12

Expert Comment

by:Alan3285
ID: 34973602
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
 
LVL 1

Author Comment

by:SAM2009
ID: 34973728
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
 
LVL 12

Assisted Solution

by:Alan3285
Alan3285 earned 166 total points
ID: 34973991
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
 
LVL 1

Author Closing Comment

by:SAM2009
ID: 34974251
Thank you for all your suggestions!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to add field in my script 2 31
how to add fields in script 20 51
Recursive folder search vbscript 7 40
PowerShell one liner to pull server names 3 50
Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now