Use netplan command in Ubuntu 18
First of all
cd /etc/netplan/
* .Yaml find the file (each person may be different), edit it
root@waydeserver:/etc/netplan# vi 50-cloud-init.yaml
Modify the content in the following format:
# This file is generated from information provided by # the datasource. Changes to it will not persist across an instance. # To disable cloud-init's network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: ens33: addresses: [192.168.3.35/24] dhcp4: no dhcp6: no gateway4: 192.168.3.1 nameservers: addresses: [192.168.3.1] version: 2
- ens33 on behalf of the card name
- addresses on behalf of you want IP, 24 on behalf of 24-bit subnet mask, that is 255.255.255.0
- gateway4 represents the default gateway address
- nameservers on behalf of DNS, of course, be replaced by Google's 8.8.8.8, or domestic 114.114.114.114, etc.
Is one to pay attention to the indentation and spacing is very important , wrong, then it will not be correctly identified.
After modifying saved, then execute:
netplan apply
At this point you are finished, you can use the ifconfig command.