#!/bin/bash

This script sets the DNS server to 8.8.8.8 and 8.8.4.4 permanently on Ubuntu

Backup the original resolv.conf file

sudo cp /etc/resolv.conf /etc/resolv.conf.original

Create a new resolv.conf file

sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf sudo echo "nameserver 8.8.4.4" >> /etc/resolv.conf

Set the file permissions

sudo chmod 644 /etc/resolv.conf

Prevent the file from being overwritten

sudo chattr +i /etc/resolv.conf

echo "DNS server has been set to 8.8.8.8 and 8.8.4.4 permanently.

在ubuntu使用shell脚本永久更改系统dns的代码

原文地址: http://www.cveoy.top/t/topic/fmgj 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录