CentOS6.8 How to configure IP under the non-graphical interface?

Source: Internet
Author: User

CentOS6.8 How to configure IP under the non-graphical interface?

Action Tip:

When the input is directed to the virtual machine, click inside the virtual machine or press ctrl+g;

When the input is directed to the physical host, press Ctrl+alt.

1 Installing CentOS6.8 System

2 View IP configuration information

Enter the command line: ifconfig to get the IP configuration information that is already in the system as shown in Figure 1.

Figure 1 System existing IP configuration information

As you can see from Figure 1, the IP configuration information does not show basic information about the NIC device eth0.

3 See if the system has a network card device eth0

Enter command: ls/ect/sysconfig/network-scripts to get the filename information contained in the directory as shown in Figure 2.

Figure 2/ect/sysconfig/network-scripts The filename information in the directory

4 Activate the NIC Eth0

Enter command: ifconfig-a, view NIC status information. As shown in Figure 3, the NIC device eth0 is not active in this system.

Figure 3 NIC status information

Input command: ifconfig eth0 up, activate network card device eth0, and then enter ifconfig again to view the basic information eth0, but the network card is not currently configured with the appropriate IP address. As shown in Figure 4:

Figure 4 Activating the network card device

Similarly, we want to let a network card device no longer work, also can by the command "ifconfig network card name down" to lock it.

5 Configure IP for eth0

When configuring an IP address, you need to select the appropriate IP based on the system's network connection. You can set up the network connection of the virtual machine in the interface shown in Figure 5.

Figure 5 Setting up the virtual Machine network connection method

If your network connection is set up in bridging mode, you need to set up an actual IP address on the same network segment as your own physical host. The IP address will occupy the actual network bandwidth resources and access the Internet.

If the network connection is set to NAT mode, see the VMNET8 network IP address in the physical host network device, as shown in Figure 6, and then set up a virtual IP address that is on the same network segment as this IP address. This IP address does not occupy the actual network bandwidth resources, and if the physical host can access the Internet, then the virtual machine can also access the Internet.

In addition, there is a mode of network connectivity here is "host-only Mode", which corresponds to the physical host of the VMnet1, is similar to "NAT mode", the difference is that the IP address set by this mode can only maintain communication with the host, can not access the Internet.

Figure 6 VMnet8 Network Connection details

5.1 Configuring temporary IP addresses

The command format for temporarily configuring IP addresses is "ifconfig network card name IP address netmask subnet mask" and takes effect immediately.

For example: ifconfig eth0 192.168.12.2 netmask 255.255.255.0, configuration results are shown in Figure 7:

Figure 7 Temporary IP address

5.2 Configuring Permanent IP addresses

Configuring a permanent IP address requires modifying the NIC configuration file.

Enter the command "Vi/etc/sysconfig/network-scripts/ifcfg-eth0" to enter the NIC configuration file as shown in Figure 8. Press the Insert key to enter the edit state.

Figure 8 NIC configuration file

As shown in Figure 8, the value of modifying onboot is yes; modify Bootproto to none; Add basic information such as IP address ipaddr and subnet mask netmask.

Attention:

(1) Device represents the NIC device name. The value must be set to the same name as the NIC after "ifcfg-" in the filename entered above, otherwise the modification operation will not take effect;

(2) Onboot Indicates whether eth0 is in effect with network service startup. CentOS series of Linux system after installation onboot default is no, modify the NIC configuration file must be modified to Yes, or modify the operation can not take effect.

(3) Bootproto represents the way IP address is obtained (none, static, DHCP). Both static and none represent manual assignment, and DHCP represents the automatic acquisition of IP, but only if the presence of a DHCP server within that LAN is available.

Press ESC to exit the edit state and enter ": Wq" to save and exit. As shown in Figure 9:

Figure 9 Saving network adapter profile modifications

You need to restart the network service after you save the changes is in effect, enter the command "service network restart" To restart the network service, as shown in Figure 10:

Figure 10 Restart Network Services

After reboot, you can enter the command "Ifconfig" to verify that the modification is effective. As shown in Figure 10:

Figure 11 Verifying that the permanent IP configuration is in effect b

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.