How to Change IP Address Linux [3 Effective Methods]

Written by

Reviewed by

Last updated: May 14, 2024

Expert verified

SVG Image


To change ip address in Linux, you can try these three methods:

  1. Using the ifconfig Command: Change IP address through the command line.
  2. Configuring IP Address via Network Manager: Change IP address using a graphical interface.
  3. Using the ip Command: Change IP address with extensive network configuration capabilities.

Explore the guide below to learn different methods and best practices to change ip address Linux.

IP addresses are unique identifiers assigned to devices connected to a network, enabling data transfer and communication. You might need to change IP address in Linux for various reasons, such as safeguarding your privacy, accessing geo-restricted content, troubleshooting network issues, or even experimenting with different network configurations.

In this ultimate guide, I will explore three effective methods to change IP address Linux and four best practices to remember when changing the ip address. 

How to Change IP Address Linux?

To change IP address in Linux, you have options that suit your preferences. For advanced users and scripting, the ifconfig command provides command-line control. Network Manager offers a user-friendly graphical interface, while the ip command provides extensive network configuration capabilities.

1. Using the ifconfig Command

This method allows you to change your IP address through the command line, making it useful for advanced users and scripting purposes. Follow these steps to change your IP address using ifconfig:

  1. Open a Terminal window.
opening terminal 10
  1. Identify the network interface you want to modify by running the command: 
<strong>ifconfig -a</strong>
  1. It will display a list of available network interfaces.
identify network interface you want to modify
  1. Disable the network interface using: 
<strong>sudo ifconfig interface down</strong>
  1. Replace the interface with the interface that you selected.
disabling network interface
  1. Change Linux IP address using the command: 
<strong>sudo ifconfig interface new_ip_address netmask subnet_mask up</strong>
  1. This command will change the IP address.
changing ip address
  1. Verify the changes by running ifconfig again.
verifying the changes

2. Configuring IP Address via Network Manager

Network Manager provides a user-friendly graphical interface for changing IP addresses, making it suitable for users who prefer a visual approach to network configuration. Here’s how you can change IP address in Linux using Network Manager’s graphical interface:

  1. Open the Network Manager applet from the system tray or access it through the system settings.
opening system settings
  1. Locate the network connection you want to modify and select it.
locating network to change ip address
  1. Click on the IPv4 or IPv6 tab, depending on the type of address you wish to change.
choosing ip address type to change it
  1. Choose the Manual option from the Method dropdown menu.
choosing manual method
  1. Enter the desired IP address, subnet mask, gateway, and DNS servers, then click on the apply button.
entering desired ip address
  1. It will set IP address Linux and the output will be:
changes are made

3. Using the ip Command

The ip command offers extensive network configuration capabilities, making it a powerful tool for advanced users who require fine-grained control over IP address changes. Follow these steps to change your IP address using the ip command:

  1. Open a Terminal window and identify the network interface you wish to modify using the command: 
<strong>ip addr show</strong>
  1. The command will show a list of network interfaces.
identifying network interface
  1. Disable the network interface: 
<strong>sudo ip link set interface down</strong>

Replace interface with interface name that you chose.

disable desired network interface
  1. Change Linux ip address by executing the command: 
<strong>sudo ip addr add new_ip_address/subnet_mask dev interface</strong>
  1. The command will change ip address on Linux.
changing ip address of desired interface
  1. Enable the network interface: 
<strong>sudo ip link set interface up</strong>
  1. The changes will look like this:
enabling network interface

How to Permanently Change IP Linux?

Permanently changing your IP address in Linux is essential for managing network configurations, ensuring stable server connectivity, and meeting security protocols. Setting a static IP prevents issues like network conflicts and device unavailability, facilitating a reliable setup. Follow these steps to change your ip permanently:

Netplan is a network configuration utility introduced in Ubuntu 17.10 that uses YAML configuration files to manage network settings. It simplifies the configuration process and is used by default in Ubuntu versions post-17.10.

  1. Open a terminal (Ctrl+Alt+T).
  2. List Netplan configurations with:
ls /etc/netplan
listing netplan configuration file
  1. Edit the Netplan Configuration. Choose an existing YAML file or create a new one:
sudo nano /etc/netplan/01-network-manager-all.yaml

This command opens an existing Netplan configuration file in the nano text editor. If the file does not exist, nano will start with a new file named 01-netcfg.yaml.

opening configuration file in nano editor
  1. Modify or add the configuration to set a static IP. Here’s an example:

  version: 2

  renderer: networkd



      dhcp4: no




        addresses: [,]


- to:


Replace enp0s3 with your network interface name and adjust the IP settings as necessary.

editing and saving network configuration file
  1. Save the changes and apply them:
sudo netplan apply

This command saves the changes to the system and applies the new network settings immediately.

applying the changes to netplan configuration
  1. Check the new IP address:
ip addr show enp0s3

This command displays the current network configuration for enp0s3, including the newly set static IP address.

verifying the changes

Best Practices for Changing IP Address

Changing IP addresses in Linux requires careful attention to ensure a smooth transition and avoid potential issues. Following these best practices when changing IP addresses in Linux helps maintain system security, minimize downtime, and ensure a smooth transition to the new IP configuration. Here are four best practices to follow:

1. 🔒 Ensure Proper Authorization and Permission

Before changing your IP address, it is crucial to ensure that you have the necessary authorization and permission to do so. Modifying network settings often requires administrative privileges.

Changing IP addresses without proper authorization can lead to network connectivity issues or violations of organizational policies. Always consult your network administrator or obtain the necessary permissions before proceeding to avoid potential complications or security breaches.

2. ⏰ Plan and Document Your Changes

Changing IP addresses should not be taken lightly. It is important to plan and document your changes to avoid confusion and ensure a smooth transition. Before making any modifications, create a clear plan outlining the steps and desired outcomes.

Documenting the changes helps maintain an organized process record, making troubleshooting easier if any issues arise. Documentation is also a valuable reference for future network management or IP address reconfiguration.

3. 💡 Verify Compatibility and Impact

Verify the compatibility and potential impact of changing your IP address, especially if your network is integrated with other systems or services. Determine whether the IP address change will affect other components such as DNS, routing, or network services. Assess potential compatibility issues with existing devices, software, or network configurations.

Identifying and addressing compatibility concerns beforehand can minimize disruptions and ensure a seamless transition to the new IP address without compromising other essential network functionalities.

4. 🔧 Test and Validate the New Configuration

Before implementing the new IP address configuration in a production environment, it is crucial to test and validate the changes thoroughly. Set up a test environment or use a sandbox network to simulate the configuration of the new IP address. Test network connectivity, services, and applications to ensure they function correctly with the new IP address.

By conducting thorough testing, you can identify and address any issues or conflicts before deploying the changes to the live network. This proactive approach helps mitigate potential downtime or disruptions and ensures a smooth transition to the new IP address.

    Reflecting on the Process of Linux Change IP Address

    I have provided you with various methods on how to change ip in Linux, including using the ifconfig command, modifying network configuration files, and utilizing the ip command. Alongside these methods, I have shared best practices to ensure a smooth and secure IP address change.

    To deepen your knowledge, consider exploring related topics such as advanced network configuration, network security practices, or setting up a Virtual Private Network (VPN) for enhanced privacy and anonymity. Stay updated with the latest developments in Linux networking to ensure you stay ahead in managing IP addresses and optimizing your network connectivity.

    Frequently Asked Questions

    How do I revert to my original IP address after making changes?

    If you wish to revert to your original IP address after making changes, simply follow the steps outlined in the respective method you used initially, but instead of entering a new IP address, use your initial IP configuration. For example, if you modified the IP address using the ifconfig command, open the Terminal and use sudo ifconfig interface original_ip_address netmask subnet_mask up. This will restore your original IP address and network settings.

    Will changing the IP address affect other network settings?

    Yes, changing the IP address can impact other network settings. DNS configuration is one of the critical network settings that can be affected. DNS (Domain Name System) translates domain names into IP addresses, allowing you to access websites using their domain names. When you change your IP address, it is important to ensure that the DNS settings are updated to reflect the new IP address, or else you may experience issues with domain name resolution.

    Can changing the IP address help bypass geo-restrictions?

    Yes, changing your IP address can be an effective method to bypass certain geo-restrictions. Changing your IP address, especially one associated with a different geographic location, can make it appear like you are accessing the internet from that particular region. This can help you bypass restrictions imposed by certain websites or online services that limit access based on geographical boundaries. By changing your IP address to one that allowed access, you can overcome these restrictions and gain access to content or services previously unavailable in your original location.

    How can I automate the IP address change process in Linux?

    To automate the IP address change process in Linux, you can utilize scripting and scheduling tools. You can automate the entire process by creating a script with the necessary commands to change the IP address. Save the script and grant it executable permissions. Then, you can use tools like cron, a time-based job scheduler, to schedule the execution of the script at specific intervals or during system startup. By configuring cron to run the script automatically, you eliminate the need for manual intervention, making the IP address change process in Linux seamless and automated.



    Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.



    Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

    Share this article
    Shareable URL
    Prev Post

    How to Find IP Address in Linux Command Line [5 Easy Methods]

    Next Post

    3 Effective Methods To Select All Text In Vim/Vi

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Read next