Configuring a static IP for the Linux system in the virtual machine (detailed steps)


Preface

  Configuring a fixed IP address in a virtual machine is one of the key tasks to ensure that the system identity is unique and stable in a simulated network environment. By setting a fixed IP address, we can easily communicate with the virtual machine and also facilitate other devices to communicate with it.

  This blog will introduce why you need to configure a static IP and the specific steps to configure a Linux system static IP on a virtual machine.


1. Why configure static IP

1. Stability and reliability

  A static IP address is fixed and does not change over time or network connections. This means other devices can always accurately find and access your console. It is very important to use static IP for services and applications that require continuous availability and stability, such as servers, network devices, or printers.

2. Specific application requirements

  Some applications or services may require a fixed IP address to function properly. For example, remote access, VPN connections, port forwarding and other functions may require the device to have a static IP address so that remote devices or users can accurately find and access your device.

3. Convenient management and monitoring

  Using a static IP address makes it easier to manage and monitor your device. By knowing the device's fixed IP address, administrators can remotely manage the device for troubleshooting, configuration changes, and monitoring. In addition, static IP addresses make it easier to identify and track network activity, helping with security auditing and network management.

4. Increase network security

  Static IP can enhance network security. With a device's fixed IP address, network administrators can more easily enforce security policies such as access control lists (ACLs) and firewall rules. Static IP addresses can also reduce the risk of some cyber attacks (such as IP spoofing) because it is difficult for attackers to predict, forge or impersonate a fixed IP address.

2. Configuration steps

1. Configure the gateway and network segment of the IP address in VMware

Open [Virtual Machine] > Click [Edit] > Click [Virtual Network Editor]
Insert image description here
to select [VMnet8] > Click [Change Settings]
Insert image description here
to change [Subnet IP] > Change [Subnet Mask] > Click [NAT Settings]

The 88 in the subnet IP can be modified according to your needs.
The subnet mask must be 255.255.255.0

Insert image description here
Change [Gateway IP] > Click [OK]

The 88 in the gateway IP corresponds to the one you set earlier.

Insert image description here

2. Modify the configuration file in the Linux system

Open [Terminal] > Enter [su - root] and enter the password > Enter [vim /etc/sysconfig/network-scripts/ifcfg-ens33]. Running results: Press [i] to enter
Insert image description here
input
Insert image description here
mode. After making the following changes, press [ESC 】Exit modification, press【:】>enter【wq】and press Enter

dhcp: Indicates automatically obtaining IP
static: Static IP
IPADDR: IP address, must be between 192.168.xx.0 ~ 192.168.xx.254 set previously
NETMASK: Subnet mask, must be 255.255.255.0
GATEWAT: Gateway , keep consistent with the one just set
DNS1: domain name resolution server, just keep it consistent with the gateway

Insert image description here

3. Restart the network card service

Execute the command [systemctl stop network] > [systemctl start network] > [ifconfig].
The results are:

The new IP is displayed after inet, that is, the configuration is successful.

Insert image description here


Summarize

  Follow the above steps to quickly configure a fixed IP address on the Linux system in the virtual machine. This will ensure that your system has a stable identity on the network and makes it easier for other devices to communicate with it. If you encounter any difficulties or problems, you can refer to the relevant Linux distribution documentation or ask the community for help.

  Hope this blog is helpful to you! If you have other questions about Linux or network configuration, please feel free to comment.

Guess you like

Origin blog.csdn.net/qq_43341612/article/details/132155501