ip 주소를 cmd 창에서 입력을 하려고 하는데, 랜카드 이름을 지정할 수 있는 방법이 없을까 찾아보다 스크립트로 확인할 수 있는 방법을 찾아 기록합니다.

 

@echo on

chcp 949

for /f "tokens=5,6 delims= " %%a IN ('netsh interface ipv4 show interface ^| findstr 이더 ^| findstr /v dis') do set result=%%a %%b

if "%result%" =="이더넷 " (
for /f "tokens=5 delims= " %%a IN ('netsh interface ipv4 show interface ^| findstr 이더 ^| findstr /v dis') do set result1=%%a
echo netsh interface ipv4 set address name="%result1%" static 192.168.100.161 255.255.255.0 192.168.100.1
echo netsh interface ipv4 set dns name="%result1%" static 8.8.8.8
echo netsh interface ipv4 add dns name="%result1%" 8.8.4.4 index=2
) else (
echo netsh interface ipv4 set address name="%result%" static 192.168.100.161 255.255.255.0 192.168.100.1
echo netsh interface ipv4 set dns name="%result%" static 8.8.8.8
echo netsh interface ipv4 add dns name="%result%" 8.8.4.4 index=2
)

'기술 노트 > Windows' 카테고리의 다른 글

Windows 로그인 OTP 적용하기  (1) 2024.10.10
계정 비밀번호 암호화하기  (0) 2023.12.12
virtualbox 설치하기  (0) 2023.09.27
Windows PC 시간 예약해서 끄기  (0) 2023.06.23
가상 OS 설치하기  (0) 2023.05.10

+ Recent posts