Hello,
I have been looking out for a vb script or a s/w tool which will assign a specific IP based on the MAC address it reads from a txt file.
help me achieve this. it's very important to me.
any tools/how to/guides.
thanks in advance
Page 1 of 1
IP settings based on MAC address..? help needed...any scripts/tools out there?
#2
Posted 14 November 2005 - 08:24 AM
Hi gparmar,
I think this cmd file should do the trick
It reads the text file mac2ip.txt which should be in the same directory as this cmd file. And the text file looks something like this:
It can handle multiple ethernet adapters on one computer.
Good luck with it
I think this cmd file should do the trick
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
REM Set the subnetmask
SET NETMASK=255.255.255.0
REM Retrieve "adapter name" & mac address using ipconfig
FOR /F "DELIMS=" %%M in ('IPCONFIG.EXE /ALL') DO @(
SET LINE=%%M
FOR /F "TOKENS=1" %%A IN ("!LINE!") DO @(
IF X%%A==XEthernet (
SET ADAPTER=!LINE:Ethernet adapter =!
SET ADAPTER=!ADAPTER::=!
SET MAC=
) ELSE IF X%%A==XPhysical (
SET MAC=!LINE:* : =!
REM Use Adapter with double quotes to submit full adaptername as 1 parameter
CALL :SET_IP !MAC! "!ADAPTER!"
)
)
)
GOTO END
:SET_IP
REM Read MAC & IP addresses from file, and if MAC is %1 set IP
FOR /F "TOKENS=1,2" %%I IN ('TYPE "%~dp0\mac2ip.txt"') DO IF %%I==%1 SET IP=%%J
IF DEFINED IP (
REM Update IP address for adapter
NETSH INTERFACE IP SET ADDRESS STATIC NAME=%2 %IP% %NETMASK%
) ELSE (
ECHO MAC Address not found in %~dp0\mac2ip.txt
)
GOTO END
:END
It reads the text file mac2ip.txt which should be in the same directory as this cmd file. And the text file looks something like this:
# MAC Address IP Address 00-AA-11-BB-22-CC 10.10.10.101 00-DD-11-EE-22-FF 10.10.11.101 00-11-22-33-44-55 10.10.12.101
It can handle multiple ethernet adapters on one computer.
Good luck with it
Share this topic:
Page 1 of 1



Help
Back to top








