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<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.

See also  Easy Uninstall amavisd-new On Ubuntu

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.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

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

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