habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

How to Setting IP Static Ubuntu 18 or 20.04

1 min read

how to et-IP-Static-Ubuntu-18-or-20.04

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
    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
    link/ether 00:0c:29:03:60:50 brd ff:ff:ff:ff:ff:ff
1: lo:

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
    <strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color">inet 10.12.12.12/24 brd 10.12.12.255 scope global ens33</mark></strong>

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.

See also  Zimbra zclient.IO_ERROR (invoke Connection refused, server: localhost)

Let's Buy Me Coffee.

Buy Me a Coffee at ko-fi.com

https://saweria.co/habibzain
https://ko-fi.com/habibzain
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox