Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Networking»Configuring the Static IPv4 Address on Ubuntu using Netplan

    Configuring the Static IPv4 Address on Ubuntu using Netplan

    RahulBy RahulJune 1, 20223 Mins Read

    The Ubuntu 17.10 and later systems use the Netplan as a new command-line utility for managing network interfaces. It works with the Systemd-networkd or NetworkManager renderes. Netplan configuration files are written in YAML format, allowing you simple-to-complex networking configurations. Which work from the Desktop to the server and from the cloud to IoT devices.

    This article will help you to configure static IPv4 addresses on Ubuntu systems using the Netplan command-line tool.

    Check the Network Interface Name

    First of all, you need to identify the network interface name. It can differ based on the installation type and system environment.

    • To find the interface name type:
      sudo nmcli device status 
      
      Output:
      DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired connection 1 lo loopback unmanaged --
    • You can also check the interface name using the ip command:
      sudo ip a 
      

      Configure Static IPv4 Address using Netplan on Ubuntu
      Checking the network interface name

    The above output shows that the system is configured with the network interface name eth0. This can be different on your system. So please verify the system network interface name with the ip a command as shown above.

    Configuring the Static IP Address using Netplan

    Netplan stores all the configuration files under /etc/netplan directory. As you already have the network interface name found in the above commands. Now, we will configure the static IP address to that interface using the NetPlan utility.

    Let’s, create a configuration file and edit in your favoite text editor:

    sudo vi /etc/netplan/01-netcfg.yaml 
    

    Add the network configuration in YAML format. The below configuration uses 4 spaces due to strict indentation followed by the YAML.

    network:
        version: 2
        renderer: networkd
        ethernets:
            eth0:
                addresses:
                    - 192.168.0.210/24
                nameservers:
                    addresses: [8.8.8.8, 8.8.4.4]
                routes:
                    - to: default
                      via: 192.168.0.254
    

    In the above configuration:

    • eth0 – is the network interface name
    • 192.168.0.210/24 – is the IPv4 address to set on interface. Make sure to define CIDR. You can add multiple IP address as well.
    • routes via 192.168.0.254 – Set the gateway IP address of the network
    • 8.8.8.8, 8.8.4.4 – is the IP address of the Google DNS servers.

    Make sure the IPv4 address belongs to the system network and has the correct gateway Ip address.

    Once confirmed, press ESC and :wq to save file content and close it.

    Now, execute the following command to apply the changes:

    sudo netplan apply 
    

    This will configure the static IPv4 address on the network interface. Now the system will be accessible with the new IP address you configured above.

    Conclusion

    In this tutorial, you have learned to configure the network interface on Ubuntu systems.

    ip address Netplan networking
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleWhat are Soft Links and Hard Links in Linux?
    Next Article How to Delete a Let’s Encrypt Certificate using Certbot

    Related Posts

    How to Check IPv4 Address on Ubuntu 22.04

    2 Mins Read

    How to Configure Static IP Address on Ubuntu 22.04

    Updated:May 31, 20223 Mins Read

    Linux ip Command and Examples

    Updated:July 15, 20218 Mins Read

    How to Check IP Address on Ubuntu 20.04 (Desktop)

    Updated:April 30, 20202 Mins Read

    How to Check IP Address on CentOS 8

    Updated:October 8, 20192 Mins Read

    How to Configure Static IP Address on CentOS 8

    Updated:October 7, 20192 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    • How to Install Angular CLI on Ubuntu 22.04
    • How to Install Composer on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.