栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Win10子系统ubuntu20.04设置静态ip、笔记

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Win10子系统ubuntu20.04设置静态ip、笔记

Win10子系统ubuntu20.04设置静态ip、笔记

简单有效的方法

一个新思路:不改IP,加一个指定IP。

在 Windows 10 中,以管理员权限运行 CMD 或 Powershell,然后执行以下两条命令:

::在Ubuntu中添加一个IP地址,192.168.50.16,命名为eth0:1

wsl -d [UBUNTU_NAME] -u root ip addr add 192.168.50.16/24 broadcast 192.168.50.255 dev eth0 label eth0:1


::在Win10中添加IP地址,192.168.50.88

netsh 接口 ip 添加地址“vEthernet (WSL)” 192.168.50.88 255.255.255.0

eg.

wsl -d Ubuntu-20.04 -u root ip addr add 192.168.50.16/24 broadcast 192.168.50.255 dev eth0 label eth0:1

netsh interface ip add address "vEthernet (WSL)" 192.168.50.88 255.255.255.0

以后访问Ubuntu时使用 192.168.50.16 ,访问Win10时使用 192.168.50.88 。

可以将以上两行命令保存为.bat文件,然后放入引导区,每次都自动执行。

后记

不知道为啥, 我的 MObaXterm 中自动多了一个 ssh 连接…

如果看不懂上面的话没关系, 不影响整体阅读;


reference

@online{BibEntry2022Feb,
title = {{[Solved] WSL Static IP on WSL 2}},
year = {2022},
month = feb,
date = {2022-02-22},
urldate = {2022-04-28},
note = {[Online; accessed 28. Apr. 2022]},
url = {https://lifesaver.codes/answer/static-ip-on-wsl-2-418},
abstract = {{I give you a new idea: Instead of changing the IP add a designated IP In Windows 10 run CMD or Powershell with administrator privilege}}
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/844522.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号