virtualbox+Ubuntu20.04/centos7 fixed IP static IP network settings graphical

Virtual machine fixed IP

Roughly divided into VMware and virtual box two factions

The system I mainly use is divided into ubuntu and centos

Recently virtual box is used more

So start with the virtual box, hoping to get 1. Fixed ip does not need to be changed every time you restart 2. At least you can link to the external network

In fact, you can use manual IPV4, and the graphical setting is very convenient.

1、virtual box + ubuntu

Not to mention the installation, just watch another tutorial and start recording after the installation

1.1 Create a root password

sudo passwd
[sudo] 你的用户名 的密码:          #输入你的用户名账号的密码
新的 密码:                        #定义root密码
重新输入新的 密码:                 #确认root密码
password: 已成功更新密码           #成功提示
su                               #su验证登录

1.2 install ssh

Install vim first

apt install vim

For ubuntu, you need to open the port and install openssh-server to connect to the host xshell

sudo ufw status  #检查防火墙状态
sudo ufw disable #关闭防火墙
sudo ufw allow 22 #开放22端口

sudo apt-get update 
sudo apt-get install openssh-server #安装openssh-server`

The above is the setting of virtual box+ubuntu20.04 after installation, and the following introduces the solid IP

Install a dependency first

apt install net-tools	

Manually modify ipv4 in the graphical interface

image-20211026110223827

2、virtual box + centos

Directly manually modify ipv4 in the graphical interface

But note that the network segment should be consistent with the host\physical machine

WeChat screenshot_20211026105951

3 other

Another method is port forwarding, but the limitation is that it can only be connected by ssh, not remotely by vscode. The method is recorded as follows

image-20211026111025384

When connecting using ssh

ssh 用户名@127.0.0.1 23
例如:
ssh [email protected] 23

Then enter the password in the pop-up interface

4 postscript

After writing here, the response is that VMware should be able to use the same method to set a fixed IP, so there will be no more pitfalls. In fact, static IP and fixed IP can be used, but if the network environment changes, you must remember to reset it

Guess you like

Origin blog.csdn.net/muziyang555/article/details/120968682