The Linux virtual machine Ubuntu 22.04 version cannot be connected through remote connection. If you enter ifconfig, you can only see the solution 127.0.0.1.

After configuring a static IP for the virtual machine before, you can directly connect remotely through the host Vscode. However, after setting the TCP/IPV4 static IP of the host some time ago, the virtual machine could not be connected again, so I referred to to solve the problem that the virtual machine cannot access the Internet ifconfig only shows 127.0.0.1. Problem, I can connect again, but I can’t connect after restarting the virtual machine, so I want to make it permanent by configuring bashrc, but the following problem occurs:
Insert image description here

Solution

Enter root privileges

sudo -i

Configuration

  • Enter in the terminal
    vim ~/.bashrc
  • Add in the last line
    dhclient -v
  • Save and exit
  • Enter in the terminal
    source ~/.bashrc

Note that the above operations need to be performed under root permissions, otherwise the above permissions problems will occur.

View ifconfig

It is found that in addition to 127.0.0.1, there are also IP addresses, indicating that the configuration is successful.

Guess you like

Origin blog.csdn.net/qaaaaaaz/article/details/132378566