当前位置: 首页 > Linux

OpenResty安装Luarocks出现的DNS污染解决

时间:2023-04-06 22:42:45 Linux

OpenResty安装Luarocks导致DNS污染的解决方案openresty下安装luarocksLua包管理工具Luarocks下载luarocks出现如下错误:[root@centos6102~]#wgethttp://luarocks.org/releases/luarocks-2.4.2.tar.gz--2021-01-2611:09:31--http://luarocks.org/releases/luarocks-2.4.2.tar.gzResolvingluarocks.org...45.33.61.132Connectingtoluarocks.org|45.33.61.132|:80...connected.HTTP请求已发送,正在等待响应...302MovedTemporarilyLocation:https://luarocks.github.io/luarocks/releases/luarocks-2.4.2.tar.gz[following]--2021-01-2611:09:31--https://luarocks.github.io/luarocks/releases/luarocks-2.4.2.tar.gzResolvingluarocks.github.io...::1,127.0.0.1连接到luarocks.github.io|::1|:443...失败:连接被拒绝。连接到luarocks.github.io|127.0.0.1|:443...失败:连接被拒绝。从报错信息中可以看到请求http://luarocks.org/releases/luarocks-2.4.2.tar.gzwasredirectedtohttps://luarocks.github.io/luarocks/releases/luarocks-2.4.2.tar.gz302,失败:连接被拒绝。使用ping排错为了排错,我们先pingluarocks.github.io[root@centos6102~]#pingluarocks.github.ioPINGluarocks.github.io(127.0.0.1)56(84)bytesofdata.64来自本地主机(127.0.0.1)的字节:icmp_seq=1ttl=64时间=0.032ms来自本地主机(127.0.0.1)的64字节:icmp_seq=2ttl=64时间=0.039ms来自本地主机(127.0.0.1)的64字节:icmp_seq=3ttl=64time=0.029ms然后pinggithub.io[root@centos6102~]#pingluarocks.github.ioPINGluarocks.github.io(127.0.0.1)56(84)字节数据.64字节来自本地主机(127.0.0.1):icmp_seq=1ttl=64time=0.032ms64bytesfromlocalhost(127.0.0.1):icmp_seq=2ttl=64time=0.039ms64bytesfromlocalhost(127.0.0.1):icmp_seq=3ttl=64time=0.029ms您可以看到两个地址都解析为127.0.0.1。这时候我们就需要检查一下系统的hosts文件是否被篡改了。本地hosts文件[root@centos6102~]#cat/etc/hosts127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6可以看到本机的hosts文件是正常的,我们可以认为远程DNS解析已经被污染了。(DNS污染)。方案一:修改hosts文件,在/etc/hosts文件中加入github.io的解析(github.io的ip可以在站长中国查看)185.199.111.153luarocks.github.io185.199.110.153github.io去pingluarocks.github.iopinggithub.io看域名解析是否正确[root@centos6102~]#pingluarocks.github.ioPINGluarocks.github.io(185.199.111.153)56(84)bytesofdata.64bytesfromluarocks.github.io(185.199.111.153):icmp_seq=1ttl=53time=206ms64bytesfromluarocks.github.io(185.199.111.153):icmp_seq=2ttl=53时间=218ms64字节来自luarocks.github.io(185.199.111.153):icmp_seq=3ttl=53时间=205ms64字节来自luarocks.github.io(185.199.111.153):icmp_seq=4ttl=53时间=196ms[root@centos6102~]#pinggithub.ioPINGgithub.io(185.199.110.153)56(84)字节数据。来自github.io(185.199.110.153)的64字节:icmp_seq=2ttl=53time=236ms64字节来自github.io(185.199.110.153):icmp_seq=3ttl=53time=288ms64字节来自github.io(185.199.110.153):icmp_seq=4ttl=53time=236ms然后运行??wgethttp://luarocks。组织/发布s/luarocks-2.4.2.tar.gz可以正常下载。方案二:更换DNS服务器,使用dig测试可用的DNS服务器。网上有很多可用的DNS服务器,比如常用的144.144.144.144和8.8.8.8。我们可以使用dig命令来测试这些服务器是否可以正确解析github.io。格式如下:dig[domainname]@[nameserverip]下面测试一下使用8.8.8.8解析github.io[root@centos6102lua]#diggithub.io@8.8.8.8;<<>>DiG9.8.2rc1-RedHat-9.8.2-0.68.rc1.el6_10.8<<>>github.io@8.8.8.8;;全局选项:+cmd;;得到答案:;;->>HEADER<<-操作码:QUERY,状态:NOERROR,id:57042;;标志:qr;查询:1,答案:1,权限:0,附加:0;;问题部分:;github.io。在一个;;答案部分:github.io。868输入127.0.0.1;;查询时间:163毫秒;;服务器:8.8.8.8#53(8.8.8.8);;时间:2021年1月26日星期二12:15:12;;MSGSIZErcvd:43可以在github.io上看到。868INA127.0.0.1,8.8.8.8无法解析github.io。遗憾的是,作者没有找到可以正确解析github.io的DNS,只能采用方案一:修改hosts文件。如果找到可以正确解析的,更改DNS如下(假设8.8.8.8可用,读者可以将其替换为自己找到的DNS)。方法一:静态ip永久修改DNS服务器如果是静态ip地址,则修改以下文件vi/etc/resolv.conf为(或其他可用的DNS服务器)nameserver8.8.8.8nameserver8.8.4.4修改成这样,servicenetworkreload重启仍然有效方法二:DHCP永久修改DNS如果服务器是DHCP,修改/etc/resolv.conf后,servicenetworkreload重启网络,发现/etc/resolv.conf恢复原样状态。这时需要修改以下文件。vi/etc/sysconfig/network-scripts/ifcfg-eth0修改(或其他可用的DNS服务器)DNS1=8.8.8.8DNS2=8.8.4.4重启后,/etc/resolv.conf也会改成对应的DNS服务器。参考资料:linux查看域名解析DNS污染什么是DNS污染?如何解决DNS污染?