**Description: **
Today, when I continued the last office collaboration platform experiment, I found that the virtual machine obtained the IP address through DHCP before, and this time the address obtained by DHCP changed after the virtual machine was turned on, because the website has been configured with a fixed IP address for access , The webpage cannot be accessed, so you need to modify the ip address to the ip address obtained last time. After checking how to modify the ip address in ubuntu, I found that "ubuntu has given up on fixing the IP in /etc/network/interfaces since 17.10 The configuration will not take effect even if the configuration is configured. Instead, it will be changed to netplan. The configuration is written in /etc/netplan/01-netcfg.yaml or a yaml file with a similar name."
Not much to say, just talk about how netplan changes the ip address
0 x00
Use the ifconfig command to view the network card
ifconfig
0 x01 modify yaml configuration file
sudo vi /etc/netplan/00-installer-config.yaml
network:
ethernets:
ens33: #The name of the configured network card
addresses:[192.168.31.215/24] #Configured static IP address and mask
dhcp4: no #Turn off DHCP, write yes if you need to turn on DHCP
optional:true
gateway4:192.168.31.1 #Gateway address
nameservers:
addresses:[192.168.31.1,114.114.114.114] #DNS server address, multiple DNS server addresses need to be separated by English commas
version:2
renderer: networkd #Specify systemd for backend-networkd or Network Manager, if you don’t fill in, systemd will be used by default-workd
Save the file after configuring it according to your needs
0 x02 makes the configured ip address effective
sudo netplan apply
Okay, use the ifconfig command to check whether the configured new ip address has taken effect.
**0 x03 Note: **
1、 The ip address and DNS server address need to be enclosed in [], but the gateway address is not required
2、 Note that a space must be added after each colon
3、 Pay attention to the indentation at the front of each level, at least two spaces more than the previous level
So far, this article on the example of how to modify the ip address of Ubuntu 20.04 is introduced. For more related Ubuntu 20.04 modification of the ip address, please search for the previous articles of ZaLou.Cn or continue to browse the related articles below. Hope you all Support ZaLou.Cn a lot!
Recommended Posts