暑假的时候把整个电脑系统由win10换成了ubuntu18.04(回头再写个安装ubuntu18.04时应该避免的坑..)
由于某些众所周知的原因,steam社区在大陆无法正常连接。
在win10系统下,其常用解决办法是用steamcommunity_302修复工具,开启加速器等。
而在ubuntu系统下,steamcommunity_302修复工具和加速器通常无法运行,怎么办。
steam社区无法正常连接是由于DNS污染造成的,电脑不能将steam社区的域名与正确的IP地址对应起来。
有一个简易的修复办法,修改hosts文件,手动告知电脑steam社区的IP地址。
一般/etc/hosts 的内容一般有如下类似内容:
127.0.0.1 localhost.localdomain localhost
192.168.1.100 linmu100.com linmu100
192.168.1.120 ftpserver ftp120
而我们要在其中加入的格式为 steam社区ip steamcommunity.com
steam社区的域名是steamcommunity.com。注意前面没有www.
现在问题就只有一个了,我们如何去获得steam社区的ip呢?
答案 去ping store.steampowered.com
我们看到store.steampowered.com 的ip地址是23.13.185.114
这个就是steamcommunity.com的ip
我们在hosts文件中加入
ok! 我们再去连接steam社区,就可以连接成功啦!
当然这个方法只适合于DNS污染导致导致的无法联通。
用python编写代码简化ping 再 修改问价的代码如下
#coding=utf-8
import os
str="ping -c 1 store.steampowered.com"
a=os.popen(str).read()
ips=a.find('(')+1
ipf=a.find(')')-1
ip=a[ips:ipf]
print (ip)
fi=open('/etc/hosts','r+')
fi.write(ip+" steamcommunity.com\n")
这个小脚本就能轻松完成上面所说的任务啦。
用pyinstaller生成的可执行文件在这里
https://download.csdn.net/download/qq_38900288/10678661