Configure a static IP address, subnet mask, gateway, and DNS server in Ubuntu.

Configure a static IP address, subnet mask, gateway, and DNS server in Ubuntu.

Problem Statement:-

Configure a static IP address, subnet mask, gateway, and DNS server for a network interface using the command line. Verify that the network configuration persists after rebooting the system.


Solution:

First of all, I must remove all your confusion:

Earlier in Ubuntu, when we want to change the IP address we use /etc/network/interfaces        

This file is used by “ifupdown” tools from Debian. Now Ubuntu has switched from “ifupdown” to “Netplan”.

So now your network settings are handled from /etc/netplan/? in this folder you will get a ‘.yaml’ file.


Now talk about the solution:

  • Go to /etc/netplan here you get a YAML file, as you can see below -

Access your yaml file

  • In this file you see renderer, if it is set to ‘NetworkManager’, it means your Ubuntu system Network configuration is managed by GUI Network Manager.
  • But we want to do it on the command line. For this set rendered to networkd and define interface information like IP address, subnet mask, gateway, and DNS like the below screenshot.

Changes made to yaml file

  • Now save the file and run sudo netplan apply
  • Now your changes will persist across reboots.


Now if you made any mistake or want to get back the old stat of network configuration as it was.

Then do this:

  • Change renderer back to ‘NetworkManager’ and also erase the interface information that you gave.
  • Now your .yaml file should look like this-

Your yaml file

  • Save it and run “sudo netplan apply
  • Now restart the system and your network will work fine.

Now hope you understand the whole process and if you have any suggestions DM me.

Thank you for reading.

要查看或添加评论,请登录

Farhan Ahmed的更多文章

  • How to use AWS CLI

    How to use AWS CLI

    First, install AWS CLI Visit here: https://aws.amazon.

  • Deploy Snip-IT on Amazon EC2 -Manually

    Deploy Snip-IT on Amazon EC2 -Manually

    Hello learner, my name is Farhan Ahmed. I am presently pursuing B.

  • Taking a Deep Dive into the Inner Workings of Python ??!

    Taking a Deep Dive into the Inner Workings of Python ??!

    Taking a Deep Dive into the Inner Workings of Python ??! Introduction: Python is a versatile and widely used…

  • Setting up BurpSuite in Firefox

    Setting up BurpSuite in Firefox

    Steps to Setup BurpSuite: Open BurpSuite Click proxy -> options Note down interface IP and port no. Open Firefox Goto…

    3 条评论
  • 4-BIT ALU IN LOGISIM

    4-BIT ALU IN LOGISIM

    Hello readers, I am Farhan Ahmed. I design a 4-bit ALU using Logisim.

    4 条评论

社区洞察

其他会员也浏览了