Linux更换DNS教程

教程

Linux更换DNS教程

2023-04-06 10:20


Linux更换dns教程






宝塔可使用应用商店内的Linux工具箱进行更换dns的操作

以下是使用ssh连接进行更换dns的方法

一条命令更换命令:

更换国内DNS:

echo -e "options timeout:1 attempts:1 rotate nameserver 119.29.29.29 nameserver 114.114.114.114">/etc/resolv.conf;

更换国外DNS:

echo -e "options timeout:1 attempts:1 rotate nameserver 8.8.8.8 nameserver 8.8.4.4" >/etc/resolv.conf;

推荐国内外并行的DNS配置:

echo -e "options timeout:1 attempts:1 rotate nameserver 8.8.8.8 nameserver 223.5.5.5" >/etc/resolv.conf;

查看修改:

查看修改后的DNS配置:

cat /etc/resolv.conf

其他环境1.使用ssh工具登录服务器

 

2.输入 cd /etc/sysconfig/network-scripts/ 进入

再输入ls查看网卡名 确认当前外网网卡配置文件(本站vps外网网卡文件名一般为ifcfg-eth0)

3.编辑当前网卡文件 linux编辑命令为vi ifcfg-eth0

光标移动至dns1处 敲一下i 进入编辑模式

修改完dns后 按下ESC 输入:wq 保存并退出

4.重启网络即可。(centos6重启命令为service network restart,centos7重启命令为systemctl restart network)

 


标签: linux更换dns教程 教程 linux