How to Disable DNS Server from DHCP in Linux Network Configuration
To ignore the DNS server obtained from DHCP in the ifcfg config file, you need to modify the configuration file as follows:
-
Open the configuration file for the specific network interface. The file is typically located in the '/etc/sysconfig/network-scripts/' directory and has a name like 'ifcfg-ethX' or 'ifcfg-enX', where 'X' is the interface number.
-
Edit the file using a text editor such as vi or nano.
-
Look for the line that starts with 'DNS1=' or 'DNS2='. These lines specify the DNS servers obtained from the DHCP server.
-
Comment out or remove the line(s) by adding a '#' at the beginning of the line(s). This will prevent the system from using the DNS server obtained from DHCP.
-
Save the file and exit the text editor.
-
Restart the network service for the changes to take effect. You can do this by running the following command:
systemctl restart network
By following these steps, you have effectively ignored the DNS server obtained from DHCP in the ifcfg config file.
AI 优化版
原文地址:https://www.cveoy.top/t/topic/qA2C 著作权归作者所有。请勿转载和采集!