Ubuntu18.04 sets static IP and DNS
Ubuntu18.04 uses netplan to manage network. So you can create a file that ends with yaml in the / etc/netplan/ directory. There is a default file in the / etc/netplan/ directory: 01-netcfg.yaml. We can create another file for the network card ourselves, or we can modify it directly.
Vi / etc/netplan/01-netcfg.yaml
By default, dhcp4: yes automatically gets IP on behalf of DHCP and changes it to
Dhcp4: no
Addresses: [192.168.1.9/24]
Gateway4: [192.168.1.1]
Nameservers:
Addresses: [192.168.1.10223.5.5.5]
Here the DNS and ipv4 addresses are configured in the same file, and there is no need to modify the / etc/resolv.conf file.
-* * after saving, execute * *
Sudo netplan applyip addr list