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:
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.