Enable and disable Nic commands in Centos

Source: Internet
Author: User
Ifup and ifdown: linux commands can manually modify some network interface parameters in real time, which can be implemented using ifconfig. if you want to directly use the configuration file, that is, if you start the ifcfg-ethx and other file setting parameters in/etc/sysconfig/network-scripts, you need to implement ifdown or ifup. [Root @ linux ~] # & N

Ifup and ifdown:Linux Commands

You can use ifconfig to manually modify network interface parameters in real time, that is, if you start the ifcfg-ethx and other file setting parameters in/etc/sysconfig/network-scripts, you need to implement ifdown or ifup.

[Root @ linux ~] # Ifup {interface}
[Root @ linux ~] # Ifdown {interface}
[Root @ linux ~] # Ifup eth0

Ifup and ifdown are too simple. These two programs are actually scripts. they will directly search for the corresponding configuration files in the/etc/sysconfig/network-scripts directory, such as ifup eth0, it will find the contents of the ifcfg-eth0 file and then set it. For more information about how to set up a ifcfg-eth0, see the instructions for connecting to the Internet in the previous chapter.

However, because these two programs mainly start and close the settings file ifcfg-ethx, therefore, before use, make sure that ifcfg-ethx exists in the correct directory. Otherwise, the startup will fail. In addition,If you use ifconfig eth0 to set or modify the network interface, you cannot disable it in ifdown eth0 mode. Because ifdown will analyze and compare the current network parameters and ifcfg-eth0 is consistent, if not, will give up this operation. Therefore, you must use ifconfig eth0 to disable the ifconfig eth0 operation after the ifconfig modification is complete.

 

When linux starts, the NIC must be activated to access the Internet.
I searched for information online and finally solved the problem as follows:
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0: 1 view the configuration file of eth0: 1.
It is said that ONBOOT = yes can enable automatic activation upon startup, but it still does not work in the configuration file, and manual activation is always required for boot.
Add the following content to the/etc/rc. d/rc. local file:

Ifup eth0

Or

Ifconfig eth0 up
Eth0 is the network card to be activated. in my system, eth0: 1 is used, so ifup eth0: 1 is used.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.