Switch Network Settings With Batch Files - A quick way to change IP, Gateway, DNS

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #18) by iGuest on Jul 1 2008, 11:53 AM. (Line Breaks Removed)
how to add the one more ip address to a batch file Switch Network Settings With Batch Files Hi,Iam Rajkumar working in crystal granite marble pvt ltd.Here our lan ip is 192.168.0.1 subnetmask is 255.255.255.0And internet ip is 10.7.192.81 subnetmask is 255.255.255.240I want to add the one moreip address to the above mentioned batchfile I can add the one more dns also but iam not able to add the i... read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Free Web Hosting > Computers & Tech > How-To's and Tutorials > Networking

Switch Network Settings With Batch Files - A quick way to change IP, Gateway, DNS

curare
Let's suppose you are using two network settings with your laptop frequently. Wether it's a wireless or wired network, all the same: Every time you want to change the IP, subnet mask, default gateway and DNS Server(s) of your network connection in any flavour of Windows, you have to click through menus, submenus, and from that you go to yet another submenu... you have been there, it's awful. mad.gif

There is a better way: the command "netsh" on your command prompt can change all the aforementioned settings, and if you put them in a batch file, you can change them with a double mouse click.

To familiarize yourself with the command, click on "Start/Run" and enter "cmd". The command prompt opens. Enter "netsh /?" and you'll see the options and parameters of this powerful command and its subsets.

Open your network connections folder in the Control Panel. Windows usually calls the Network Interface Card "Local Area Connection" If you want to change the settings of your wireless network settings go to the appropriate status window. Make sure you know the name. Click on it, than click "Properties" and there double-click "Internet Protocol (TCP/IP)" This is where you usually go when you change those settings.

Now open your text editor and create a new file which you will call "Connection_settings_1.bat", or whatever is easily memorable and you associate with your settings # 1. Enter the following code:

CODE

netsh interface ip set address name="Local Area Connection" source=static addr=111.222.333.444 mask=255.255.255.255
netsh interface ip set address name="Local Area Connection" gateway=555.666.777.888 gwmetric=0
netsh interface ip set dns name="Local Area Connection" source=static addr=999.111.222.333  
netsh interface ip add dns name = "Local Area Connection" addr = 444.555.666.777  


Of course you must enter the numbers if the IP, subnet mask, gateway and DNS Server(s) according to your settings! As most of you know, 111.222.333.444 is just an example of an actually non-existing IP address. Save the file.

Assuming that your connection settings #2 are different, say with DHCP, than create another batch file and name it differently from the first.

CODE

netsh interface ip set address name="Local Area Connection" dhcp
netsh interface ip set dns name="Local Area Connection" dhcp


Save the file. If you need WINS you should enter the code

CODE

netsh interface ip set wins name="Local Area Connection" source=static addr=   .   .   .  


at the end of the batch files(s) with the correct settings instead of the dots.

Now test your new batch files. When you double-click on one, a command prompt window opens and the batch file is processed line by line. This takes some time (25 seconds in my case with a 2.8 GH Intel Processor), it is not done instantly. When the processes are finished the window closes.

To check if the settings are applied correctly, open a command prompt and entee "ipconfig". Than double-click on the second batch file and after it is finished put the command prompt where you entered "ipconfig" in focus and enter "ipconfig" again. The settings have changed with one double-click! rolleyes.gif

A final note: Yes, there is little proggies which do this job as well. One of them is even free. But you can do it without launching any extra program, using the built - in capabilities of your operating system.

curare

 

 

 


Reply

OpaQue
Nice professionally written tutorial. Keep it up smile.gif

Reply

miCRoSCoPiC^eaRthLinG
Yeah hey -where's the reputation system ... we need one back for sure wink.gif Otherwise such works go completely unappreciated. Good one curare - that's the kind of well organized and quality tutorial/post we're always hoping for smile.gif

Reply

curare
Thank you for your kind words, gentlemen. I have worked some hours on this... and I enjoyed it!

I have a minor (?) request: could you please show your appreciation for this howto by adding some points to my account? While my hosting request has been kindly approved by our dear leader tongue.gif I am stuck at 31,25 points and my guess would be that this howto should be worth another two or three points smile.gif

TIA,

curare

Reply

MarkBla
Heey, cool.gif

You can also set DHCP Server on. Everytime you connect, you will receive a new ip adres. tongue.gif

The only disadvantages are that your ip adres may change every time you reconnect. But that's only in some cases a problem. dry.gif


Greets,
Mark

Reply

FeedBacker
You can also try "Net Profile Switch" http://www.jitbit.com/netprofileswitch.aspx to store and switch multiple network profiles

Reply

FeedBacker
Hi

Do you know a way to run multiple batch files with netsh, at certain intervals of time. I want to schedule ip changing at 10 minutes interval, let's say.
Can it be done?
Greets!

-kukubau

Reply

