mirror of
https://github.com/shokinn/.files.git
synced 2025-01-18 21:22:25 +00:00
Add script to enable forwarding
on Windows network interfaces to get access to Hyper-V VMs
This commit is contained in:
parent
066af88bf1
commit
4438299f33
14
config.yaml
14
config.yaml
|
@ -18,9 +18,6 @@ actions:
|
||||||
[[ ! -d ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes ]] && mkdir -p ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes || echo "do nothing" >/dev/null
|
[[ ! -d ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes ]] && mkdir -p ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes || echo "do nothing" >/dev/null
|
||||||
[[ ! -d ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes/powerlevel10k ]] && git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes/powerlevel10k || echo "do nothing" >/dev/null
|
[[ ! -d ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes/powerlevel10k ]] && git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${{ZSH_CUSTOM:-${{HOME}}/.oh-my-zsh/custom}}/themes/powerlevel10k || echo "do nothing" >/dev/null
|
||||||
dotfiles:
|
dotfiles:
|
||||||
f_addhypervroute:
|
|
||||||
dst: ~/.bin/addhypervroute
|
|
||||||
src: bin/addhypervroute
|
|
||||||
d_bspwm:
|
d_bspwm:
|
||||||
dst: ~/.config/bspwm
|
dst: ~/.config/bspwm
|
||||||
src: config/bspwm
|
src: config/bspwm
|
||||||
|
@ -111,6 +108,12 @@ dotfiles:
|
||||||
f_kite:
|
f_kite:
|
||||||
src: local/bin/kite
|
src: local/bin/kite
|
||||||
dst: ~/.local/bin/kite
|
dst: ~/.local/bin/kite
|
||||||
|
f_addhypervroute:
|
||||||
|
dst: ~/.bin/addhypervroute
|
||||||
|
src: bin/addhypervroute
|
||||||
|
f_enablewslhypervforwarding:
|
||||||
|
dst: ~/.bin/enablewslhypervforwarding
|
||||||
|
src: bin/enablewslhypervforwarding
|
||||||
profiles:
|
profiles:
|
||||||
AINCRAD:
|
AINCRAD:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
|
@ -133,6 +136,7 @@ profiles:
|
||||||
- f_start_systemd_shell.sh
|
- f_start_systemd_shell.sh
|
||||||
- f_dotdrop.sh
|
- f_dotdrop.sh
|
||||||
- f_addhypervroute
|
- f_addhypervroute
|
||||||
|
- f_enablewslhypervforwarding
|
||||||
AINCRAD-wsl:
|
AINCRAD-wsl:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- d_fonts
|
- d_fonts
|
||||||
|
@ -154,6 +158,7 @@ profiles:
|
||||||
- f_start_systemd_shell.sh
|
- f_start_systemd_shell.sh
|
||||||
- f_dotdrop.sh
|
- f_dotdrop.sh
|
||||||
- f_addhypervroute
|
- f_addhypervroute
|
||||||
|
- f_enablewslhypervforwarding
|
||||||
yoetunheimr:
|
yoetunheimr:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- d_bspwm
|
- d_bspwm
|
||||||
|
@ -182,6 +187,7 @@ profiles:
|
||||||
- f_c3check
|
- f_c3check
|
||||||
- f_dotdrop.sh
|
- f_dotdrop.sh
|
||||||
- f_addhypervroute
|
- f_addhypervroute
|
||||||
|
- f_enablewslhypervforwarding
|
||||||
YOETUNHEIMR-wsl:
|
YOETUNHEIMR-wsl:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- d_fonts
|
- d_fonts
|
||||||
|
@ -203,6 +209,7 @@ profiles:
|
||||||
- f_start_systemd_shell.sh
|
- f_start_systemd_shell.sh
|
||||||
- f_dotdrop.sh
|
- f_dotdrop.sh
|
||||||
- f_addhypervroute
|
- f_addhypervroute
|
||||||
|
- f_enablewslhypervforwarding
|
||||||
ymir:
|
ymir:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_zshrc
|
- f_zshrc
|
||||||
|
@ -221,6 +228,7 @@ profiles:
|
||||||
- f_c3check
|
- f_c3check
|
||||||
- f_dotdrop.sh
|
- f_dotdrop.sh
|
||||||
- f_addhypervroute
|
- f_addhypervroute
|
||||||
|
- f_enablewslhypervforwarding
|
||||||
workspace:
|
workspace:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- d_fonts
|
- d_fonts
|
||||||
|
|
42
dotfiles/bin/enablewslhypervforwarding
Executable file
42
dotfiles/bin/enablewslhypervforwarding
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# {{@@ header() @@}}
|
||||||
|
#
|
||||||
|
|
||||||
|
WINHOME="$(echo "$(cmd.exe /C "echo %USERPROFILE%")" | tr -d '\r')"
|
||||||
|
WINHOMEWSL="$(wslpath ${WINHOME})"
|
||||||
|
|
||||||
|
cat <<EOF > "${WINHOMEWSL}/enablewslhypervforwarding.ps1"
|
||||||
|
#at top of script
|
||||||
|
if (!
|
||||||
|
#current role
|
||||||
|
(New-Object Security.Principal.WindowsPrincipal(
|
||||||
|
[Security.Principal.WindowsIdentity]::GetCurrent()
|
||||||
|
#is admin?
|
||||||
|
)).IsInRole(
|
||||||
|
[Security.Principal.WindowsBuiltInRole]::Administrator
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
#elevate script and exit current non-elevated runtime
|
||||||
|
Start-Process \`
|
||||||
|
-FilePath 'powershell' \`
|
||||||
|
-ArgumentList (
|
||||||
|
#flatten to single array
|
||||||
|
'-File', \$MyInvocation.MyCommand.Source, \$args \`
|
||||||
|
| %{ \$_ }
|
||||||
|
) \`
|
||||||
|
-Verb RunAs
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-NetIPInterface -ifAlias "vEthernet (Default Switch)" -Forwarding Enabled
|
||||||
|
Set-NetIPInterface -ifAlias "vEthernet (WSL)" -Forwarding Enabled
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
powershell.exe "${WINHOME}\enablewslhypervforwarding.ps1"
|
||||||
|
powershell.exe "Get-NetIPInterface | select ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding | Sort-Object -Property IfIndex | Format-Table"
|
||||||
|
|
||||||
|
|
||||||
|
rm ${WINHOMEWSL}/enablewslhypervforwarding.ps1
|
Loading…
Reference in a new issue