Linux Ipconfig | How to change IP in Linux Ubuntu

Learn how to change your IP address in Ubuntu effortlessly. Our comprehensive guide provides step-by-step instructions and valuable insights, enabling you to customize your network settings and enhance your online privacy. Take control of your Ubuntu experience and explore the possibilities of a new IP address today

Updated: 27 Jun, 23 by Susith Nonis 4 Min

List of content you will read in this article:

The Linux operating system has versions available. Ubuntu Linux is one of the most famous and widely used versions of this operating system. If you are using this operating system or want to start it, after installing the operating system, the first and most important thing to do is to configure the IP. Please keep reading to get used to it.

To configure IP in Ubuntu Linux, first, enter the following path in a command processor:

This tutorial will use the vi command processor to perform the steps.

vi /etc/network/interfaces

Then enter your IP address in the following order:

auto eth0 iface eth0 inet static address 192.168.1.150 netmask 255.255.255.0 network 192.168.2.0 broadcast 192.168.1.255 gateway 192.168.2.1

Then enter your IP in front of the address option and follow the steps below:

  • In front of the netmask option, enter your subnet address;
  • In the network option, you must enter your network address;
  • In the last two options, you must enter your broadcast and getaway, respectively;
  • In this way, the initial IP configuration in Ubuntu Linux is done successfully.

Once you have done the steps in retrospect, now it's time to set up DNS:

  • First, follow the following path with the vi editor

vi /etc/resolv.conf

Then enter the list of expressions below the mentioned DNS addresses. You can use the DNS addresses of your choice and enter them instead of the default addresses in this section:

nameserver 8.8.8.8 nameserver 8.8.4.4

Finally, you should save the file and close the page; this way, the DNS setting is done successfully.

⭐⭐Experience unmatched performance, flexibility, and security with our Ubuntu VPS servers. Empower your business with blazing-fast speeds, full root access, and seamless scalability, all backed by the rock-solid stability and open-source power of Linux. ⭐⭐

In the next step of IP configuration in Ubuntu Linux, you must remove it from your system to prevent the IP from being registered by DHCP. To do so, enter the following address in your editor:

apt-get remove dhcp-client;

This way, DHCP is removed, and your IP remains fixed in the system.

As the last step to configure IP in Ubuntu Linux, you must configure your network card once.

To do this, enter the following statement in the editor:

ifdown eth0 && ifup eth0

After you reset your network card, use the following command to ensure the correct IP configuration:

Ifconfig.

Final tips

After entering this command, you will be shown a page containing general system IP specifications. Dear ones, you can check each set item, and if any of them are incorrect, configure the IP again through the mentioned steps.

Finally, to test, you can ping a website to see if the IP configuration is done correctly or not. To do so, enter the ping command along with the address of your desired site, like ping google.com—if you see a page similar to the one below, the DNS and ip configuration settings are done correctly.

In this article, we tried to teach you how to configure your Linux IP in the best way. By following the mentioned steps, you can complete the IP settings of your system so that you don't face the problem of internet interruption and lack of network connection while using the Ubuntu Linux operating system.

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.