Jump to content

Assigning range of IPS in win2k3


gemcneill

Recommended Posts

Probably not what you are looking for, but if you are moving machines around or replacing them regularly you can utilize batch scripts to set the connection information on a machine. I do have some prewritten batch scripts I keep saved and edit as needed for new equipment.

Here is a priliminary one that is fairly clean and easy to work with.

@ECHO OFF

set varip=65.88.48.77
set varsm=255.255.255.224
set vargw=65.88.48.65
set vardns1=66.78.202.254
set vardns2=66.78.210.254
set varhome=www.google.com

REM ***** You don’t need to change anything below this line! ******

ECHO This fanciness is brought to you by Saman Sadeghi!
ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%

ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1

ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%

ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%

ECHO Here are the new settings for %computername%:
netsh int ip show config

pause

Link to comment
Share on other sites

Probably not what you are looking for, but if you are moving machines around or replacing them regularly you can utilize batch scripts to set the connection information on a machine. I do have some prewritten batch scripts I keep saved and edit as needed for new equipment.

Here is a priliminary one that is fairly clean and easy to work with.

@ECHO OFF

set varip=65.88.48.77
set varsm=255.255.255.224
set vargw=65.88.48.65
set vardns1=66.78.202.254
set vardns2=66.78.210.254
set varhome=www.google.com

REM ***** You don’t need to change anything below this line! ******

ECHO This fanciness is brought to you by Saman Sadeghi!
ECHO Setting IP Address and Subnet Mask
netsh int ip set address name = "Local Area Connection" source = static addr = %varip% mask = %varsm%

ECHO Setting Gateway
netsh int ip set address name = "Local Area Connection" gateway = %vargw% gwmetric = 1

ECHO Setting Primary DNS
netsh int ip set dns name = "Local Area Connection" source = static addr = %vardns1%

ECHO Setting Secondary DNS
netsh int ip add dns name = "Local Area Connection" addr = %vardns2%

ECHO Here are the new settings for %computername%:
netsh int ip show config

pause

 

 

Don't forget if you are adding more then 1 IP then you need to add these lines for each additional IP.

 

 

set varip2=65.88.48.77

set varip3=65.88.48.77

set varip4=65.88.48.77

 

ETC.. changing each line for a different IP. :D

 

Make sure you don't typo anything or when you run that script you will lose connection to the box. Proof read your edits 3 or 4 times. ;)

Link to comment
Share on other sites

A range:

 

for /L %a in (1,1,254) do netsh in ip add address "Local Area Connection" 1.2.3.%a 255.255.255.0

 

Manually:

 

netsh in ip add address "Local Area Connection" 10.0.0.2 255.0.0.0

netsh in ip add address "Local Area Connection" 10.0.0.3 255.0.0.0

netsh in ip add address "Local Area Connection" 10.0.0.4 255.0.0.0

netsh in ip add address "Local Area Connection" 10.0.0.5 255.0.0.0

netsh in ip add address "Local Area Connection" 10.0.0.6 255.0.0.0

Link to comment
Share on other sites

  • 2 weeks later...

for /L %a in (1,1,254)

 

Start a for loop with variable %a from 1 to 254 in increments of 1

 

do netsh in ip add address "Local Area Connection"

 

Add an ip address to the connection named "Local Area Connection"

 

1.2.3.%a 255.255.255.0

 

IP 1.2.3.%a, where a is the current value of %a in the loop. Use subnet mask 255.255.255.0

 

In other words, that command adds the IPs 1.2.3.1 > 1.2.3.254 to the adaptor Local Area Network connection.

Link to comment
Share on other sites

I think it's not a good idea using your primary interface for doing this. On all my servers i'm creating a loopback interface and bind my extra ips on it. Why ? The main reason (but please dont repeat it) it's because sometimes i clicked on "disable" item from right-click menu of the network card instead of "Manage firewall" :)

Link to comment
Share on other sites

The main reason (but please dont repeat it) it's because sometimes i clicked on "disable" item from right-click menu of the network card instead of "Manage firewall" :)

 

Oops. That could be potentially fatal :)

 

I have a shortcut on the desktop to the Windows firewall interface. You can also automate adding rules to it from the commandline just like you have done for IPs:

 

FOR /L %%A IN (27000,1,27040) DO netsh firewall add portopening UDP %%A "SRCDS Port "%%A

Link to comment
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

  • Who's Online   0 Members, 0 Anonymous, 9 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use