Solved

What Subnet Am I In?

Posted on 2012-03-15
13
772 Views
1 Endorsement
Last Modified: 2012-03-27
Hello,

If I do an IPConfig, I can find out the IP address and subnet mask of my Windows machine.  With this info, can I determine what AD subnet I'm on?

Thanks,
Joe
1
Comment
Question by:JoeyBugeyes
  • 4
  • 3
  • 2
  • +4
13 Comments
 

Author Comment

by:JoeyBugeyes
ID: 37727171
The reason I'm asking is because I'm trying to put together a script or at lease a procedure.  If I get that midnight call and says these 100 users can't log on...  I want to be able to ask for an IP address of an affected machine and do something like this...

1. based on IP, determine subnet they are on
2. look up subnet in AD Sites & Services to determine the DC they 'should' be connecting to.
3. check the DC(s) in question.

Thanks,
Joe
0
 
LVL 37

Expert Comment

by:Neil Russell
ID: 37727172
Do you mean what AD Site you are in? A subnet is a subnet. There is no such thing as an AD Subnet as such.

What exactly are you trying to find out?

Can you give example of what you would expect to find as a result?
0
 
LVL 11

Expert Comment

by:itguy565
ID: 37727191
Neilsr,

I think I understand what he is referring to but he is using the wrong terminology. If I am reading this right he has site specific policies in place that vary from one location to another.

Example of this is :
http://technet.microsoft.com/en-us/library/cc731907.aspx
0
 
LVL 11

Expert Comment

by:itguy565
ID: 37727201
Now where I am confused is why he would need what he is asking for.

If you have your subnets mapped to different sites then you have probably already told Active Directory which server is linked to what site. If that is the case all you would need to do is ping the machine get the IP relate that to one of your DHCP scopes and that should tell you which server you are connecting to.
0
 

Author Comment

by:JoeyBugeyes
ID: 37727387
OK...

I apologize if I wasn't clear.  I'm certain I'm not using the correct terminology and perhaps not even asking a valid question.  But here's what I'm thinking.   We have a TON of sites and subnets.  If a group of people experience long logons, no logons, or other authentication issues, I want to be able to very quickly (perhaps even scripted) tell which domain controller is in trouble.  I understand that it may be other things such as network, but let's assume for now it's AD related.  By the way, there is currently no issue, but I just want to be prepared for next time.

1. Let's say I have an IP Address / subnet mask of a windows machine of 10.20.30.40 / 255.255.252.  This windows machine and all others in the same physical location is having trouble logging on.

2. If I plug this IP/subnet mask into a subnet calculator (http://www.subnetonline.com/pages/subnet-calculators/ip-subnet-calculator.php) it reveals to me that my machine is on the 10.20.28.0 network.  I assume this is the same thing as my 'subnet'.  Again, forgive my misuse of terminology.  If I'm wrong here, let me know.

3.  I now take this 10.20.28.0 and look for it in AD sites & Services to find out what site it's associated with.  Let's say it comes back with Trenton.

4.  Then I use AD Sites & Services to look up the 'Trenton' site to see what domain controllers service the site.

5. Now I can health check the the Trenton DCs .

So I guess what I'm really asking now is two things.  1) Are my steps correct/logical?  and 2) if so, is there a better way to do step number two above instead of having to use a subnet calculator?  Is there a command line tool or something?  I'm thinking command line because if this process is good, then I'd like to script it eventually.

What are your thoughts?  I'm sure I'll get this call from time to time and I don't want to get caught without a good process.

Thanks a bunch!

Joe
0
 
LVL 6

Expert Comment

by:vmagan
ID: 37727777
Have the user do an ipconfig /all and tell you what the dns server is. A lot of times that is also the domain controller.  You should also check dhcp and see what different scopes they have so that you will be familiar with the addresses. You can check the subnets in AD but that won't tell you much.  
Ipconfig /all should be enough.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:rafter81
ID: 37728348
Do you mean, within AD sites & services, the subnets that are defined here are assigned against sites?...
0
 
LVL 10

Accepted Solution

by:
mat1458 earned 250 total points
ID: 37728746
to answer your questions Joe:
1) in my opinion your steps seem logical. The direct relationship between subnet and AD seems to be something that you have in your network. It is not that way in every network; probably that's why people are confused a bit.
2) Faster than the script is probably only your brain. Subnet calculation is easy if you start to understand how it works. But that's probably not what you want to hear....;-) If you are into VBS then look at this: http://www.codeproject.com/Articles/72622/Calculating-Subnet-Ranges-With-VBScript. or .net look here: http://www.techexams.net/ip-subnet-calculators/.
0
 
