Configure the IP address in the non-graphic interface under CentOS6.8

Source: Internet
Author: User

Configure the IP address in the non-graphic interface under CentOS6.8

Operation prompt:

When the input is directed to the virtual machine, click inside the virtual machine or press Ctrl + G;

When you direct the input to the physical host, press Ctrl + Alt.

1. Install CentOS6.8

2. View IP configuration information

Enter the command line: ifconfig to obtain the existing IP Address Configuration Information of the system shown in 1.

Figure 1 existing IP Address Configuration Information of the system

As shown in figure 1, the basic information of eth0 on the NIC is not displayed in the IP configuration information.

3. Check whether the network card device eth0 exists in the system.

Enter the command ls/ect/sysconfig/network-scripts to get the file name information contained in the directory 2.

Figure 2 file name information under the/ect/sysconfig/network-scripts directory

4. Activate the network adapter eth0

Enter the command ifconfig-a to view the NIC status. 3. eth0 is not activated.

Figure 3 Nic status information

Run the command ifconfig eth0 up to activate eth0 on the NIC device. Enter ifconfig again to view the basic information of eth0, but no IP address is configured for the NIC. 4:

Figure 4 activating a NIC Device

Similarly, if you want to stop a NIC device from working, you can also run the "ifconfig Nic name down" command to lock it.

5. Configure an IP address for eth0

When configuring an IP address, you must select an appropriate IP address based on the network connection method of the system. You can set the network connection mode of the virtual machine on the page 5.

Figure 5 set Virtual Machine Network Connection Mode

If the network connection mode is set to "Bridge Mode", you need to set an actual IP address in the same network segment as your physical host. This IP address occupies the actual network bandwidth resources and can access the Internet.

If the network connection mode is set to "NAT mode", as shown in figure 6, view the network IP address of VMnet8 in the network device of the physical host, and then set a virtual IP address in the same network segment as this IP address. This IP address does not occupy actual network bandwidth resources. If the physical host can access the Internet, the virtual machine can also access the internet.

In addition, the network connection mode here also has a "host only" mode, which corresponds to the physical host's VMnet1, which is similar to the "NAT mode, the difference is that the IP address set in this mode can only communicate with the host and cannot access the Internet.

Figure 6 VMnet8 network connection details

5.1 configure a temporary IP Address

The command format for temporary IP Address Configuration is "ifconfig Nic name IP address netmask Subnet Mask" and takes effect immediately.

For example, ifconfig eth0 192.168.12.2netmask 255.255.255.0. The configuration result is 7:

Figure 7 temporary IP Address

5.2 configure a permanent IP Address

To configure a permanent IP address, you must modify the NIC configuration file.

Enter the command vi/etc/sysconfig/network-scripts/ifcfg-eth0 to enter the NIC configuration file shown in 8. Press the "Insert" key to enter the editing status.

Figure 8 Nic configuration file

As shown in figure 8, change the ONBOOT value to yes, change BOOTPROTO to none, and add basic information such as IP address IPADDR and subnet mask NETMASK.

Note:

(1) DEVICE indicates the name of the nic device. The value must be set to the same name as the NIC name after "ifcfg-" in the input file name; otherwise, the modification will not take effect;

(2) ONBOOT indicates whether eth0 takes effect as the network service starts. After CentOS Linux is installed, the ONBOOT value is no by default. When modifying the NIC configuration file, you must change it to yes. Otherwise, the modification cannot take effect.

(3) BOOTPROTO indicates the IP address acquisition method (none, static, dhcp ). Both static and none indicate manual allocation; dhcp indicates that the IP address is automatically obtained, but only if the dhcp server exists in the LAN.

Press Esc to exit the editing status, and enter ": wq" to save and exit. 9:

Figure 9 save Nic Configuration File Modification

After saving the changes, you need to restart the network service to make the changes take effect. Enter the "service network restart" command to restart the network service, as shown in Figure 10:

Figure 10 restart a network service

After the restart, run the "ifconfig" command again to verify whether the modification takes effect. 10:

Figure 11 verify whether the permanent IP configuration takes effect B

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.