couldn't resolve host api.weixin.qq.com

1.代理服务器突然出现 couldn't resolve host api.weixin.qq.com 不知原因

2.重启nginx无效-----代码肯定没有动过(之前出现过,过了一天恢复)

3.防火墙关闭状态 -- service iptables status

4. ping api.weixin.qq.com

curl api.weixin.qq.com

5.修改dns后 8.8.8.8 可以curl和ping通过

6.还是显示couldn't resolve host api.weixin.qq.com 无法解析主机,重启network后被覆盖

7.解决覆盖问题

必须要在/etc /sysconfig/network-scripts/ifcfg-eth0里面最后加上dns的设置。要不然,重启后,肯定使用eth0设置中没有设 dns的相关信息,使/etc/resolv.conf恢复到原来的状态。

(1)若有多个ifcfg-ethX,首先查看一下当前机器的IP地址,先ifconfig 查看系统走的那个配置文件,

(2)添加DNS地址

8.resolv.conf设置 (一定要把代理主机写在上部,负责重启后会覆盖)

9.设置到此已经代码curl数据不通过

10.找到hosts文件/etc/hosts,抓出微信地址写进hosts 直接生效不用重启(问题解决)

原文地址:https://www.cnblogs.com/yangzailu/p/9958930.html