Static IP Server Configure

netplan
network configuration YAML file.In this post, we will see how we can set a static IP address on our Linux server, specifically an Ubuntu Server (Version > 17.10).
Ubuntu now uses Netplan
as the default network management tool to replace the old configuration file /etc/network/interfaces
that we can still find in other Linux Distributions.
Network Interface
First we need to find the network interface name that we are connected, we can do that with ifconfig
:
We can also use the newer ip
command, if ifconfig
is not available:
We can see that the network interface is enp3s0
and the IP address is 192.168.1.99
.
Netplan file
Netplan uses configuration files in YAML format. To configure a static local IP address with netplan
we need to edit the following yaml
file:
The 01-netcfg.yaml
file defore we change it will be like:
And after the changes:
We explain the additional field we added:
enp3s0
: The network interface namedhcp4: no
: We don’t want DHCP to give us an IP addressaddresses
: The IP address that we want to be assigned and the subnetgateway4
: The local networks gatewaynameservers
: The IP addresses of the nameservers we want to have
Give the file the proper permissions:
Apply changes:
Verify the changes by typing: