how to overwrite dns server setting from dhcp under linux
To overwrite DNS server settings from DHCP under Linux, you can use the following steps:
-
Open the terminal.
-
Edit the Network Manager configuration file using a text editor (e.g., nano or vi). The file is usually located at
/etc/NetworkManager/NetworkManager.conf.sudo nano /etc/NetworkManager/NetworkManager.conf -
Look for the
[main]section in the file and add the linedns=none. This line tells Network Manager not to use the DNS servers provided by DHCP.[main] dns=none -
Save the file and exit the text editor.
-
Restart the Network Manager service to apply the changes.
sudo systemctl restart NetworkManager -
Configure the DNS servers manually by editing the network interface configuration file. The file is usually located at
/etc/sysconfig/network-scripts/ifcfg-<interface_name>. Replace<interface_name>with the name of your network interface (e.g.,eth0).sudo nano /etc/sysconfig/network-scripts/ifcfg-<interface_name> -
Add the following lines to the file, replacing
<DNS_server_IP>with the IP address of your desired DNS server(s).DNS1=<DNS_server_IP> DNS2=<DNS_server_IP>You can add multiple DNS servers by specifying additional
DNS3,DNS4, and so on. -
Save the file and exit the text editor.
-
Restart the network service to apply the changes.
sudo systemctl restart network
After following these steps, your Linux system should now use the manually configured DNS servers and ignore the ones provided by DHCP
原文地址: http://www.cveoy.top/t/topic/iU4p 著作权归作者所有。请勿转载和采集!