FeedBacker
schedule network settings batch
Switch Network Settings With Batch Files

Replying to Feedbacker

Sure, there's already a tool. "scheduled tasks". Then schedule the task to run the batch file at whatever interval you want.

-reply by John Smith

Reply

FeedBacker
this doesnt work
Switch Network Settings With Batch Files

I have copied and pasted the exact text in the web page above into a bat file and run it, but it just doesnt seem to work, I am trying to update my wireless connection settings in vista (so I change the name to Wireless network connection etc) but still nothing, please help! :(

Thanks

Pete

-reply by pete

Reply

FeedBacker
Very useful info
Switch Network Settings With Batch Files

This tutorial saved my day. I used this technique to switch between two networks. It works just fine. Very informational and useful. Keep it up!

-reply by Subbu

Reply

Latest Entries

iGuest
how to add the one more ip address to a batch file
Switch Network Settings With Batch Files

Hi,


Iam Rajkumar working in crystal granite marble pvt ltd.


Here our lan ip is 192.168.0.1 subnetmask is 255.255.255.0

And internet ip is 10.7.192.81 subnetmask is 255.255.255.240


I want to add the one moreip address to the above mentioned batchfile


I can add the one more dns also but iam not able to add the ip address


Please help me in this scenario



Thnaks and Regards,
Rajkumar.S

-reply by RAJKUMAR

Reply

iGuest
Thanks
Switch Network Settings With Batch Files

I'm using vista but it didn't work as mentioned above

I tried

Set address name="Wireless Network Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

And now it works perfectly!

-reply by Quang Tran

Reply

iGuest
Vista problems
Switch Network Settings With Batch Files

Hiya,

Have you tried running it by right clicking and using 'run as administrator' instead.

It worked for me as I was getting the:

This command needs to be elevated

HTH

-reply by Andy Holland

Reply

iGuest
Vista settings
Switch Network Settings With Batch Files

Emmy- that's because you need to type the following into a batch file:

@ECHO OFF

Set varip=192.168.0.99
Set varsm=255.255.255.0
Set vargw=192.168.0.100
Set vardns1=195.131.131.11
Set vardns2=195.131.131.12

ECHO Setting IP to static
Netsh int ipv4 set address name = "LAN-verbinding 4" source = static address = %varip% mask = %varsm%

ECHO Setting IP Address and Subnet Mask
Netsh int ipv4 set address name = "LAN-verbinding 4" address = %varip% mask = %varsm% gateway = %vargw% gwmetric = 1

ECHO Setting Primary DNS
Netsh int ip set dns name = "LAN-verbinding 4" source = static addr = %vardns1%

ECHO Setting Secondary DNS
Netsh int ip add dns name = "LAN-verbinding 4" addr = %vardns2%

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

Pause

-reply by Razzor

Reply

iGuest
Thanks
Switch Network Settings With Batch Files

Great stuff. Keep up the good work



-reply by Pyous

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Pages: 1, 2
Recent Queries:-
  1. change ip addrees via batch - 0.11 hr back. (1)
  2. bat switch network card - 0.88 hr back. (2)
  3. batch file to change dns ip - 0.98 hr back. (1)
  4. batch network settings - 1.12 hr back. (1)
  5. change ip xp batch - 1.21 hr back. (1)
  6. batch file to change ip address - 2.11 hr back. (6)
  7. netsh problem bat - 3.29 hr back. (1)
  8. batch files for changing the ip - 4.11 hr back. (1)
  9. change gateway with bat file - 4.30 hr back. (1)
  10. netsh interface ip set wins - 5.28 hr back. (1)
  11. ip change batch - 5.86 hr back. (1)
  12. quick ip change - 6.57 hr back. (2)
  13. batch file to change network settings - 7.21 hr back. (1)
  14. batch file for editing the firewall settings - 12.96 hr back. (1)
Similar Topics

Keywords : switch, network, settings, batch, files, quick, change, ip, gateway, dns

  1. Setting Up A Peer To Peer Network.
    From laying the wires to sharing the printers. (0)
  2. Lock Down Switch Port To Increase Network Security
    Assign the MAC address to each switch port. (0)
    One way to boost network security is to use Cisco's Port Security feature to lock down switch
    ports. A growing challenge facing network administrators is determining how to control who can
    access the organization's internal network—and who can't. For example, can anyone walk into
    your office, plug in a laptop, and access your network? You might argue that the wall jack has no
    connection to a switch, but couldn't someone just pull the Ethernet cable from a working PC and
    connect to the network that way? You might think this an unlikely scenario, but it d....

    1. Looking for switch, network, settings, batch, files, quick, change, ip, gateway, dns






*SIMILAR VIDEOS*
Searching Video's for switch, network, settings, batch, files, quick, change, ip, gateway, dns
advertisement




Switch Network Settings With Batch Files - A quick way to change IP, Gateway, DNS