Note: Ubuntu 20.04 sets static IP through netplan
step:
1. Check the name of the network card ( this machine uses ens33 )
Command: ip a
2. Generally speaking, if a file is modified, a copy of the file will be saved first
sudo cp /etc/netplan/01-network-manager-all.yaml 01-network-manager-all.yaml.bak
3. Edit 01-network-manager-all.yaml (you can also use vi vim to modify)
sudo nano /etc/netplan/01-network-manager-all.yaml
4. Enter the following information
network:
version: 2
renderer: NetworkManager
ethernets:
ens33:
dhcp4: no
addresses:
- 192.168.72.140/24
gateway4: 192.168.72.2
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Note: Be sure to pay attention to the indentation, otherwise the configuration will not succeed
Note: The gateway4 gateway is set to the gateway of the network cable
5. Enable configuration
sudo netplan apply
6. Finish, check it through ip a by yourself
Reference link:
https://linuxhint.com/ubuntu_20-04_network_configuration/