how to disable default route in ifcfg config file
To disable the default route in the ifcfg config file, you can follow these steps:
-
Open the ifcfg configuration file for the specific interface. The file is usually located in the "/etc/sysconfig/network-scripts/" directory and has a name like "ifcfg-<interface_name>". For example, if it is the eth0 interface, the file name would be "ifcfg-eth0".
-
Edit the file using a text editor such as vi or nano. For example, run the command:
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 -
Look for the line that starts with "DEFROUTE" and set its value to "no". If the line does not exist, add it at the end of the file. For example:
DEFROUTE=no -
Save the changes and exit the text editor.
-
Restart the network service to apply the changes. Use the appropriate command for your Linux distribution. For example, on CentOS/RHEL 7, use:
sudo systemctl restart network
After following these steps, the default route for the specified interface should be disabled
原文地址: http://www.cveoy.top/t/topic/iU3u 著作权归作者所有。请勿转载和采集!