Entry
Network: Microsoft: Windows: How to create batch file to set IP address, mask, gateway, DNS, proxy?
Jan 22nd, 2006 11:10
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 22 January 2021 - 06:15 pm --------------------
Network: Microsoft: Windows: How to create batch file to set IP
address, mask, gateway, DNS, proxy?
In general use:
netsh interface ip set address name=<the name of your network card>
source=<static> addr=<your IP address> mask=<your mask>
Steps: Overview:
1. -Open Notepad
2. -Create a file
1. -E.g.
ipset.bat
3. -Put the following text in this batch file
--- cut here: begin --------------------------------------------------
@REM
@REM netsh.exe sets the IP address, subnet mask gateway, one or more
DNS from the command line (this file is located in c:\windows\system32)
@REM
@REM netsh.exe sets the IP address + subnet mask for that network card
netsh.exe interface ip set address name=<your network card name>
source=static addr=<your network card IP address> mask=<your network
card subnet mask>
@REM
@REM netsh.exe sets the gateway for that network card
netsh.exe interface ip set address name=<your network card name>
gateway=<your gateway IP address> gwmetric=1
@REM
@REM netsh.exe sets the 1st DNS server for that network card
netsh.exe interface ip set dns name=<your network card name>
source=static addr=<your DNS server 1 IP address> register=primary
@REM
@REM netsh.exe sets the 2nd DNS server for that network card
netsh.exe interface ip add dns name=<your network card name>
addr=<your DNS server 2 IP address> index=2
--- cut here: end ----------------------------------------------------
4. or more in general:
create a batch file: 'ipsetgeneral.bat'
--- cut here: begin --------------------------------------------------
@REM %1 = network card name (e.g. "Local Area Connection")
@REM %2 = IP address (e.g. 26.162.159.32 for test machine 1)
@REM %3 = subnet mask (e.g. 255.255.248.0)
@REM %4 = gateway (e.g. 26.162.152.1)
@REM %5 = dns 1 (e.g. 26.162.8.150)
@REM %6 = dns 2 (e.g. 36.8.64.51)
@REM
@REM e.g. ipsetgeneral.bat "Local Area Connection" 26.162.159.32
255.255.248.0 26.162.152.1 26.162.8.150 36.8.64.51
@REM
netsh interface ip set address name="Local Area Connection"
source=static addr=%2 mask=%3
netsh interface ip set address name="Local Area Connection" gateway=%4
gwmetric=1
netsh interface ip set dns name="Local Area Connection" source=static
addr=%5 register=primary
netsh interface ip add dns name="Local Area Connection" addr=%6 index=2
@if not exist proxyset.reg @pause "please check and adapt the path to
the registry file" ELSE regedit.exe /s proxyset.reg
@goto next
:next
--- cut here: end ----------------------------------------------------
---
---
Internet: see also:
---
Network:Microsoft:Windows:How to create batch file to set IP
address,mask,gateway,DNS,proxy?Overview
http://www.faqts.com/knowledge_base/view.phtml/aid/39154/fid/868
---
Operating system: Microsoft: Windows: XP: Link: Overview: Can you give
an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/34878/fid/868
----------------------------------------------------------------------