How to Change IP Address in Ubuntu Linux

June 8, 2024

How to Change IP Address in Ubuntu Linux
Cheap Linux Server

 


How to Change IP Address in Ubuntu Linux


Changing the IP address of your Ubuntu Linux system can be necessary for various reasons, such as setting up a static IP for a server, troubleshooting network issues, or simply experimenting with network configurations. In this blog post, we’ll cover how to change your IP address using both graphical and command-line interfaces in Ubuntu Linux.

Table of Contents

  1. Introduction
  2. Changing IP Address via GUI
  3. Changing IP Address via Command Line
  4. Configuring Static IP via Network Configuration File
  5. Conclusion

1. Introduction

IP addresses are crucial for network communication. An IP (Internet Protocol) address allows devices to locate and communicate with each other on a network. Ubuntu Linux, like other operating systems, supports both dynamic (DHCP) and static IP configurations.

Prerequisites

  • Basic knowledge of Linux commands.
  • Administrative access to the system.

2. Changing IP Address via GUI

If you’re using a desktop version of Ubuntu, you can easily change your IP address through the graphical user interface (GUI). Here’s how:

Steps:

  1. Open Network Settings:
    • Click on the network icon in the system tray (top-right corner).
    • Select “Settings” from the dropdown menu.
  2. Select Network Interface:
    • In the “Network” settings window, choose the network interface you want to configure (e.g., Wired, Wi-Fi).
    • Click on the gear icon next to the connected network.
  3. IPv4 Settings:
    • Go to the “IPv4” tab.
    • Change the “Method” to “Manual”.
  4. Set Static IP Address:
    • Enter your desired IP address, Netmask, and Gateway.
    • Optionally, configure the DNS servers.
  5. Apply Changes:
    • Click “Apply” to save the changes.
    • Restart the network interface or reboot your system for the changes to take effect.

3. Changing IP Address via Command Line

For those who prefer using the terminal, changing the IP address via the command line is straightforward.

Steps:

  1. Open Terminal:
    • You can open the terminal by pressing Ctrl + Alt + T.
  2. Identify Network Interface:
    • Run the following command to list all network interfaces:
      ip a

         Identify Network Interface    
    • Note the name of the interface you want to configure (e.g., eth0, enp3s0).
  3. Assign New IP Address:
    • Use the following command to assign a new IP address to the interface:
      sudo ip addr add 192.168.1.100/24 dev enp3s0
      Assign New IP Address
       
    • Replace 192.168.1.100/24 with your desired IP address and subnet mask.
  4. Remove Old IP Address:
    • If needed, remove the old IP address using:
      sudo ip addr del 192.168.1.101/24 dev enp3s0

      Remove Old IP Address
  5. Verify Changes:
    • Confirm the new IP address with:
      ip a show dev enp3s0

      Verify Changes 1

4. Configuring Static IP via Network Configuration File

For persistent IP configuration, editing the network configuration files is the most reliable method.

Steps:

  1. Open Network Configuration File:
    • Edit the appropriate network configuration file using a text editor, for example:
       
      sudo nano /etc/netplan/01-netcfg.yaml

      Open Network Configuration File
    • The file might be different on your system; common locations include /etc/netplan/ or /etc/network/interfaces.
  2. Configure Static IP:
    • Modify the file to include your static IP configuration. For example:
       
      network:

      version: 2

      ethernets:

      enp3s0:

      dhcp4: no

      addresses: [192.168.1.100/24]

      gateway4: 192.168.1.1

      nameservers:

      addresses: [8.8.8.8, 8.8.4.4]

      Configure Static IP
  3. Apply Configuration:
    • Apply the changes with:
       
      sudo netplan apply

      Apply Configuration
  4. Verify Changes:
    • Check the new configuration:
       
      ip a show dev enp3s0

      Verify Changes

5. Conclusion

Changing the IP address on an Ubuntu Linux system can be done easily through both the GUI and the command line. Whether you need a temporary change or a permanent static IP configuration, the steps outlined above will guide you through the process. Always remember to verify your changes to ensure the new settings are applied correctly.


 

How to Change IP Address in Ubuntu Linux (F.A.Q)

How can I temporarily change my IP address on Ubuntu using the command line?

To temporarily change your IP address using the command line, follow these steps:

  1. Open the terminal with Ctrl + Alt + T.
  2. Identify your network interface with ip a.
  3. Assign a new IP address with:
    sudo ip addr add 192.168.1.100/24 dev enp3s0
  4. Verify the change with:
    ip a show dev enp3s0

This change will not persist after a reboot.

 
How do I set a static IP address using the GUI in Ubuntu?

To set a static IP address using the GUI:

  1. Click on the network icon in the system tray and select “Settings.”
  2. Choose the network interface (e.g., Wired, Wi-Fi) and click the gear icon.
  3. In the “IPv4” tab, change the method to “Manual.”
  4. Enter your desired IP address, Netmask, and Gateway.
  5. Apply the changes and restart the network interface.
 
Where are the network configuration files located for setting a static IP address?

Network configuration files for setting a static IP address are commonly found in:

  • /etc/netplan/ (for systems using Netplan)
  • /etc/network/interfaces (for older systems or those using ifupdown)

For example, you might edit /etc/netplan/01-netcfg.yaml to configure a static IP.

How do I apply changes after modifying network configuration files in Ubuntu?

After modifying network configuration files, apply the changes using:

  • For Netplan:

    sudo netplan apply
  • For ifupdown:

     
    sudo ifdown <interface> && sudo ifup <interface>

Replace <interface> with your network interface name, such as enp3s0.

 
What is Forex VPS and Why You Need It

What is Forex VPS and Why You Need It

  What is Forex VPS and Why You Need It The world of Forex trading is dynamic and fast-paced, where milliseconds can make a difference between a profitable trade and a loss. As traders strive to optimize their trading strategies and enhance their performance, one...

What Is Ubuntu Pro, and Is It Worth It?

What Is Ubuntu Pro, and Is It Worth It?

  What Is Ubuntu Pro, and Is It Worth It? In today's fast-evolving technological landscape, security and compliance are paramount concerns for enterprises. As organizations increasingly adopt open-source solutions, maintaining the robustness and security of these...

0 Comments

Submit a Comment