The method of automatically acquiring and statically configuring IP under Linux

Source: Internet
Author: User

First step: Activate the network card

System installed after the default network card is eth0, with the following command to activate this network card.

The code is as follows:

# ifconfig eth0 up

Step two: Set the network card to start when entering the system

If you want to automatically get the IP address to the Internet every time you turn on, you should set up the network service when the system starts. Linux is a bit different from Windows is a lot of services by default is stopped, and you use the service when you start the service, but did not set it as the default startup, the next time to enter the system this service is still stopped. The following is a way to set up network services to start when the system starts.

Use the Chkconfig command to enable network services to start by default when the system boot level is 2345.

The code is as follows:

# chkconfig--level 2345 Network on

Step three: Modify the NIC file Ifcfg-eth0

Modify the Ifcfg-eth0 file and set the value of Onboot to Yes so that the network service uses the NIC when it starts. Set the value of Bootproto to DHCP, allowing the network card to automatically obtain an IP address from the DHCP server.

The code is as follows:

# Vi/etc/sysconfig/network-scripts/ifcfg-eth0




Usually the third step is the most important, because most Linux system default network service is also started when the system is started, the NIC is enabled, as long as the third step, and then use the following command to start the Network service OK.

The code is as follows:

# Service Network Start

Configure static IP address Internet and dynamic IP address expatiating, modify Ifcfg-eth0, and then use command Service network retart Restart network services.

The code is as follows:








Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.