Linux static IP, dynamic IP configuration

Source: Internet
Author: User
Tags get ip

Linux static IP, dynamic IP configuration

First step: Activate the NIC

After the system is installed, the default NIC is eth0, which activates the NIC with the following command.
# ifconfig eth0 up
Step two: Set the NIC to boot when it enters the system

If you want to get IP address automatically every time you turn on the Internet, you must set up the network service to start the system. Linux is a little different from Windows is that many services are stopped by default, and you use the service at some time to start the service, but did not set it as the default boot, the next time you enter the system this service is still stopped. Here's how to set up a network service that also starts when the system starts.

Use the Chkconfig command to have the Network service start by default when the system boot level is 2345.

# chkconfig--level 2345 Network on
Step three: Modify the NIC file Ifcfg-eth0

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

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

Onboot=yes
bootproto=DHCP

DHCP must be a lowercase letter
Summarize:

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

# Service Network Start

Configure static IP address Internet and dynamic IP address Internet expatiating, modify the Ifcfg-eth0, and then restart the Network Service with the Command service network Retart.

Device=eth0
ipaddr=192.168.1.100
netmask=255.255.255.0
gateway=192.168.1.1
dns=8.8.8.8
Bootproto=static
Onboot=yes

Linux static IP, dynamic IP configuration

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.