Get the App
SLTechnology News&Howtos  ›  Servers  › 

Beginners to configure IP and restart the network for Linux in the virtual machine

Shulou Source: shulou.com Published: 2022-06-02 04:03:24 10月01日 Update

Friends who have just come into contact with the virtual machine, or have just installed linux in the virtual machine, need to configure the IP address themselves because the system is installed in the virtual machine.

Configure this IP address in several steps:

Step 1: open your virtual machine, open linux, and log in using your root account.

As shown in the picture, I am using the CentOS7.2 system. Click to log in, enter the interface of typing instructions, and enter vi / etc/sysconfig/network-scripts/ifcfg-eth0 (each computer behind the eth is different, you can press the tab key to complete it. )

Follow the above instructions to enter the interface for configuring IP, as shown in the figure

Since I have already configured it, I will have three more fields than you (IPADDR,GATEWAY,NETMASK).

Press the I key to enter insert mode

Set BOOTTPROTO to static

Set ONBOOT to yes

Join the IPADDR (static IP) instance 192.168.2.200 GATEWAY (gateway) 192.168.2.1 NETMASK (subnet mask) 255.255.255.0

When you are finished, press shift+ Q, type: wq, save and exit.

Then go back to your virtual machine interface, click Edit in the virtual machine, select the virtual network editor, add a network and select host-only mode. Then modify the subnet IP of the network you just added to 192.168.2.0 (in my example), the first three bits should be the same as your IP address.

As shown in the figure

Click OK after completing the above steps, and then right-click your virtual machine, select Settings, and modify your network adapter for the network you just created.

As shown in the figure

Enter service network restart to restart the network service after exiting

Then you can use Xshell or Xftp to connect to your server. If the connection is successful, it means that your IP address has been successfully configured and you can connect.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: Network address as shown in figure configuration interface input selection success instruction mode system security subnet service login three host content field instance Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Redmi macOS Shulou Information