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

temp-1

  🔧 vast_id Configuration Key: vast_id Description This section defines the VAST ID , a unique numeric identifier used by internal systems for asset tracking, automation, or integration with enterprise management platforms. It helps associate the server with inventory records, monitoring tools, or deployment workflows. ✅ Used during provisioning to register the system in centralized databases or orchestration systems. JSON Format json 1 "vast_id" : 12194 ✅ Can also be provided as a string: json 1 "vast_id" : "12194" Field Reference vast_id String or Integer Unique identifier for the system in VAST (Verizon Asset Systems Tracker) 12194 ✅ Must be non-empty and numeric — leading zeros may be stripped depending on system. Validations Enforced vast_id  is required and must be a non-empty string or integer Ensures the field is present and contains usable data If  vast_id  is a string, it must not be blank or whitespace-only Prevents " " , "...

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...

temp

 {   "_id": {     "$oid": "6841e4b0fd270b2ab92d7eaa"   },   // 📌 [Auto-generated]   // Description: Unique system identifier for internal use (MongoDB ObjectId).   // Type: ObjectId (string)   // Required: No (automatically handled)   "vast_id": "21452",   // 📌 [Required]   // Description: Your unique request ID or reference number.   // Type: string   // Format: Numeric string (e.g., "21452")   // Example: "21452"   "env": "dev",   // 📌 [Required]   // Description: The environment where the VM will be deployed.   // Type: string   // Allowed values: "dev", "qa", "uat", "prod"   // Example: "dev" for development, "prod" for production   "ver": "0.2",   // 📌 [Do Not Modify]   // Description: Template version. Used by automation to ensure compatibility.   // Type: string   // Format: Semantic versioning (e.g., "...