• Linux
  • FreeBSD
  • Networking
  • Python
  • AWS
  • WebDev
  • About Us
Tech Tips and Tutorials
Menu
  • Linux
  • FreeBSD
  • Networking
  • Python
  • AWS
  • WebDev
  • About Us
Home  /  Linux  /  How to add a static IP in Ubuntu 20.04 server

How to add a static IP in Ubuntu 20.04 server

Written by
Linux Leave a Comment

By default , most OS comes with the DHCP client enabled and it will then get an IP from the DCHP server pool . But in some cases, you may need to add a static IP instead of receiving a dynamc IP via DHCP .

So ubuntu on latest versions uses a utility called netplan for this :

First you need to find your ethernet interface name

ifconfig

The file we need is:

/etc/netplan/00-installer-config.yaml

As this is an important file , its better to take a backup and incase something goes wrong we can restore it back :

cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.bak

Then you can modify the file using the nano editor:

nano /etc/netplan/00-installer-config.yaml

You will see DHCP True in this file ,that should be changed to ‘no’ , so edit it as below : Make sure you provide your own ethernet interface name which you found using ifconfig . Then your private/public static IP, subnet mask, gateway etc .The namersever we just used are external name servers but you can use your own if you want .

network:
  ethernets:
    ens5:
      dhcp4: no
      addresses:
        - 10.10.0.10/24
      gateway4: 10.10.0.1
      nameservers:
          addresses: [8.8.8.8, 1.1.1.1]
version:2

Then apply the configuration :

 netplan apply

Share On
Share on Facebook
Share on Twitter
Share on Google+
Share on Whatsapp

 Previous Article How to create a custom apt-repository in Ubuntu
Next Article   How to see the download speed using fetch command in FreeBSD

Related Posts

  • Linux Shell Scripts for System Administrators

  • SOCKS PROXY

  • How to grep IP addresses from log files in Linux

Leave a Reply

Cancel reply

  • Popular Posts
  • Recent Posts
  • Linux Shell Scripts for System Administrators
  • Cacti 1.1.38 ERROR Opening .rrd No Such file or directory
  • Apache configuration for Cacti
  • How to create RAM disk in Ubuntu 18.04
  • Linux Shell Scripts for System Administrators
  • SOCKS PROXY
  • How to install XAMPP and access phpMyAdmin in MAC OS
  • How to increase the root volume in a Linux ec2 instance

Linux

  • Linux Shell Scripts for System Administrators
  • SOCKS PROXY
  • How to grep IP addresses from log files in Linux
  • How to empty or delete a large file in Linux

Categories

  • AWS (5)
  • FreeBSD (12)
  • Linux (29)
  • Networking (3)
  • Python (5)
  • Uncategorized (4)
  • WebDev (1)
  • Connect on Facebook
  • Connect on YouTube
© Copyright 2020.TechieNix. All Rights Reserved.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPT
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these cookies, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may have an effect on your browsing experience.
Necessary
Always Enabled

Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.

Non-necessary

Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.