How to Temporarily Set a Static IP Address on a Linux System

Take Your Linux Skills to the Next Level All courses, certifications, ad-free articles & community — from $8/mo
Join Root →
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
From $8/mo · or $59/yr billed annually · Cancel anytime

Setting a static IP address on a Linux system temporarily is useful in situations where you need to troubleshoot network issues or configure networking for a specific session.

This temporary change won’t persist after a reboot, but it can be easily applied for immediate network setup needs.

In this guide, we’ll walk through the steps to configure a static IP address on a Linux system using command-line tools.

Step 1: Check Linux Network Interface

First, identify the name of your network interface by running the following ip command.

ip a

This command will display all the network interfaces available on your system. Look for your active network interface, usually named something like eth0, ens33, or wlan0 (for Wi-Fi).

Check Linux Network Interface
Check Linux Network Interface

Here, enp1s0 is the name of the network interface.

2. Temporarily Assign a Static IP Address on Linux

Once you’ve identified the network interface, use the ip command to assign a temporary static IP address. For example, to assign the IP address 192.168.122.50 with a subnet mask of 255.255.255.0, you can use the following command:

sudo ip addr add 192.168.122.50/24 dev enp1s0

To ensure your system can route traffic properly, you need to set the default gateway, which is typically the IP address of your router or gateway on the local network.

sudo ip route add default via 192.168.122.1

Here, 192.168.122.1 is the IP address of the gateway (router).

Step 3: Verify Network Configuration

After setting the static IP address, you should verify that the changes have been applied correctly.

ip a

Additionally, you can test connectivity by pinging an external site or your gateway:

ping 8.8.8.8

If you get replies, the network configuration is working.

Check Linux Network Configuration
Check Linux Network Configuration

Step 4: Removing Temporary Static IP Address

Since this configuration is temporary, it will revert back to the original settings after a reboot. However, if you want to manually remove the static IP address before rebooting, you can use the following command:

sudo ip addr del 192.168.122.50/24 dev enp1s0

This will remove the static IP address from the network interface.

Conclusion

Temporarily setting a static IP address in Linux can be useful for troubleshooting or specific network setups. The method shown here uses the ip command, which is a modern and versatile tool for managing network configurations on Linux systems.

Root Plan
Premium Linux Education for Serious Learners

Take Your Linux Skills to the Next Level

Root members get full access to every course, certification prep track, and a growing library of hands-on Linux content — with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
Ravi Saive
I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Root Plan Premium Linux Education for Serious Learners

Before You Go - Upgrade Your Linux Skills

Root members get everything in one place, with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Linux certifications: RHCSA, RHCE, LFCS and LFCA
Access new courses on release
Weekly newsletter, priority support & Telegram community
Join Root Today and Start Learning Linux the Right Way
Structured courses, certification prep, and a community of Linux professionals - all in one membership.
Join Root Plan →
$8/mo · or $59/yr billed annually