##############################################################################################################
#
# Purpose: Manually set the Binding Order (order of preference) for a specified Network Interface
#
# Written by: Joshua D. True
#
# Notes: This script has been set to only show interfaces with an active connection (to avoid confusion dealing with unused virtual interfaces)
# To change the script to show all interfaces, remove the following ### | where {$_.ConnectionState -eq "Connected"} ### from both lines
# of code that begin with "Get-NetIPInterface"
# This script requires Admin elevation!
#
##############################################################################################################
# Display active interfaces to be changed
Write-Host -ForegroundColor Red "Below is of network conenctions (with an active connection) sorted in order of highest priority first (BEFORE CHANGES)"
Get-NetIPInterface | where {$_.ConnectionState -eq "Connected"} | select ifIndex,InterfaceAlias,InterfaceMetric,AddressFamily,ConnectionState | sort InterfaceMetric | FT
# Prompt user for index and new metric value of an interface
$nicIndex=Read-Host "Enter the Index of the network connection that you would like to change"
$nicIMetric=Read-Host "Enter the new Interface Metric value to be assigned to the Index you just selected (lower number means higher priority)"
If (($nicIndex -ne $null) -and ($nicIMetric -ne $null)) {
Set-NetIPInterface -InterfaceIndex $nicIndex -InterfaceMetric $nicIMetric
}
# Display active interfaces after change has been made (just for confirmation that change you made was entered correctly)
Write-Host -ForegroundColor Green "Below is of network conenctions (with an active connection) sorted in order of highest priority first (AFTER CHANGES)"
Get-NetIPInterface | where {$_.ConnectionState -eq "Connected"} | select ifIndex,InterfaceAlias,InterfaceMetric,AddressFamily,ConnectionState | sort InterfaceMetric | FT
# END
질문자가 마지막 자답을 하기 전의 덧글에 대한 알림 이메일을 퇴근 무렵에 읽어서, 집에 가서 답변해야 겠다는 사이... 이미 자답이 달렸더군요. ^^; 음... 쪼끔 허탈하긴 했지만 ^^ 어쨌든 그래도 이런 시행 착오는 많이들 알고 계시는 것이 좋을 것 같아서 같이 공유해 봅니다. ^^
참고로, 현장감(?)을 살리기위해 마지막 자답을 읽기 전인 것처럼 글을 썼습니다.
질문자의 문제는, 다음과 같은 코딩을 한 경우 무선랜 IP 가 먼저 조회된다는 것입니다.
IPAddress[] ipList = Dns.GetHostAddresses(Dns.GetHostName());
ipList[0] == 무선랜 IP
ipList[1] == 유선랜 IP
혹시, 우리가 흔히 알고 있는 ipconfig 명령어도 Dns.GetHostAddresses의 반환 순서와 같지 않을까요?
확인을 위해, 유/무선 랜카드가 설치되어 있는 제 컴퓨터에서 ipconfig 을 실행해 보면 다음과 같은 결과가 나옵니다.