LVL 10

Assisted Solution

by:172pilotSteve
172pilotSteve earned 250 total points
ID: 37730239
I agree with MAT1458.. Your logic and steps seem sound.. just remember that there's also a "default site" so if your subnet isnt listed, it MIGHT be that you're in the default site...  Of course, it's also possible that whoever setup the sites, used "supernetting".  In otherwords, I might setup something where the WAN location is in the second octet, like "10.x.y.z" where x= site number, y=floor or switch number, and z=node number.  A "Headquarters" site might be many different switches, to include:
10.1.1.z/24
10.1.2.z/24
10.1.3.z/24
... all the way to
10.1.255.z/24

Instead of defining 255 subnets as the site "Headquarters", I'd most certainly create site headquarters with "10.1.0.0/16"  (or 10.1.0.0 / mask 255.255.0.0) which would encompass all of the subnets in one entry.  The problem is that you're going to see 10.1.0.0/16 in Sites and Services, but the user on the phone is going to tell you something like "10.1.7.5" which isn't going to match anything in your IP subnet calculator.  For this reason, I second the concept of being able to understand the subnets without relying on the Internet calculator so much...

VMagan talks about using the DNS server to determine your DC / site, which works great if everything is up, but when there's a problem (which is why you got the call in the first place!) your machine will go to a non-optimal site/DC/DNS if it has to, which could skew the info you get.

Check out this site:
http://patternbuffer.wordpress.com/2007/12/13/finding-your-active-directory-site-and-domain-controllers/

It has some commands to search the LDAP based on your current situation, to find your site and local DC names..

Does that help?
0
 

Author Closing Comment

by:JoeyBugeyes
ID: 37752726
Thank you very much for your answers.  <br /><br />Mat1458, <br />I was lucky and found a script that does exactly this process.  It's a winbatch script, but i have a compiler so I'm good there.  There's no direct link to the script, but you can go to techsupt.winbatch.com and search for "Useful ADSI Site server functions".<br /><br />172PilotSteve,<br />That's great info.  Thank you!!!!
0
 
LVL 10

Expert Comment

by:172pilotSteve
ID: 37752802
WOW..  a winbatch user?!  How unusual!  I used to do a LOT of winbatch, and actually, somewhere I have a routine I wrote for EXACTLY this purpose - you pass it 2 IP addresses with mask, and it will tell you whether they're in the same subnet.

I wrote it because I had written a custom software deployment / workstation management system (kind of a mini SMS) and I used it to be able to target installs to certain subnets.

If that code would be handy for you, let me know, and I'll dig it out.  I KNOW I still have it SOMEWHERE..
0
 

Author Comment

by:JoeyBugeyes
ID: 37772909
Steve,

Oh yeah, I love Winbatch.  Don't bother digging out the script though.  The one on their site works pretty well.  I think it was some guy from NJ who wrote it, maybe Clifton area?  That wouldn't happen to be you, would it?  What a small world if so.

Joe
0
 
LVL 10

Expert Comment

by:172pilotSteve
ID: 37774818
Nope..  Wasn't me..  I'm in Maryland..  Haven't used Winbatch in a couple years, but I'm a big fan too.  It's amazing what it can do.  I've been forced into Powershell, which is also really cool, but sometimes I miss the simplicity of winbatch...

Good luck and thanks!!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
This is the first one of a series of articles I’ll be writing to address technical issues that are always referred to as network problems. The network boundaries have changed, therefore having an understanding of how each piece in the network  puzzl…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

707 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

16 Experts available now in Live!

Get 1:1 Help Now