Linux CentOS IP set NIC settings

Source: Internet
Author: User
Tags get ip

1. Get IP address automatically


Virtual machines use bridging mode, which is equivalent to a network connected to a physical machine, and the physical machine network has a DHCP server that automatically assigns IP addresses.

#dhclient Auto Get IP address command

#ifconfig Query System network card information, IP address, MAC address

After assigning to an IP address, ping the IP address with the physical machine and detect if it is ping.

2. Manually set the IP address


If the virtual machine does not acquire IP automatically, it can only be configured manually, as follows:

Input command

#vi/etc/sysconfig/network-scripts/ifcfg-eth0 [Edit the configuration file for the NIC]

Enter the above command after entering, open the configuration file, use the arrow keys to move the cursor to the last line, press the letter key "O", enter the edit mode, input the following content:

ipaddr=192.168.4.10

netmask=255.255.255.0

gateway=192.168.4.1

In addition, the cursor moves to the line "Onboot=no" and changes to Onboot=yes

"Bootproto=dhcp", Change to Bootproto=none

When you're done, press the ESC key in the upper-left corner of the keyboard, enter: Wq in the lower left of the screen, enter to save the configuration file.


The network service needs to be restarted after the command is

#servicenetwork restart

After the network restarts, the IP of eth0 is in effect, use the command #ifconfigeth0 to view


This article is from the "I am the program my biggest" blog, please be sure to keep this source http://skinglzw.blog.51cto.com/10729606/1846740

Linux CentOS IP set NIC settings

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.