Today, today i will do configuration static ip address on ubuntu server 18.04 or 20.04 uing netplan. Since Ubuntu 17.10 and later uses Netplan as the default network management tool. The previous Ubuntu versions were using ifconfig
and its configuration file /etc/network/interfaces
to configure the network.
About Netplan
Netplan is a utility for easily configuring networking on a linux system. We can simply create a YAML description of the required network interfaces and what each should be configured to do.
How does it work?
Netplan reads network configuration from /etc/netplan/*.yaml
which are written by administrators, installers, cloud image instantiations, or other OS deployments. During early boot, Netplan generates backend specific configuration files in /run
to hand off control of devices to a particular networking daemon.
The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To doing it, use “ip link
” or “ip add
” to determine interface.
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000<br> link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000<br> link/ether 00:0c:29:03:60:50 brd ff:ff:ff:ff:ff:ff
Setting Static IP Ubuntu
To assign a static IP address on the network interface, open the YAML configuration file with your favourite editor text.
~$ sudo vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: true
version: 2
The result above is default dhcp. Next i want to change to be static IP address. This is way.
# This is the network config written by 'subiquity'
network:
ethernets:
ens33:
dhcp4: no
addresses:
- 10.12.12.12/24
gateway4: 10.12.12.2
nameservers:
addresses: [10.12.12.10, 8.8.8.8]
version: 2
Save and netplan apply
.
$ sudo netplan apply
~$ ip ad
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:a4:a4:2c brd ff:ff:ff:ff:ff:ff
inet 10.12.12.12/24 brd 10.12.12.255 scope global ens33
That’s it and great! we have finished assigned a static IP to our Ubuntu server. Hope it’s helpful, please leave a comment and I’ll appreciate it.
Let's Buy Me Coffee. https://saweria.co/habibzain https://ko-fi.com/habibzain