Solved

Maintaning  Large DHCP Server and mac reservations

Posted on 2009-05-02
2
478 Views
Last Modified: 2012-06-27
Will be having new latops coming in an out and want to lock down the DHCP server scopes for only those laptops

Almost got it, but i have DHCP server with 70 + scopes
Made a txt file with IP,Mac Address
i can easily do

for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.1.0 add reservedip %i %j %k %l

And above works but then i have to do this for every scope everytime new laptop comes in
want to script this but it throws and error

would like to batch it

ie=
for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.1.0 add reservedip %i %j %k %l
for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.2.0 add reservedip %i %j %k %l
for /f "tokens=1-4 delims=," %i in (addresses.txt) do netsh Dhcp Server 172.10.1.3 Scope 172.17.1.3 add reservedip %i %j %k %l

when i create a batch file with that in there error msg i get is:

i was unexpected at this time.
D:\Apps\test>for /f "tokens=1-4 delims=," i k l

any ideas?

or a better way to do this?
0
Comment
Question by:crsol
2 Comments
 
LVL 15

Accepted Solution

by:
markpalinux earned 500 total points
Comment Utility

Here is an example:

I was guessing it was ip addresses, if you are looking for four octets, then use 1-4.

Also the for loop you need to use two percent signs when in a cmd ( batch file) , at the command line you use one percent sign.  

for /f "tokens=1-4 delims=." %%i in (addresses.txt) do echo %%i %%j %%k %%l



Mark
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

763 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

9 Experts available now in Live!

Get 1:1 Help Now