diff --git a/bin/add-host.ps1 b/bin/add-host.ps1 index 9c645aa..5945d36 100644 --- a/bin/add-host.ps1 +++ b/bin/add-host.ps1 @@ -13,7 +13,7 @@ if (!$PSBoundParameters.ContainsKey('wslHost')) { $file = $env:windir + '\System32\drivers\etc\hosts' # Get the current IP address of the wsl instance. -$wslIp = $(wsl -e hostname -I) +$wslIp = $(wsl -e /bin/bash -c "ip -4 -o address show eth0 | grep -oP """"(?<=inet\s)\d+(\.\d+){3}""""") # Read the last byte of the file. $size = 1 diff --git a/bin/update-hosts-ips.ps1 b/bin/update-hosts-ips.ps1 index d393d60..b6e8a45 100644 --- a/bin/update-hosts-ips.ps1 +++ b/bin/update-hosts-ips.ps1 @@ -7,7 +7,7 @@ $file = $env:windir + '\System32\drivers\etc\hosts' $regex = '(?<=^\s*)(\d+\.\d+\.\d+\.\d+)(?=.*\.' + $wslTld + '(\s+|$))' # Get the current IP address of the wsl instance. -$wslIp = $(wsl -e hostname -I).Trim() +$wslIp = $(wsl -e /bin/bash -c "ip -4 -o address show eth0 | grep -oP """"(?<=inet\s)\d+(\.\d+){3}""""") Write-Host "Updating hosts file for TLD [.$wslTld] with WSL IP [$wslIp]."