CentOS修改DNS地址方法|其他Linux发行版也应该适用,请自测 作者: Chuwen 时间: 2017-04-08 分类: Linux ## DNS是用于解析域名后端IP的服务器。 > Linux和Windows一样,可自定义DNS地址,修改起来非常简单。当Linux作为网站服务器使用,运行Wordpress查询速度缓慢的情况下,可尝试修改一个快速的DNS服务器解决以上问题。 ## 1.修改DNS配置文件 ```shell vi /etc/resolv.conf ``` [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ图片20170408185042.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ图片20170408185042.png) ## 2.按格式修改 ### 1.按 a 键进入编辑模式,然后用键盘上的方向键移动 光标(绿色的那个) [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408190122.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408190122.png) ### 2.按删除键,删除那个IP(DNS服务器),然后光标移动到下方,也删除那个IP(DNS服务器) [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408190553.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408190553.png) ### 3.然后光标移动到上方 [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408190703.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408190703.png) ### 4.输入需要更改的DNS的IP,比如我更改为 [`阿里DNS`](http://alidns.com/),就输入 `223.5.5.5.5` [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408191013.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408191013.png) ### 5.光标移动到下方,输入 `223.6.6.6` [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408191203.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408191203.png) > 注意事项:nameserver 和自己输入的DNS之间是有一个空格的 > > [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408191408.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408191408.png) ### 6.按 ESC 退出编辑,按 Shift + ; 即输入的是 `:`,然后输入 w 和 q ,按下 Enter 键,退出编辑并保存当前修改后的文件。 ### 7.输入 cat /etc/resolv.conf ### 查看DNS是否修改为自己的DNS。 [![](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408192211.png)](https://wordpress-ogdn-net.oss-cn-hangzhou.aliyuncs.com/wp-content/uploads/2017/04/QQ截图20170408192211.png) 标签: CentOS, DNS