参考:https://www.delftstack.com/zh/howto/powershell/powershell-run-as-administrator/ 然后随意执行一条wsl指令,这样如果wsl在后台未启动的情况下会自动启动,确保出现WSL的虚拟网卡;接下来就是网络桥接指令,注意把Set-VMSwitch WSL -NetAdapterName 以太网中的以太网改为你自己机器的网卡名称。最后是用到了windo...
echo"正在解除wsl桥接..."Set-VMSwitch WSL -SwitchType Internalecho"正在重启wsl"wsl --shutdownwsl --cd~ -elsecho"`ndone"pause 需要使用管理员权限的powershell来执行ps1文件 如果powershell无法执行ps1文件,则需执行以下命令 Set-ExecutionPolicy Unrestricted-ForceSet-ExecutionPolicy "RemoteSigned"-ScopeCurrentU...
echo "Delete WSL Bridge..." Set-VMSwitch WSL -SwitchType Internal echo "Restart WSL" wsl --shutdown wsl --cd ~ -e ls echo "All Done!" pause 测试: 1.启动桥接 管理员身份启动windows ternimal preview/终端预览,默认进入终端,执行命令 .\wsl-bridge-on.ps1 在主机终端pingWSL: ping 192.168.1....
执行以下代码: Set-VMSwitchWSL-NetAdapterNameWi-Fi 即可将 WSL 使用的网卡桥接到Wi-Fi这个网卡之上。 接下来进入 WSL 配置 IP 地址和网关,例如网关为192.168.1.1,IP 设置为192.168.1.150/24: sudo ip addr del$(ip addr show eth0|grep'inet\b'|awk'{print $2}'|head -n 1)dev eth0 sudo ip addr...
[wsl2]networkingMode=bridgedvmSwitch=VETHipv6=true 粘贴以上内容到.wslconfig并保存 networkingMode指定网络模式为桥接 vmSwitch指定网卡为上面创建的虚拟网卡,注意名称一致 ipv6配置为可选,删除本行即禁用,也可改为false 对于Windows 10 以及 Windows 11 22H2 以前版本,将使用以下项目 ...
vmSwitch=WSL_external dhcp=false # 禁止DHCP动态分配IP地址 ipv6=true # Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB #可更改 memory=4GB # Sets the VM to use two virtual processors ...
[wsl2]networkingMode=bridgedvmSwitch=WSLBridgeipv6=truememory=2GBswap=4GBlocalhostForwarding=true 重启电脑后生效 Miniconda 1,下载miniconda 2,sh miniconda安装包,然后一直enter就行,确认路径为/opt/miniconda 3,配置文件,vim /etc/profile,末尾添加export PATH=/opt/miniconda/bin:$PATH ...
IsolateVSwitch// Type = StaticPCWSTRnetSettings=LR"({"Name":"WSL","Type":"ICS","IsolateSwitch...
PS C:\WINDOWS\system32>Set-VMSwitchWSL-NetAdapterName'Name_of_your_phsyical_windows_NIC'Set-VMSwitch: Failedwhileadding virtual Ethernetswitchconnections. External Ethernet adapter'Name_of_your_phsyical_windows_NIC'is already bound to the Microsoft VirtualSwitchprotocol. At line:1char:1+Set-VMSw...
wsl -d ubuntu powershell -Command "Set-VMSwitch WSL -SwitchType Internal" which sets the WSL virtual switch back to Internal after WSL will be shut down later Made the shortcut of this ubuntu.bat and set this shurtcut to run as admin (create shortcut of the ubuntu.bat and set -> ...