Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Networking»Configuring the Static IPv4 Address on Ubuntu using Netplan

    Configuring the Static IPv4 Address on Ubuntu using Netplan

    By RahulAugust 24, 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.

    Advertisement

    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 it in your favorite 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

    Related Posts

    How to Find IP Address in Ubuntu 22.04 (GUI + CLI)

    How to Check IPv4 Address on Ubuntu 22.04

    How to Configure Static IP Address on Ubuntu 22.04

    How to Configure Static IP Address on Ubuntu 22.04

    Linux ip command with useful examples

    ip Command in Linux (Manage Networking)

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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