Skip to main content

Temporarily Changing the IP Address in Linux (RHEL and Debian-Based Systems):

Changing the IP address on a Linux system can be useful for testing network configurations, troubleshooting connectivity, or temporarily reassigning network resources. This guide explains how to change an IP address temporarily on both RHEL-based and Debian-based Linux systems. These changes will reset after a reboot or network restart, making them ideal for temporary adjustments. 

Why Change the IP Address Temporarily?
Sometimes, you may need to test network configurations or isolate connectivity issues without making permanent changes to your system. By changing the IP address temporarily, you can: 
  • Test connections with different subnets or IP ranges. 
  • Diagnose network issues related to specific IP configurations. 
  • Experiment with network settings without permanently affecting the system. 
Method: Using the ip Command:

Linux provides a powerful command-line tool, ip, to manage network settings dynamically. With this command, you can add or remove IP addresses, manage routes, and perform other network-related tasks. 

Note: The changes made with the ip command will not persist after a reboot. If you need a permanent IP change, edit the network configuration files specific to your distribution. 

Step-by-Step Instructions:

For RHEL-Based Systems (e.g., CentOS, Red Hat Enterprise Linux):

Identify the Network Interface: First, determine the network interface name you want to configure. Use the following command:
# ip a
Look for the name of your interface, such as eth0, ens33, etc. 

Change the IP Address: Run the following command, replacing <new_ip>, <subnet_mask>, and <interface_name>:
# sudo ip addr add <new_ip>/<subnet_mask> dev <interface_name>
Example: To assign 192.168.1.100 with a subnet of 24 (equivalent to 255.255.255.0) on eth0:
# sudo ip addr add 192.168.1.100/24 dev eth0

Remove the Old IP Address (Optional): If you want to remove the old IP address, use:
# sudo ip addr del <old_ip>/<subnet_mask> dev <interface_name>

Set a Default Gateway: Define a default gateway to direct traffic outside your local network:
# sudo ip route add default via <gateway_ip>
Example:
# sudo ip route add default via 192.168.1.1

For Debian-Based Systems (e.g., Ubuntu, Debian):

The steps are similar on Debian-based systems. 

Identify the Network Interface
# ip a

Change the IP Address
# sudo ip addr add <new_ip>/<subnet_mask> dev <interface_name>

Remove the Old IP Address (Optional)
# sudo ip addr del <old_ip>/<subnet_mask> dev <interface_name>

Set a Default Gateway
# sudo ip route add default via <gateway_ip>

Example Command Summary:
For both systems, to change the IP address to 192.168.1.100 with subnet 24 on interface eth0, and set the gateway to 192.168.1.1:
# sudo ip addr add 192.168.1.100/24 dev eth0 # sudo ip route add default via 192.168.1.1

Verifying the IP Change:
After changing the IP, you can verify the new configuration by running:
# ip a
This command will display the updated IP address details for your network interfaces. You can also test connectivity by pinging another device on the network:
# ping <destination_ip>

Important Notes:

Temporary Changes: These IP changes will not persist across reboots. If you need a permanent IP configuration, modify the network configuration files. 
  • For RHEL-based systems: /etc/sysconfig/network-scripts/ifcfg- <interfaces>
  • For Debian-based systems: /etc/network/interfaces or /etc/netplan/ 
Permissions: sudo is required for these commands, so make sure you have appropriate permissions. 

Wrapping Up:
Changing an IP address temporarily using the ip command provides flexibility in managing and testing network configurations on Linux systems. Remember, this change is not permanent and will reset upon reboot. For a persistent IP change, edit your system's network configuration files.

Comments

Popular posts from this blog

How to Check Hardware Details on Linux:

  Whether you're troubleshooting hardware issues, planning an upgrade, or just curious about your system’s specifications, Linux provides a variety of commands to gather comprehensive hardware information. Here are some essential commands: 1.  Use lscpu to get detailed information about the CPU, including architecture, cores, threads, and CPU speeds. # lscpu                                                 2. The lshw command provides a complete overview of hardware configuration, including CPU, memory, storage, and network. You’ll likely need superuser privileges to run it. # sudo lshw                                                                               ...

testing

09052025 T-1 { "volume_groups" : { "vgroot" : { "vgsize" : "304G" , "fs_type" : "xfs" } } , "logical_volumes" : { "root" : { "lvroot" : { "vgname" : "vgroot" , "lvname" : "lvroot" , "lvsize" : "12G" , "mountpoint" : "/" , "purpose" : "root filesystem" , "disk" : 1 , "partition" : 2 } } , "swap" : { "lvswap" : { "vgname" : "vgroot" , "lvname" : "lvswap" , "lvsize" : "4G" , "mountpoint" : "NA" , "purpose" : "swap" , "disk" : 1 , "partit...

How Virtual Machines are Created in OpenStack: A Complete Backend Workflow:

When creating a Virtual Machine (VM) in OpenStack, several components work together in the backend to provision the instance. Here's a step-by-step explanation of how the process flows: 1. User Request Interface Used : The user initiates the VM creation through the Horizon Dashboard (web UI), the OpenStack CLI ( openstack server create ), or the OpenStack API. Request Information : The request includes parameters such as: VM name. Image (the operating system or custom image to boot from). Flavor (the compute, memory, and storage specifications). Network (which network the VM will be connected to). Security Groups (firewall rules). Key Pair (for SSH access). 2. API (Nova API) Component : Nova (Compute service). Process : The request is received by the Nova API , which validates the request (checks if the requested resources like the image, flavor, and network exist). If valid, the API creates an entry in the database for the new instance. Nova's Role : Nova is the core service r...