This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
前提:开启hyper-V
1. 获取所有网卡信息
```shell
Get-NetAdapter
```
![[Snipaste_2023-04-01_17-47-48.png]]
2. 启动WSL,打开powershell(管理员模式),选择网卡桥接
这里桥接到WLAN
```shell
Set-VMSwitch WSL -NetAdapterName WLAN
# 中文
Set-VMSwitch WSL -NetAdapterName "以太网 3"
```
3. 查看宿主机网关
```shell
ipconfig
```
找到IP段和网关
![[Snipaste_2023-04-01_17-47-48 1.png]]
4. 修改WSL IP地址及网关
```shell
# 绑定到eth0网卡
sudo ip addr del $(ip addr show eth0 | grep 'inet\b'| awk '{print $2}'| head -n 1) dev eth0
# 设置IP段
sudo ip addr add 192.168.0.150/24 broadcast 192.168.0.255 dev eth0
# 设置网关
sudo ip route add 0.0.0.0/0 via 192.168.0.1 dev eth0