How to set Ubuntu22.04 as static ip

Table of contents

1. Virtual machine settings

2. Edit -> Virtual Network Editor

3. Modify VMware's IP and DNS to static

Control PanelEdit

Network and Internet

Network and Sharing Center

 Change adapter settings

VMware Network Adapter VMnet8 right click properties

Select TPC/IPv4, click the property button below

 Set as shown above

4. Configure Ubuntu's yaml

 The above part of address can add 1 to the ip address of Windows configuration, and the via is the same

The following addresses are filled in according to the subnet ip and mask filled in on Windows

Press esc to exit edit mode, enter ":wq!" to save and exit

After launching, enter sudo netplan apply to update the configuration

After entering ifconfig, check whether the ip has been successfully changed


1.  Virtual machine settings

Network adapter selects NAT mode

 

 

2. Edit -> Virtual Network Editor

  • Select VMnet8
  • Click to change settings (administrator authorization)
  • Select NAT mode, click NAT settings, and view the gateway IP
  • The subnet IP can be different from what I set, mainly to make your virtual machine and your Windows system in the same LAN, but the mask of your Windows must be the same as mine

 

3. Modify VMware's IP and DNS to static

control Panel

 

Network and Internet

Network and Sharing Center

 Change adapter settings

VMware Network Adapter VMnet8 right click properties

Select TPC/IPv4, click the property button below

 Set as shown above

Configure the ip address, subnet mask, and default gateway (the last three digits of the ip address can be set at will, but they cannot be consistent with your Ubuntu’s ip, and the default gateway is also, which can be added or subtracted appropriately)

4. Configure Ubuntu's yaml

  • open terminal
  • Enter sudo vi /etc/netplan/01-network-manager-all.yaml
  • Delete the original configuration
  • Write the following configuration

 The above part of address can add 1 to the ip address of Windows configuration, and the via is the same

The following addresses are filled in according to the subnet ip and mask filled in on Windows

Press esc to exit edit mode, enter ":wq!" to save and exit

After launching, enter sudo netplan apply to update the configuration

After entering ifconfig, check whether the ip has been successfully changed

 

Guess you like

Origin blog.csdn.net/weixin_51395932/article/details/131997807