Get the App
SLTechnology News&Howtos  ›  Servers  › 

Ubuntu18.04 sets static IP and DNS

Shulou Source: shulou.com Published: 2022-06-03 02:59:32 09月22日 Update

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

Tags: File directory have do not use representative address situation network card management configuration static Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Tech Info OPPO Reno Shulou Information Huawei