The terminal input ifconfig
shows that the virtual machine IP address is 127.0.0.1
, and the specific output content is as follows:
wxy@ubuntu:~$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1142 bytes 80042 (80.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1142 bytes 80042 (80.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I've encountered this situation many times, and it only took one line of command to solve the problem:
$ sudo /sbin/dhclient
sudo /sbin/dhclient
is a command to start DHCP client in Linux system. DHCP stands for "Dynamic Host Configuration Protocol" and is a network protocol used to automatically assign IP addresses, subnet masks, default gateways and other network configuration parameters to computers.
When you connect to a network, you usually need an IP address to be able to communicate with other devices. Manually configuring the IP address of each device can be very tedious, especially in large networks. This is what DHCP does. A DHCP server assigns IP addresses and provides other network configuration information to make the process of connecting devices more automated and simplified.
When using sudo /sbin/dhclient
the command, the DHCP client sends a request to the DHCP server in the network to obtain available IP addresses and other configuration information. The client waits for a response from the server, and once it receives the response, it configures the device's network settings, including IP address, subnet mask, default gateway, DNS server, etc.
After I re-entered ifconfig
the command, I found that the IP address returned to normal:
The wired connection is also back to normal: