Step 1: Determine the network settings of the virtual machine
Before changing the IP address, you first need to check the network settings of the virtual machine. Generally speaking, a virtual machine can connect to the network through the following network modes:
Bridge mode: The virtual machine is directly connected to the physical network and is in the same network segment as the host.
Network Address Translation (NAT) mode: The virtual machine accesses the external network through the host, and the host acts as a router.
Host-only mode: The virtual machine can communicate with the host, but cannot access the external network.
Choose the appropriate network mode according to your needs, which will affect how the IP address is configured.
Step 2: Change the IP address of the virtual machine
Here are the specific steps to change the IP address in virtual machines for different operating systems:
Windows virtual machine
1. Start the Windows virtual machine.
2. Right-click the network icon in the lower right corner of the screen and select "Open Network and Internet Settings".
3. Click "Change adapter options".
4. Find the corresponding network adapter (such as "Ethernet" or "Wi-Fi"), right-click and select "Properties".
5. In the properties window, find "Internet Protocol Version 4 (TCP/IPv4)" and double-click it.
6. Select "Use the following IP address" and enter the new IP address, subnet mask, and default gateway. Make sure the IP address you enter is in the same network segment.
7. Click "OK" to save the settings and close all windows.
Linux virtual machine
1. Start the Linux virtual machine.
2. Open the terminal and use the following command to view the current network configuration:
ifconfig
1. Find the corresponding network interface (such as eth0, ens33, etc.).
2. Use the following command to change the IP address (as root user or using sudo):
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
To set the default gateway, you can use the following command:
sudo route add default gw 192.168.1.1
To permanently change the IP address, you can edit the network configuration file. The specific path varies depending on the Linux distribution. For example, in Ubuntu, edit the `/etc/netplan/01-netcfg.yaml` file.
Step 3: Verify the IP address change
After changing the IP address, use the following method to verify whether it is successful:
In Windows, you can enter the command in the command prompt:
ipconfig
to view the current IP address.
In Linux, you can use the command:
ifconfig
or
ip addr
to view the current IP address.
Notes
When changing the IP address of a virtual machine, you need to pay attention to the following points:
Make sure the new IP address is in the same network segment to avoid IP address conflicts.
If using NAT mode, you may need to configure port forwarding on the host to allow external access to the virtual machine.
In bridge mode, make sure that the DHCP server of the physical network can assign the new IP address.
In Linux, some distributions may use NetworkManager to manage the network, which can be configured through the `nmcli` command.
Related Recommendations
- How to set a computer to access the Internet with static IP? Here are the detailed steps
- Apple mobile phone set up static IP tutorial, what is the role of long-term IP agents?
- What are the functions of the http proxy IP tool? How to set the proxy IP address for mobile phone software?
- How to set up a computer to access the Internet with dynamic IP? What is the use of dynamic proxy IP?
- Solve the IP restriction problem and no longer worry about "blocking access"!
- Browser High-Speed Proxy IP: Detailed Selection and Usage Guide
- Build an IP proxy server with multiple IP servers: Provide stable and flexible proxy services
- How to set up an HTTP proxy server on iPhone or iPad
- How to set up the Firefox proxy server? Just these few steps are easy to get done
- http global proxy: how to set up a stable connection