Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure virtual machine network in Centos7.4

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to configure the virtual machine network in Centos7.4. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

I. static network configuration

1. Open the virtual machine and enter the account number and password to log in. Then enter cd / etc/sysconfig/network-scripts/, to enter the interface of the network configuration, and view the network configuration file by commanding ls. This is shown in the following figure.

It is found that the configuration file is a little different from the Centos6.7 version, in the Centos6.7 version, the network configuration file is in ifcfg-eth0, but in the Centos7.4 version, the network configuration file is in ifcfg-ens160.

2. Enter the network configuration file through the vi ifcfg-ens160 or vim ifcfg-ens160 command. The following figure shows the original network configuration file, which has more content than the Centos6.7 version.

3. But there are only two things we need to change, and we need to add IP addresses, gateways, masks, and DNS1, as well as backup DNS2. The specific configuration is shown in the following figure.

Set ONBOOT to yes, BOOTPROTO to static (static), and then add the IP address, gateway, mask, and DNS1, as well as a backup DNS2.

Press Esc after the modification, and then type: WQ _ quit to save the exit.

If you are not sure whether the modification has been successful, you can check it through cat / etc/sysconfig/network-scripts/ ifcfg-ens160.

Restart the network and enter service network restart on the command line. After successfully rebooting the Nic, the green ok appears on the right, as shown in the following figure. If a red Failed appears, there is a problem with the network configuration, and a common error is that IP is not available or that ONBOOT and BOOTPROTO have not changed.

After that, the network ping communication test is carried out through ping http://www.baidu.com. If IP is available, the server will respond, as shown in the following figure. If you want to terminate the operation, use Ctrl+C to force the exit.

At this point, the virtual machine connects to the Internet successfully.

5. You can view the IP address through the ip addr command, as shown in the following figure. At first, the editor wanted to use ipconfig to check the IP address, but the system prompted command not found (command not found), which is also different from the Centos6.7 version.

The steps are as follows:

1) enter on the command line:

Vi / etc/sysconfig/network-scripts/ifcfg-ens160

2) later, you can modify the ONBOOT=yes. By default, there is no need to add any IP, gateway, etc. Save and exit after the modification is completed.

3) then type service network restart to restart the network card.

4) finally, enter ip addr to view the IP address.

On how to configure the virtual machine network in Centos7.4 to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report