Configure static IP address netplan on Ubuntu 18.04
Configure static IP address using Netplan
Netplan network configuration had been first introduced to Ubuntu 18.04 LTS Bionic Beaver. It is available to all new Ubuntu 18.04 installations.Depending on your Ubuntu installation Netplan may not be avaiable on upgraded Ubuntu systems.
configure a static IP address for your network interface using
/etc/network/interfaces
Ubuntu 18.04 has used Netplan, netplan is a utility that can simplify network configuration, you only need to create a configuration file in yaml in the directory / etc / netplan, the netplan uses 2 renderers, namely NetworkManager and Networkd, we will use the networkd renderer because of networkmanager renderer usually used for desktop users.
To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant netplan network configuration file within
/etc/netplan/
directory. For example you might find there a default netplan configuration file called
01-netcfg.yaml
or 50-cloud-init.yaml
with a following content instructing the networkd
deamon to configure your network interface via DHCP:user $ sudo nano /etc/netplan/enp0s3.yaml
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: yes
To set your network interface
enp0s3
to static IP address 192.168.1.222
with gateway 192.168.1.1
and DNS server as 8.8.8.8
and 8.8.4.4
replace the above configuration with the one below.# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no addresses: [192.168.1.122/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8,8.8.4.4]
Once ready apply changes with:
$ sudo netplan applyIn case you run into some issues execute:
$ sudo netplan --debug apply
Komentar
Posting Komentar