一招解决win10下ubuntu子系统软件包安装难题
Win10系统新特性支持安装linux子系统值得我们广大程序员为之点赞。但我安装完成Ubuntu(Debian一样)子系统后,发现子系统域名解析非常有问题。网上搜索相同问题很多且没有解决办法。不解决此问题,在线安装ubuntu软件包也成为不可能完成的任务,对程序员来说显然是不可接受的。
Win10系统中linux子系统IP地址、网关和hosts文件都是子系统启动后动态拷贝自主系统,网络配置方法与真正Ubuntu系统完全不同,尝试通常的方法配置域名服务地址完全无效,想安装软件包找不到任何软件仓库。怎么办?只能试试本地解析,在win10中ping软件仓库获得ip地址,加入配置到win10系统的hosts文件中,再次启动ubuntu子系统,安装软件包,成功成功还是成功,就这样,一招解决Ubuntu子系统的在线软件包安装难题。
![a9d0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/a9d0aa53-0b14-eb11-8da9-e4434bdf6706.png)
Win10系统支持linux子系统
![aad0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/aad0aa53-0b14-eb11-8da9-e4434bdf6706.png)
Win10提供可以安装的linux子系统
![abd0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p02.5ceimg.com/content/abd0aa53-0b14-eb11-8da9-e4434bdf6706.png)
Win10与ubuntu子系统相同的ip地址
![add0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p04.5ceimg.com/content/add0aa53-0b14-eb11-8da9-e4434bdf6706.png)
百度搜索的子系统域名解析问题
![afd0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/afd0aa53-0b14-eb11-8da9-e4434bdf6706.png)
右边ubuntu无法解析域名
![b0d0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p04.5ceimg.com/content/b0d0aa53-0b14-eb11-8da9-e4434bdf6706.png)
右边Ubuntu动态拷贝win10的hosts
![b1d0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/b1d0aa53-0b14-eb11-8da9-e4434bdf6706.png)
域名解析问题解决前Ubuntu子系统无法安装软件包
![b2d0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/b2d0aa53-0b14-eb11-8da9-e4434bdf6706.png)
可以本地解析的hosts文件(加入软件仓库ip)
![b3d0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/b3d0aa53-0b14-eb11-8da9-e4434bdf6706.png)
通过本地域名解析安装f77软件包成功
![b5d0aa53-0b14-eb11-8da9-e4434bdf6706.png](http://p01.5ceimg.com/content/b5d0aa53-0b14-eb11-8da9-e4434bdf6706.png)
通过本地域名解析安装zip软件包成功