Linux static IP, dynamic IP configuration __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.
# 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.

# 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.

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

Onboot=yes
Bootproto=dhcp
Summarize:

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.

# 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.

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

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.