Solved

Batch File for logon script to check Static IP Settings

Posted on 2011-03-01
12
562 Views
Last Modified: 2012-08-13
Hello,

I need a batch file that i can run at logon to check a PC's staticly assigned IP settings, pretty much everyhting but the Ip and if it is wrong i need the batch file to then set the correct IP address based on variables set at the top of the batch file. Hope fully the batch file could figure out which network connection is using the IP address 192.168.1.0 subnet and only set that network cards settings...

If you need more information please let me know.
0
Comment
Question by:speeDemon
  • 3
  • 2
  • 2
  • +4
12 Comments
 
LVL 3

Expert Comment

by:Rhyseh
ID: 35013099
This sounds like a clunky way to do this. Is there a reason you can't create a reservation for the required clients/servers in DHCP and set them to obtain their address automatically?
0
 
LVL 1

Author Comment

by:speeDemon
ID: 35013331
we are not using DHCP fo Addresses everyhting is staticly assigned
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 35013531
Let me rephrase the previous person's question - WHY aren't you using DHCP?

I can try to post instructions later (when I'm not on the phone) but I would like to know as well why you are essentially hacking a dhcp solution instead of just using dhcp
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 35013543
I will say doing this will require the use of netsh
0
 
LVL 4

Expert Comment

by:cmartell
ID: 35013953
If the IPs are statically assigned they aren't going to change so there is no need to check them with a script.

I think we need clarification on your setup and what you are trying to accomplish.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 14

Expert Comment

by:Don Thomson
ID: 35015927
There is nothing wrong with using static IP's but with today's Servers and Routers, Using Address reservations is much more efficient. If for instance your ISP's DNS server goes south, you only need to change one entry in your Server or router,  On a Domain, the DHCP server will correctly assign the proper routes to DNS servers and Wins servers without having to go into every workstation and setting that up.

Also with the ever increasing use of laptops and desktops, using DHCP with address reservations does make musch more sense

0
 
LVL 8

Expert Comment

by:MarkieS
ID: 35015936
Dont continue down this road unless you have a damned good reason too!!!  
The batch file you have requested is DHCP.  

Having said that you dont mention any centrally administered networking so am I guessing you have no servers?

If that's the case anything over 10 local client standalone workgroup machines is going to get to be a headache to administer.  Start thinking of getting a Server and centrally managing your network.
0
 
LVL 1

Author Comment

by:speeDemon
ID: 35019989
I have servers I am not in a position to change my companies address scheme. I do not have the authority to change clients to DHCP and will have to continue to use staticly assigned IP addresses. The fille will need to check because i do not want the file to continually reset the IP address if the address settings are set in the correct IPs already.

p.s. i totally agree with DHCP, just cant do it because of "higher" powers
0
 
LVL 14

Expert Comment

by:Don Thomson
ID: 35020341
I would do something like

ping %computername% -4 -n 1 >> \\server\logs\iplist

That will give you a list from each PC that logs in - and will append it to a text file on the server
You can probably write a quick and dirty parcing  program to format into whatever structure you want

The actual batch file can be put in the GPO for login scripts on the server

If you just want to see which IP's are assigned to  all the Workstations just  go

Net view > PClist.txt

bring that into excel  as a fixed width file - Kill the comments - and do a search and replace for "\\" with "ping  -4 -n 1 "

Save that as a .txt file and then rename it to getips.bat
then run getips.bat > myiplist

Bring that into your database of what you think should be the IPs  and strip out the garbage - and compare the two lists
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 35020655
With a clear sample of what you are checking for and changing, it's impossible for me to do this for you (and even then, it would be a logic/coding excersize for me as I've not done something like this via script and only used NETSH on occasion via command line).

Bottom line, to adjust TCP/IP settings you need to use NETSH.  type NETSH /? for online help and you can google NETSH and the first 9 links provided should be quite useful in guiding you how to do what you want.
0
 
LVL 47

Accepted Solution

by:
Donald Stewart earned 500 total points
ID: 35077551
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to dynamically set the form action using jQuery.

747 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

13 Experts available now in Live!

Get 1:1 Help Now